add support for mfrc proxyies
This commit is contained in:
70
nfcbord.h
70
nfcbord.h
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "placementnew.h"
|
||||
#include "serial.h"
|
||||
#include "shiftreg.h"
|
||||
#include "inputshiftreg.h"
|
||||
@ -6,25 +7,78 @@
|
||||
#include "softspim.h"
|
||||
#include "staticvector.h"
|
||||
#include "defines.h"
|
||||
#include "mfrcproxy.h"
|
||||
|
||||
class NfcBoard
|
||||
{
|
||||
public:
|
||||
ShiftReg<NFC_PORTS> csReg;
|
||||
InputShiftReg<NFC_PORTS> irqReg;
|
||||
private:
|
||||
|
||||
static constexpr int TYPE_MFRC522 = 0;
|
||||
static constexpr int TYPE_PROXY = 1;
|
||||
|
||||
union PortDevice
|
||||
{
|
||||
Mfrc522 mfrc522;
|
||||
MfrcProxy proxy;
|
||||
PortDevice(const Mfrc522& mfrc522In)
|
||||
{
|
||||
new (&mfrc522) Mfrc522(mfrc522In);
|
||||
}
|
||||
PortDevice(const MfrcProxy& proxyIn)
|
||||
{
|
||||
new (&proxy) MfrcProxy(proxyIn);
|
||||
}
|
||||
};
|
||||
|
||||
struct NfcPort
|
||||
{
|
||||
PortDevice device;
|
||||
uint8_t type;
|
||||
NfcPort(const Mfrc522& mfrc522): device(mfrc522)
|
||||
{
|
||||
type = TYPE_MFRC522;
|
||||
}
|
||||
NfcPort(const MfrcProxy& proxy): device(proxy)
|
||||
{
|
||||
type = TYPE_PROXY;
|
||||
}
|
||||
~NfcPort()
|
||||
{
|
||||
if(type == TYPE_MFRC522)
|
||||
device.mfrc522.~Mfrc522();
|
||||
else
|
||||
device.proxy.~MfrcProxy();
|
||||
}
|
||||
};
|
||||
|
||||
Serial* serial;
|
||||
SpiMaster spim;
|
||||
SVector<Mfrc522, NFC_PORTS> readers;
|
||||
ShiftReg<NFC_PORTS> csReg;
|
||||
bool enabled_ = false;
|
||||
|
||||
static void printTag(const uint8_t id, const Uid& uid, Serial* serial);
|
||||
|
||||
public:
|
||||
InputShiftReg<NFC_PORTS> irqReg;
|
||||
SVector<uint8_t, NFC_PORTS> irqPins;
|
||||
|
||||
SVector<NfcPort, NFC_PORTS> readers;
|
||||
SVector<volatile uint8_t, NFC_PORTS> watchDogBits;
|
||||
|
||||
static void detectCb(Mfrc522* reader, void* data);
|
||||
static void timeoutCb(uint8_t ret, Mfrc522* reader, uint8_t* response, uint8_t responseLen, void* userData);
|
||||
static void proxyDetectCb(MfrcProxy* proxy, const Uid uid, void* data);
|
||||
|
||||
NfcBoard();
|
||||
NfcBoard(Serial* serialIn);
|
||||
|
||||
void probe();
|
||||
|
||||
void printNfcDevices(Serial* serial);
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
int dispatch(char* inBuffer, Serial* serial);
|
||||
void poll(Serial* serial = nullptr);
|
||||
|
||||
void printNfcDevices();
|
||||
|
||||
int dispatch(char* inBuffer);
|
||||
|
||||
uint8_t csToIrq(uint8_t cs);
|
||||
};
|
||||
|
Reference in New Issue
Block a user