mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
added reader restart function which may be called from application, so the reader field will be shut down and restarted after a given time
This commit is contained in:
@@ -14,9 +14,12 @@ uint16_t Reader_FWT = ISO14443A_RX_PENDING_TIMEOUT;
|
||||
#define READER_FIELD_MINIMUM_WAITING_TIME 70 // ms
|
||||
|
||||
static uint16_t ReaderFieldStartTimestamp = 0;
|
||||
static uint16_t ReaderFieldRestartTimestamp = 0;
|
||||
static uint16_t ReaderFieldRestartDelay = 0;
|
||||
static volatile struct {
|
||||
bool Started;
|
||||
bool Ready;
|
||||
bool ToBeRestarted;
|
||||
} ReaderFieldFlags = { false };
|
||||
|
||||
uint8_t CodecBuffer[CODEC_BUFFER_SIZE];
|
||||
@@ -25,7 +28,7 @@ uint16_t ReaderThreshold = 400; // standard value
|
||||
// the following three functions prevent sending data directly after turning on the reader field
|
||||
void CodecReaderFieldStart(void) // DO NOT CALL THIS FUNCTION INSIDE APPLICATION!
|
||||
{
|
||||
if (!CodecGetReaderField())
|
||||
if (!CodecGetReaderField() && !ReaderFieldFlags.ToBeRestarted)
|
||||
{
|
||||
CodecSetReaderField(true);
|
||||
ReaderFieldFlags.Started = true;
|
||||
@@ -41,6 +44,14 @@ void CodecReaderFieldStop(void)
|
||||
ReaderFieldFlags.Ready = false;
|
||||
}
|
||||
|
||||
void CodecReaderFieldRestart(uint16_t delay)
|
||||
{
|
||||
ReaderFieldFlags.ToBeRestarted = true;
|
||||
ReaderFieldRestartTimestamp = SystemGetSysTick();
|
||||
ReaderFieldRestartDelay = delay;
|
||||
CodecReaderFieldStop();
|
||||
}
|
||||
|
||||
/*
|
||||
* This function returns false if and only if the reader field has been turned on in the last READER_FIELD_MIN..._TIME ms.
|
||||
* If the reader field is not active, true is returned.
|
||||
@@ -56,3 +67,18 @@ bool CodecIsReaderFieldReady(void)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CodecIsReaderToBeRestarted(void)
|
||||
{
|
||||
if (ReaderFieldFlags.ToBeRestarted)
|
||||
{
|
||||
if (SYSTICK_DIFF(ReaderFieldRestartTimestamp) >= ReaderFieldRestartDelay)
|
||||
{
|
||||
ReaderFieldFlags.ToBeRestarted = false;
|
||||
CodecReaderFieldStart();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,4 +248,7 @@ void CodecReaderFieldStart(void);
|
||||
void CodecReaderFieldStop(void);
|
||||
bool CodecIsReaderFieldReady(void);
|
||||
|
||||
void CodecReaderFieldRestart(uint16_t delay);
|
||||
#define FIELD_RESTART() CodecReaderFieldRestart(100)
|
||||
bool CodecIsReaderToBeRestarted(void);
|
||||
#endif /* CODEC_H_ */
|
||||
|
||||
@@ -287,7 +287,7 @@ void Reader14443ACodecTask(void)
|
||||
Flags.RxDone = true;
|
||||
Flags.RxPending = false;
|
||||
}
|
||||
if (!CodecIsReaderFieldReady())
|
||||
if (CodecIsReaderToBeRestarted() || !CodecIsReaderFieldReady())
|
||||
return;
|
||||
if (!Flags.RxPending && (Flags.Start || Flags.RxDone))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user