Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISO14443A ApplicationProcess delayed responses #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion Firmware/Chameleon-Mini/Codec/ISO14443-2A.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef enum {
DEMOD_PARITY_BIT,

/* Loadmod */
LOADMOD_PREPARING,
LOADMOD_FDT,
LOADMOD_START,
LOADMOD_START_BIT0,
Expand Down Expand Up @@ -448,7 +449,9 @@ void ISO14443ACodecTask(void) {
}
}

if (AnswerBitCount != ISO14443A_APP_NO_RESPONSE) {
if (AnswerBitCount == ISO14443A_APP_DELAYED_RESPONSE) {
StateRegister = LOADMOD_PREPARING;
} else if (AnswerBitCount != ISO14443A_APP_NO_RESPONSE) {
LogEntry(LOG_INFO_CODEC_TX_DATA, CodecBuffer, (AnswerBitCount + 7) / 8);
LEDHook(LED_CODEC_TX, LED_PULSE);

Expand All @@ -474,3 +477,32 @@ void ISO14443ACodecTask(void) {
}
}

void ISO14443ASendResponse(const uint8_t *buffer, uint16_t AnswerBitCount)
{
/* Start sending a delayed response from the AppTask, if the last call
* to ApplicationProcess returned ISO14443A_APP_DELAYED_RESPONSE */
if (StateRegister != LOADMOD_PREPARING) {
return;
}

memcpy(CodecBuffer, buffer, (AnswerBitCount + 7) / 8);

if (AnswerBitCount & ISO14443A_APP_CUSTOM_PARITY) {
/* Application has generated it's own parity bits.
* Clear this option bit. */
AnswerBitCount &= ~ISO14443A_APP_CUSTOM_PARITY;
ParityBufferPtr = &CodecBuffer[ISO14443A_BUFFER_PARITY_OFFSET];
} else {
/* We have to generate the parity bits ourself */
ParityBufferPtr = 0;
}

LogEntry(LOG_INFO_CODEC_TX_DATA, CodecBuffer, (AnswerBitCount + 7) / 8);
LEDHook(LED_CODEC_TX, LED_PULSE);

BitCount = AnswerBitCount;
CodecBufferPtr = CodecBuffer;
CodecSetSubcarrier(CODEC_SUBCARRIERMOD_OOK, ISO14443A_SUBCARRIER_DIVIDER);

StateRegister = LOADMOD_START;
}
2 changes: 2 additions & 0 deletions Firmware/Chameleon-Mini/Codec/ISO14443-2A.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

#define ISO14443A_APP_NO_RESPONSE 0x0000
#define ISO14443A_APP_CUSTOM_PARITY 0x1000
#define ISO14443A_APP_DELAYED_RESPONSE 0x2000

#define ISO14443A_BUFFER_PARITY_OFFSET (CODEC_BUFFER_SIZE/2)

/* Codec Interface */
void ISO14443ACodecInit(void);
void ISO14443ACodecDeInit(void);
void ISO14443ACodecTask(void);
void ISO14443ASendResponse(const uint8_t *buffer, uint16_t bitCount);



Expand Down