From 10ac19d698c00eb8797bbf7bd6bda08730488cbe Mon Sep 17 00:00:00 2001 From: Federico Cerutti Date: Thu, 15 Oct 2020 21:02:24 +0200 Subject: [PATCH] Additional reader mode ifdefs --- Firmware/Chameleon-Mini/Configuration.c | 8 ++++++++ Firmware/Chameleon-Mini/Memory.c | 9 ++++++++- Firmware/Chameleon-Mini/Settings.c | 7 ++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Firmware/Chameleon-Mini/Configuration.c b/Firmware/Chameleon-Mini/Configuration.c index 7c30348f..b0e855ec 100644 --- a/Firmware/Chameleon-Mini/Configuration.c +++ b/Firmware/Chameleon-Mini/Configuration.c @@ -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(); @@ -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); diff --git a/Firmware/Chameleon-Mini/Memory.c b/Firmware/Chameleon-Mini/Memory.c index 3ea60ab8..c950e839 100644 --- a/Firmware/Chameleon-Mini/Memory.c +++ b/Firmware/Chameleon-Mini/Memory.c @@ -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) { @@ -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(); } diff --git a/Firmware/Chameleon-Mini/Settings.c b/Firmware/Chameleon-Mini/Settings.c index 290806ce..dc557bc2 100644 --- a/Firmware/Chameleon-Mini/Settings.c +++ b/Firmware/Chameleon-Mini/Settings.c @@ -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] = { @@ -55,6 +57,7 @@ SettingsType EEMEM StoredSettings = { .ReaderThreshold = DEFAULT_READER_THRESHOLD, .bSakMode = 0, } +#endif } }; @@ -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(); }