Skip to content

Commit

Permalink
Additional reader mode ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
ceres-c committed Oct 15, 2020
1 parent 5ef4968 commit 10ac19d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Firmware/Chameleon-Mini/Configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,14 @@ void ConfigurationSetById(ConfigurationEnum Configuration) {
&ConfigurationTable[Configuration], sizeof(ConfigurationType));

// Configure antenna load as appropriate
#ifdef CONFIG_ISO14443A_READER_SUPPORT
if (Configuration == CONFIG_ISO14443A_READER)
PORTC.OUTCLR = PIN7_bm;
else
PORTC.OUTSET = PIN7_bm;
#else
PORTC.OUTSET = PIN7_bm;
#endif

CodecInit();
ApplicationInit();
Expand All @@ -523,7 +527,11 @@ bool ConfigurationSetByName(const char *Configuration) {

if (MapTextToId(ConfigurationMap, ARRAY_COUNT(ConfigurationMap), Configuration, &Id)) {
// The last configuration can only be configured as a reader
#ifdef CONFIG_ISO14443A_READER_SUPPORT
if (GlobalSettings.ActiveSettingIdx >= SETTINGS_COUNT && Id != CONFIG_ISO14443A_READER) {
#else
if (GlobalSettings.ActiveSettingIdx >= SETTINGS_COUNT) {
#endif
return false;
}
ConfigurationSetById(Id);
Expand Down
9 changes: 8 additions & 1 deletion Firmware/Chameleon-Mini/Memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,15 @@ INLINE void FRAMWrite(const void *Buffer, uint16_t Address, uint16_t ByteCount)
SPIWriteBlock(Buffer, ByteCount);

FRAM_PORT.OUTSET = FRAM_CS;

#ifdef CONFIG_ISO14443A_READER_SUPPORT
if (0 == Address && GlobalSettings.ActiveSettingPtr->Configuration != CONFIG_ISO14443A_READER) {
ConfigurationSetById(GlobalSettings.ActiveSettingPtr->Configuration);
}
#else
if (0 == Address) {
ConfigurationSetById(GlobalSettings.ActiveSettingPtr->Configuration);
}
#endif
}

INLINE void FlashRead(void *Buffer, uint32_t Address, uint16_t ByteCount) {
Expand Down Expand Up @@ -421,8 +426,10 @@ void MemoryRecall(void) {
if (GlobalSettings.ActiveSettingIdx < SETTINGS_COUNT)
FlashToFRAM((uint32_t) GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING, ActiveConfiguration.MemorySize);

#ifdef CONFIG_ISO14443A_READER_SUPPORT
if (GlobalSettings.ActiveSettingPtr->Configuration != CONFIG_ISO14443A_READER)
ActiveConfiguration.ApplicationInitFunc();
#endif

SystemTickClearFlag();
}
Expand Down
7 changes: 6 additions & 1 deletion Firmware/Chameleon-Mini/Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ SettingsType EEMEM StoredSettings = {
.PendingTaskTimeout = DEFAULT_PENDING_TASK_TIMEOUT,
.ReaderThreshold = DEFAULT_READER_THRESHOLD,
.bSakMode = 0,
},
}
#ifdef CONFIG_ISO14443A_READER_SUPPORT
,
// In the last configuration, there is no storage space. This is used as the card reader mode only
[SETTINGS_COUNT] =
{
Expand All @@ -55,6 +57,7 @@ SettingsType EEMEM StoredSettings = {
.ReaderThreshold = DEFAULT_READER_THRESHOLD,
.bSakMode = 0,
}
#endif
}
};

Expand All @@ -77,7 +80,9 @@ void SettingsLoad(void) {
GlobalSettings.Settings[i].PendingTaskTimeout = DEFAULT_PENDING_TASK_TIMEOUT;
GlobalSettings.Settings[i].ReaderThreshold = DEFAULT_READER_THRESHOLD;
}
#ifdef CONFIG_ISO14443A_READER_SUPPORT
GlobalSettings.Settings[SETTINGS_COUNT].Configuration = CONFIG_ISO14443A_READER;
#endif

SettingsSave();
}
Expand Down

0 comments on commit 10ac19d

Please sign in to comment.