ReaderThreshold is stored in eeprom.

Signed-off-by: Michal Demin <michaldemin@gmail.com>
This commit is contained in:
Michal Demin
2017-06-15 22:09:46 +02:00
parent 0e61d2a47a
commit 6016bb7944
5 changed files with 7 additions and 6 deletions
-1
View File
@@ -23,7 +23,6 @@ static volatile struct {
} ReaderFieldFlags = { false };
uint8_t CodecBuffer[CODEC_BUFFER_SIZE];
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!
+2 -2
View File
@@ -13,6 +13,7 @@
#include <stdbool.h>
#include "../Common.h"
#include "../Configuration.h"
#include "../Settings.h"
#include "ISO14443-2A.h"
#include "Reader14443-2A.h"
@@ -89,7 +90,6 @@
#define CodecPtrRegister1 (*((volatile uint8_t**) &GPIOR8))
#define CodecPtrRegister2 (*((volatile uint8_t**) &GPIORA))
extern uint16_t ReaderThreshold;
extern uint16_t Reader_FWT;
#define FWI2FWT(x) ((uint32_t)(256 * 16 * ((uint32_t)1 << (x))) / (CODEC_CARRIER_FREQ / 1000) + 1)
@@ -172,7 +172,7 @@ INLINE void CodecInitCommon(void)
DACB.CTRLB = DAC_CHSEL_SINGLE_gc;
DACB.CTRLC = DAC_REFSEL_AVCC_gc;
DACB.CTRLA = DAC_IDOEN_bm | DAC_ENABLE_bm;
DACB.CH0DATA = ReaderThreshold; // real threshold voltage can be calculated with ch0data * Vref / 0xFFF
DACB.CH0DATA = GlobalSettings.ActiveSettingPtr->ReaderThreshold; // real threshold voltage can be calculated with ch0data * Vref / 0xFFF
/* Configure Analog Comparator 0 to detect changes in demodulated reader field */
ACA.AC0MUXCTRL = AC_MUXPOS_DAC_gc | AC_MUXNEG_PIN7_gc;
+2 -1
View File
@@ -25,7 +25,8 @@ SettingsType EEMEM StoredSettings = {
.LogMode = DEFAULT_LOG_MODE,
.LEDRedFunction = DEFAULT_RED_LED_ACTION,
.LEDGreenFunction = DEFAULT_GREEN_LED_ACTION,
.PendingTaskTimeout = DEFAULT_PENDING_TASK_TIMEOUT
.PendingTaskTimeout = DEFAULT_PENDING_TASK_TIMEOUT,
.ReaderThreshold = 400
}}
};
+1
View File
@@ -29,6 +29,7 @@ typedef struct {
LEDHookEnum LEDRedFunction; /// Red LED function for this setting.
LEDHookEnum LEDGreenFunction; /// Green LED function for this setting.
uint16_t PendingTaskTimeout; /// Timeout for timeout commands for this setting, in multiples of 100 ms.
uint16_t ReaderThreshold;
} SettingsEntryType;
typedef struct {
+2 -2
View File
@@ -578,7 +578,7 @@ CommandStatusIdType CommandSetTimeout(char* OutMessage, const char* InParam)
CommandStatusIdType CommandGetThreshold(char* OutParam)
{
snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, PSTR("%u"), ReaderThreshold);
snprintf_P(OutParam, TERMINAL_BUFFER_SIZE, PSTR("%u"), GlobalSettings.ActiveSettingPtr->ReaderThreshold);
return COMMAND_INFO_OK_WITH_TEXT_ID;
}
@@ -593,7 +593,7 @@ CommandStatusIdType CommandSetThreshold(char* OutMessage, const char* InParam)
if (!sscanf_P(InParam, PSTR("%5d"), &tmp) || tmp > CODEC_MAXIMUM_THRESHOLD)
return COMMAND_ERR_INVALID_PARAM_ID;
DACB.CH0DATA = tmp;
ReaderThreshold = tmp;
GlobalSettings.ActiveSettingPtr->ReaderThreshold = tmp;
return COMMAND_INFO_OK_ID;
}