RevG rebooted initial release

This commit is contained in:
Willok
2019-12-06 10:18:01 +01:00
parent a35610f6a7
commit 0cf47594ef
33 changed files with 982 additions and 220 deletions
+14 -14
View File
@@ -293,26 +293,26 @@ static const uint8_t TableC0[32] = {
static const uint8_t TableC7[32] = {
/* fc with Input {4,3,2,1,0} = (0,0,0,0,0) to (1,1,1,1,1) */
FC(0, 0, 0, 0, 0) << 7, FC(0, 0, 0, 0, 1) << 7, FC(0, 0, 0, 1, 0) << 7, FC(0, 0, 0, 1, 1) << 7,
FC(0, 0, 1, 0, 0) << 7, FC(0, 0, 1, 0, 1) << 7, FC(0, 0, 1, 1, 0) << 7, FC(0, 0, 1, 1, 1) << 7,
FC(0, 1, 0, 0, 0) << 7, FC(0, 1, 0, 0, 1) << 7, FC(0, 1, 0, 1, 0) << 7, FC(0, 1, 0, 1, 1) << 7,
FC(0, 1, 1, 0, 0) << 7, FC(0, 1, 1, 0, 1) << 7, FC(0, 1, 1, 1, 0) << 7, FC(0, 1, 1, 1, 1) << 7,
FC(1, 0, 0, 0, 0) << 7, FC(1, 0, 0, 0, 1) << 7, FC(1, 0, 0, 1, 0) << 7, FC(1, 0, 0, 1, 1) << 7,
FC(1, 0, 1, 0, 0) << 7, FC(1, 0, 1, 0, 1) << 7, FC(1, 0, 1, 1, 0) << 7, FC(1, 0, 1, 1, 1) << 7,
FC(1, 1, 0, 0, 0) << 7, FC(1, 1, 0, 0, 1) << 7, FC(1, 1, 0, 1, 0) << 7, FC(1, 1, 0, 1, 1) << 7,
FC(1, 1, 1, 0, 0) << 7, FC(1, 1, 1, 0, 1) << 7, FC(1, 1, 1, 1, 0) << 7, FC(1, 1, 1, 1, 1) << 7
FC(0, 0, 1, 0, 0) << 7, FC(0, 0, 1, 0, 1) << 7, FC(0, 0, 1, 1, 0) << 7, FC(0, 0, 1, 1, 1) << 7,
FC(0, 1, 0, 0, 0) << 7, FC(0, 1, 0, 0, 1) << 7, FC(0, 1, 0, 1, 0) << 7, FC(0, 1, 0, 1, 1) << 7,
FC(0, 1, 1, 0, 0) << 7, FC(0, 1, 1, 0, 1) << 7, FC(0, 1, 1, 1, 0) << 7, FC(0, 1, 1, 1, 1) << 7,
FC(1, 0, 0, 0, 0) << 7, FC(1, 0, 0, 0, 1) << 7, FC(1, 0, 0, 1, 0) << 7, FC(1, 0, 0, 1, 1) << 7,
FC(1, 0, 1, 0, 0) << 7, FC(1, 0, 1, 0, 1) << 7, FC(1, 0, 1, 1, 0) << 7, FC(1, 0, 1, 1, 1) << 7,
FC(1, 1, 0, 0, 0) << 7, FC(1, 1, 0, 0, 1) << 7, FC(1, 1, 0, 1, 0) << 7, FC(1, 1, 0, 1, 1) << 7,
FC(1, 1, 1, 0, 0) << 7, FC(1, 1, 1, 0, 1) << 7, FC(1, 1, 1, 1, 0) << 7, FC(1, 1, 1, 1, 1) << 7
};
/* Special table for nibble processing (e.g. ack), feedback at bit 3 */
static const uint8_t TableC3[32] = {
/* fc with Input {4,3,2,1,0} = (0,0,0,0,0) to (1,1,1,1,1) */
FC(0, 0, 0, 0, 0) << 3, FC(0, 0, 0, 0, 1) << 3, FC(0, 0, 0, 1, 0) << 3, FC(0, 0, 0, 1, 1) << 3,
FC(0, 0, 1, 0, 0) << 3, FC(0, 0, 1, 0, 1) << 3, FC(0, 0, 1, 1, 0) << 3, FC(0, 0, 1, 1, 1) << 3,
FC(0, 1, 0, 0, 0) << 3, FC(0, 1, 0, 0, 1) << 3, FC(0, 1, 0, 1, 0) << 3, FC(0, 1, 0, 1, 1) << 3,
FC(0, 1, 1, 0, 0) << 3, FC(0, 1, 1, 0, 1) << 3, FC(0, 1, 1, 1, 0) << 3, FC(0, 1, 1, 1, 1) << 3,
FC(1, 0, 0, 0, 0) << 3, FC(1, 0, 0, 0, 1) << 3, FC(1, 0, 0, 1, 0) << 3, FC(1, 0, 0, 1, 1) << 3,
FC(1, 0, 1, 0, 0) << 3, FC(1, 0, 1, 0, 1) << 3, FC(1, 0, 1, 1, 0) << 3, FC(1, 0, 1, 1, 1) << 3,
FC(1, 1, 0, 0, 0) << 3, FC(1, 1, 0, 0, 1) << 3, FC(1, 1, 0, 1, 0) << 3, FC(1, 1, 0, 1, 1) << 3,
FC(1, 1, 1, 0, 0) << 3, FC(1, 1, 1, 0, 1) << 3, FC(1, 1, 1, 1, 0) << 3, FC(1, 1, 1, 1, 1) << 3
FC(0, 0, 1, 0, 0) << 3, FC(0, 0, 1, 0, 1) << 3, FC(0, 0, 1, 1, 0) << 3, FC(0, 0, 1, 1, 1) << 3,
FC(0, 1, 0, 0, 0) << 3, FC(0, 1, 0, 0, 1) << 3, FC(0, 1, 0, 1, 0) << 3, FC(0, 1, 0, 1, 1) << 3,
FC(0, 1, 1, 0, 0) << 3, FC(0, 1, 1, 0, 1) << 3, FC(0, 1, 1, 1, 0) << 3, FC(0, 1, 1, 1, 1) << 3,
FC(1, 0, 0, 0, 0) << 3, FC(1, 0, 0, 0, 1) << 3, FC(1, 0, 0, 1, 0) << 3, FC(1, 0, 0, 1, 1) << 3,
FC(1, 0, 1, 0, 0) << 3, FC(1, 0, 1, 0, 1) << 3, FC(1, 0, 1, 1, 0) << 3, FC(1, 0, 1, 1, 1) << 3,
FC(1, 1, 0, 0, 0) << 3, FC(1, 1, 0, 0, 1) << 3, FC(1, 1, 0, 1, 0) << 3, FC(1, 1, 0, 1, 1) << 3,
FC(1, 1, 1, 0, 0) << 3, FC(1, 1, 1, 0, 1) << 3, FC(1, 1, 1, 1, 0) << 3, FC(1, 1, 1, 1, 1) << 3
};
/* Filter Output Macros */
@@ -133,7 +133,7 @@ bool ISO14443AWakeUp(void *Buffer, uint16_t *BitCount, uint16_t ATQAValue, bool
return true;
} else {
*BitCount = 0;
// *BitCount = 0;
return false;
}
File diff suppressed because it is too large Load Diff
@@ -16,6 +16,10 @@
#define MIFARE_CLASSIC_1K_MEM_SIZE 1024
#define MIFARE_CLASSIC_4K_MEM_SIZE 4096
void DetectionInit(void);
void DetectionLogClear(void);
void MifareDetectionInit1K(void);
void MifareDetectionInit4K(void);
void MifareClassicAppInitMini4B(void);
void MifareClassicAppInit1K(void);
void MifareClassicAppInit4K(void);
@@ -4,6 +4,7 @@
#include "../Codec/Reader14443-2A.h"
#include "Crypto1.h"
#include "../System.h"
#include "../uartcmd.h"
#include "../Terminal/Terminal.h"
@@ -138,8 +139,8 @@ uint16_t addParityBits(uint8_t *Buffer, uint16_t BitCount) {
uint16_t removeParityBits(uint8_t *Buffer, uint16_t BitCount) {
// Short frame, no parity bit is added
if (BitCount == 7)
return 7;
if (BitCount <= 7)
return BitCount;
uint16_t i;
for (i = 0; i < (BitCount / 9); i++) {
@@ -147,7 +148,7 @@ uint16_t removeParityBits(uint8_t *Buffer, uint16_t BitCount) {
if (i % 8)
Buffer[i] |= (Buffer[i + i / 8 + 1] << (8 - (i % 8)));
}
return BitCount / 9 * 8;
return (BitCount / 9) * 8;
}
bool checkParityBits(uint8_t *Buffer, uint16_t BitCount) {
@@ -226,7 +227,7 @@ static uint16_t Reader14443A_Select(uint8_t *Buffer, uint16_t BitCount) {
switch (ReaderState) {
case STATE_IDLE:
case STATE_HALT:
Reader_FWT = 4;
Reader_FWT = ISO14443A_RX_PENDING_TIMEOUT;
/* Send a REQA */
Buffer[0] = ISO14443A_CMD_WUPA; // whenever REQA works, WUPA also works, so we choose WUPA always
ReaderState = STATE_READY;
@@ -802,17 +803,21 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
if (CardCandidatesIdx == 1) {
int cfgid = -1;
switch (CardCandidates[0]) {
#ifdef CONFIG_MF_ULTRALIGHT_SUPPORT
case CardType_NXP_MIFARE_Ultralight: {
cfgid = CONFIG_MF_ULTRALIGHT;
// TODO: enter MFU clone mdoe
break;
}
#endif
case CardType_NXP_MIFARE_Classic_1k:
case CardType_Infineon_MIFARE_Classic_1k: {
if (CardCharacteristics.UIDSize == UIDSize_Single) {
cfgid = CONFIG_MF_CLASSIC_1K;
#ifdef CONFIG_MF_CLASSIC_1K_7B_SUPPORT
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
cfgid = CONFIG_MF_CLASSIC_1K_7B;
#endif
}
break;
}
@@ -821,8 +826,10 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
case CardType_Nokia_MIFARE_Classic_4k_emulated_6131: {
if (CardCharacteristics.UIDSize == UIDSize_Single) {
cfgid = CONFIG_MF_CLASSIC_4K;
#ifdef CONFIG_MF_CLASSIC_1K_7B_SUPPORT
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
cfgid = CONFIG_MF_CLASSIC_4K_7B;
#endif
}
break;
}
@@ -23,8 +23,7 @@ static enum {
} SniffState = STATE_IDLE;
static uint16_t tmp_th = CODEC_THRESHOLD_CALIBRATE_MIN;
static uint8_t Thresholds[(CODEC_THRESHOLD_CALIBRATE_MAX - CODEC_THRESHOLD_CALIBRATE_MIN) /
CODEC_THRESHOLD_CALIBRATE_STEPS] = {0};
static uint8_t Thresholds[(CODEC_THRESHOLD_CALIBRATE_MAX - CODEC_THRESHOLD_CALIBRATE_MIN) / CODEC_THRESHOLD_CALIBRATE_STEPS] = {0};
void Sniff14443AAppInit(void) {
SniffState = STATE_REQA;
+25 -1
View File
@@ -1,3 +1,14 @@
/*
* Button.c
*
* Created on: 20.03.2013
* Author: skuser
*
* ChangeLog
* 2019-09-22 willok Reverse switch function and log clearing function are added.
*
*/
#include "Button.h"
#include "Random.h"
#include "Common.h"
@@ -25,10 +36,12 @@ static const MapEntryType PROGMEM ButtonActionMap[] = {
{ .Id = BUTTON_ACTION_UID_LEFT_DECREMENT, .Text = "UID_LEFT_DECREMENT" },
{ .Id = BUTTON_ACTION_UID_RIGHT_DECREMENT, .Text = "UID_RIGHT_DECREMENT" },
{ .Id = BUTTON_ACTION_CYCLE_SETTINGS, .Text = "CYCLE_SETTINGS" },
{ .Id = BUTTON_ACTION_CYCLE_SETTINGS_DEC, .Text = "CYCLE_SETTINGS_DEC" },
{ .Id = BUTTON_ACTION_STORE_MEM, .Text = "STORE_MEM" },
{ .Id = BUTTON_ACTION_RECALL_MEM, .Text = "RECALL_MEM" },
{ .Id = BUTTON_ACTION_TOGGLE_FIELD, .Text = "TOGGLE_FIELD" },
{ .Id = BUTTON_ACTION_STORE_LOG, .Text = "STORE_LOG" },
{ .Id = BUTTON_ACTION_CLEAR_LOG, .Text = "CLEAR_LOG" },
{ .Id = BUTTON_ACTION_CLONE, .Text = "CLONE" },
};
@@ -146,7 +159,12 @@ static void ExecuteButtonAction(ButtonActionEnum ButtonAction) {
}
case BUTTON_ACTION_CYCLE_SETTINGS: {
SettingsCycle();
SettingsCycle(true);
break;
}
case BUTTON_ACTION_CYCLE_SETTINGS_DEC: {
SettingsCycle(false);
break;
}
@@ -174,6 +192,12 @@ static void ExecuteButtonAction(ButtonActionEnum ButtonAction) {
break;
}
case BUTTON_ACTION_CLEAR_LOG: {
LogMemClear();
DetectionLogClear();
break;
}
case BUTTON_ACTION_CLONE: {
CommandExecute("CLONE");
break;
+2
View File
@@ -28,10 +28,12 @@ typedef enum {
BUTTON_ACTION_UID_LEFT_DECREMENT,
BUTTON_ACTION_UID_RIGHT_DECREMENT,
BUTTON_ACTION_CYCLE_SETTINGS,
BUTTON_ACTION_CYCLE_SETTINGS_DEC,
BUTTON_ACTION_STORE_MEM,
BUTTON_ACTION_RECALL_MEM,
BUTTON_ACTION_TOGGLE_FIELD,
BUTTON_ACTION_STORE_LOG,
BUTTON_ACTION_CLEAR_LOG,
BUTTON_ACTION_CLONE,
/* This has to be last element */
+8
View File
@@ -1,10 +1,13 @@
#include "Chameleon-Mini.h"
#include "Uart.h"
#include "uartcmd.h"
int main(void) {
SystemInit();
SettingsLoad();
LEDInit();
MemoryInit();
DetectionInit();
CodecInitCommon();
ConfigurationInit();
TerminalInit();
@@ -13,6 +16,8 @@ int main(void) {
AntennaLevelInit();
LogInit();
SystemInterruptInit();
uart_init();
uartcmd_init();
while (1) {
if (SystemTick100ms()) {
@@ -25,10 +30,13 @@ int main(void) {
ApplicationTick();
CommandLineTick();
AntennaLevelTick();
uartcmd_tick();
LEDHook(LED_POWERED, LED_ON);
}
uart_task();
uartcmd_task();
TerminalTask();
LogTask();
ApplicationTask();
+1 -1
View File
@@ -20,7 +20,7 @@
#include "AntennaLevel.h"
#include "Settings.h"
#define CHAMELEON_MINI_VERSION_STRING BUILD_DATE
#define CHAMELEON_MINI_VERSION_STRING __DATE__
#endif //CHAMELEON_MINI_H
+1
View File
@@ -11,6 +11,7 @@
uint16_t Reader_FWT = ISO14443A_RX_PENDING_TIMEOUT;
// 这个是从开启到准备好的时间间隔,之前不能发送数据
#define READER_FIELD_MINIMUM_WAITING_TIME 70 // ms
static uint16_t ReaderFieldStartTimestamp = 0;
+1 -5
View File
@@ -12,7 +12,7 @@
#include "LEDHook.h"
#include "AntennaLevel.h"
#include "Terminal/Terminal.h"
#include <util/delay.h>
//#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/io.h>
@@ -80,8 +80,6 @@ static volatile uint16_t BitRate2;
static volatile uint16_t SampleDataCount;
static volatile uint16_t ReadCommandFromReader = 0;
#ifdef CONFIG_VICINITY_SUPPORT
/* This function implements CODEC_DEMOD_IN_INT0_VECT interrupt vector.
* It is called when a pulse is detected in CODEC_DEMOD_IN_PORT (PORTB).
* The relevatn interrupt vector is registered to CODEC_DEMOD_IN_MASK0 (PIN1) via:
@@ -461,8 +459,6 @@ LOADMOD_FINISHED_LABEL:
return;
}
#endif /* CONFIG_VICINITY_SUPPORT */
/* This functions resets all global variables used in the codec and enables interrupts to wait for reader data */
void StartISO15693Demod(void) {
/* Reset global variables to default values */
@@ -11,7 +11,7 @@
#include "../Application/Application.h"
#include "LEDHook.h"
#include "Terminal/Terminal.h"
#include <util/delay.h>
//#include <util/delay.h>
#define SAMPLE_RATE_SYSTEM_CYCLES ((uint16_t) (((uint64_t) F_CPU * ISO14443A_BIT_RATE_CYCLES) / CODEC_CARRIER_FREQ) )
#define ISO14443A_RX_MINIMUM_BITCOUNT 4
@@ -48,6 +48,8 @@ void Reader14443ACodecInit(void) {
/* Initialize common peripherals and start listening
* for incoming data. */
CodecInitCommon();
// 中断回调
isr_func_TCD0_CCC_vect = &isr_Reader14443_2A_TCD0_CCC_vect;
CodecSetDemodPower(true);
@@ -198,7 +200,9 @@ void isr_Reader14443_2A_TCD0_CCC_vect(void) {
BitCountUp = 0;
State = STATE_IDLE;
#ifndef CONFIG_UART_MODE
PORTE.OUTTGL = PIN3_bm;
#endif
}
// Reader -> card send bits finished
@@ -208,7 +212,9 @@ void Reader14443AMillerEOC(void) {
CODEC_TIMER_SAMPLING.INTFLAGS = TC0_CCBIF_bm | TC0_CCCIF_bm;
CODEC_TIMER_SAMPLING.INTCTRLB = TC_CCBINTLVL_OFF_gc | TC_CCCINTLVL_HI_gc;
CODEC_TIMER_SAMPLING.PERBUF = SAMPLE_RATE_SYSTEM_CYCLES - 1;
#ifndef CONFIG_UART_MODE
PORTE.OUTTGL = PIN3_bm;
#endif
}
// EOC of Card->Reader found
@@ -13,7 +13,7 @@
#include "../Application/Application.h"
#include "LEDHook.h"
#include "Terminal/Terminal.h"
#include <util/delay.h>
//#include <util/delay.h>
/* Sampling is done using internal clock, synchronized to the field modulation.
* For that we need to convert the bit rate for the internal clock. */
@@ -109,7 +109,9 @@ INLINE void ReaderSniffDeInit(void) {
// Find first pause and start sampling
ISR(CODEC_DEMOD_IN_INT1_VECT) {
#ifndef CONFIG_UART_MODE
PORTE.OUTSET = PIN2_bm;
#endif
/* This is the first edge of the first modulation-pause after StartDemod.
* Now we have time to start
@@ -147,8 +149,9 @@ ISR(CODEC_TIMER_SAMPLING_CCD_VECT) {
// Shutdown the Reader->Card Sniffing,
// disable the sampling timer
#ifndef CONFIG_UART_MODE
PORTE.OUTCLR = PIN2_bm;
#endif
CODEC_TIMER_SAMPLING.CTRLA = TC_CLKSEL_OFF_gc;
@@ -473,7 +476,9 @@ ISR(CODEC_TIMER_TIMESTAMPS_CCB_VECT) { // EOC found
void Sniff14443ACodecInit(void) {
#ifndef CONFIG_UART_MODE
PORTE.DIRSET = PIN3_bm | PIN2_bm;
#endif
// Common Codec Register settings
CodecInitCommon();
isr_func_CODEC_TIMER_LOADMOD_CCB_VECT = &isr_SniffISO14443_2A_CODEC_TIMER_LOADMOD_CCB_VECT;
@@ -496,7 +501,9 @@ void Sniff14443ACodecDeInit(void) {
void Sniff14443ACodecTask(void) {
#ifndef CONFIG_UART_MODE
PORTE.OUTSET = PIN3_bm;
#endif
if (Flags.ReaderDataAvaliable) {
Flags.ReaderDataAvaliable = false;
@@ -526,7 +533,8 @@ void Sniff14443ACodecTask(void) {
CardSniffDeinit();
ReaderSniffInit();
}
#ifndef CONFIG_UART_MODE
PORTE.OUTCLR = PIN3_bm;
#endif
}
+1 -1
View File
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <util/parity.h>
#include <util/delay.h>
//#include <util/delay.h>
#include <avr/pgmspace.h>
#include <avr/io.h>
+60
View File
@@ -3,6 +3,10 @@
*
* Created on: 15.02.2013
* Author: skuser
*
* ChangeLog
* 2019-09-22 Willok Add Turn on the antenna load when simulation tags. It solves the problem of blind area in the short distance of reading head.
*
*/
#include "Configuration.h"
@@ -35,6 +39,12 @@ static const MapEntryType PROGMEM ConfigurationMap[] = {
#ifdef CONFIG_MF_CLASSIC_4K_7B_SUPPORT
{ .Id = CONFIG_MF_CLASSIC_4K_7B, .Text = "MF_CLASSIC_4K_7B" },
#endif
#ifdef CONFIG_MF_DETECTION_SUPPORT
{ .Id = CONFIG_MF_DETECTION, .Text = "MF_DETECTION_1K" },
#endif
#ifdef CONFIG_MF_DETECTION_4K_SUPPORT
{ .Id = CONFIG_MF_DETECTION_4K, .Text = "MF_DETECTION_4K" },
#endif
#ifdef CONFIG_ISO14443A_SNIFF_SUPPORT
{ .Id = CONFIG_ISO14443A_SNIFF, .Text = "ISO14443A_SNIFF" },
#endif
@@ -247,6 +257,42 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
.TagFamily = TAG_FAMILY_ISO14443A
},
#endif
#ifdef CONFIG_MF_DETECTION_SUPPORT
[CONFIG_MF_DETECTION] = {
.CodecInitFunc = ISO14443ACodecInit,
.CodecDeInitFunc = ISO14443ACodecDeInit,
.CodecTaskFunc = ISO14443ACodecTask,
.ApplicationInitFunc = MifareDetectionInit1K,
.ApplicationResetFunc = MifareClassicAppReset,
.ApplicationTaskFunc = MifareClassicAppTask,
.ApplicationTickFunc = ApplicationTickDummy,
.ApplicationProcessFunc = MifareClassicAppProcess,
.ApplicationGetUidFunc = MifareClassicGetUid,
.ApplicationSetUidFunc = MifareClassicSetUid,
.UidSize = MIFARE_CLASSIC_UID_SIZE,
.MemorySize = MIFARE_CLASSIC_1K_MEM_SIZE,
.ReadOnly = false,
.TagFamily = TAG_FAMILY_ISO14443A
},
#endif
#ifdef CONFIG_MF_DETECTION_4K_SUPPORT
[CONFIG_MF_DETECTION_4K] = {
.CodecInitFunc = ISO14443ACodecInit,
.CodecDeInitFunc = ISO14443ACodecDeInit,
.CodecTaskFunc = ISO14443ACodecTask,
.ApplicationInitFunc = MifareDetectionInit4K,
.ApplicationResetFunc = MifareClassicAppReset,
.ApplicationTaskFunc = MifareClassicAppTask,
.ApplicationTickFunc = ApplicationTickDummy,
.ApplicationProcessFunc = MifareClassicAppProcess,
.ApplicationGetUidFunc = MifareClassicGetUid,
.ApplicationSetUidFunc = MifareClassicSetUid,
.UidSize = MIFARE_CLASSIC_UID_SIZE,
.MemorySize = MIFARE_CLASSIC_4K_MEM_SIZE,
.ReadOnly = false,
.TagFamily = TAG_FAMILY_ISO14443A
},
#endif
#ifdef CONFIG_ISO14443A_SNIFF_SUPPORT
[CONFIG_ISO14443A_SNIFF] = {
.CodecInitFunc = Sniff14443ACodecInit,
@@ -380,6 +426,9 @@ ConfigurationType ActiveConfiguration;
void ConfigurationInit(void) {
memcpy_P(&ActiveConfiguration,
&ConfigurationTable[CONFIG_NONE], sizeof(ConfigurationType));
// Simulation mode antenna load, Default is close load.
PORTC.DIRSET = PIN7_bm;
PORTC.OUTCLR = PIN7_bm;
ConfigurationSetById(GlobalSettings.ActiveSettingPtr->Configuration);
}
@@ -387,6 +436,7 @@ void ConfigurationInit(void) {
void ConfigurationSetById(ConfigurationEnum Configuration) {
CodecDeInit();
// Cancel currently executed command when configuration changes
CommandLinePendingTaskBreak(); // break possibly pending task
GlobalSettings.ActiveSettingPtr->Configuration = Configuration;
@@ -395,6 +445,12 @@ void ConfigurationSetById(ConfigurationEnum Configuration) {
memcpy_P(&ActiveConfiguration,
&ConfigurationTable[Configuration], sizeof(ConfigurationType));
// Configure antenna load as appropriate
if (Configuration == CONFIG_ISO14443A_READER)
PORTC.OUTCLR = PIN7_bm;
else
PORTC.OUTSET = PIN7_bm;
CodecInit();
ApplicationInit();
}
@@ -407,6 +463,10 @@ bool ConfigurationSetByName(const char *Configuration) {
MapIdType Id;
if (MapTextToId(ConfigurationMap, ARRAY_COUNT(ConfigurationMap), Configuration, &Id)) {
// The last configuration can only be configured as a reader
if (GlobalSettings.ActiveSettingIdx >= SETTINGS_COUNT && Id != CONFIG_ISO14443A_READER) {
return false;
}
ConfigurationSetById(Id);
LogEntry(LOG_INFO_CONFIG_SET, Configuration, StringLength(Configuration, CONFIGURATION_NAME_LENGTH_MAX - 1));
return true;
+6
View File
@@ -41,6 +41,12 @@ typedef enum {
#ifdef CONFIG_MF_CLASSIC_4K_7B_SUPPORT
CONFIG_MF_CLASSIC_4K_7B,
#endif
#ifdef CONFIG_MF_DETECTION_SUPPORT
CONFIG_MF_DETECTION,
#endif
#ifdef CONFIG_MF_DETECTION_4K_SUPPORT
CONFIG_MF_DETECTION_4K,
#endif
#ifdef CONFIG_ISO14443A_SNIFF_SUPPORT
CONFIG_ISO14443A_SNIFF,
#endif
+116 -9
View File
@@ -1,3 +1,13 @@
/*
* LED.c
*
* Created on: 13.05.2013
* Author: skuser
*
* ChangeLog
* 2019-09-22 willok Add 8 LED for indicate 8 slot
*
*/
#include "LED.h"
#include "Settings.h"
#include "Map.h"
@@ -24,7 +34,97 @@ static const MapEntryType PROGMEM LEDFunctionMap[] = {
{ .Id = LED_LOG_MEM_FULL, .Text = "LOGMEM_FULL" },
};
INLINE void Tick(uint8_t Mask, LEDActionEnum *Action) {
void LEDHook(LEDHookEnum Func, LEDActionEnum Action) {
extern LEDActionEnum LEDGreenAction;
extern LEDActionEnum LEDRedAction;
if (GlobalSettings.ActiveSettingPtr->LEDGreenFunction == Func) {
LEDGreenAction = Action;
}
if (GlobalSettings.ActiveSettingPtr->LEDRedFunction == Func) {
LEDRedAction = Action;
}
}
// 0 = Default mode1 = 8 LED mode
uint8_t LedMode = 1;
uint8_t LedConfig[] = {
1, 0, 2, 2, 2, // 1
0, 1, 2, 2, 2,
0, 0, 1, 2, 2,
0, 0, 0, 2, 2,
0, 0, 2, 1, 2,
0, 0, 2, 0, 2,
0, 0, 2, 2, 1,
0, 0, 2, 2, 0,
0, 0, 0, 1, 2, // 9
};
// LED init
void LEDInit(void) {
LED_PORT.DIRSET = LED_MASK;
// For Extended led, high resistance
PORTA.DIRCLR = PIN0_bm;
PORTE.DIRCLR = PIN1_bm;
PORTE.DIRCLR = PIN0_bm;
}
// 根据状态切换指示灯
void Led8Map(uint8_t LedNo) {
// 超出范围
if (LedNo > SETTINGS_COUNT) {
return;
}
if (LedConfig[LedNo * 5])
LED_PORT.OUTSET = PIN4_bm;
else
LED_PORT.OUTCLR = PIN4_bm;
if (LedConfig[LedNo * 5 + 1])
LED_PORT.OUTSET = PIN3_bm;
else
LED_PORT.OUTCLR = PIN3_bm;
if (0 == LedConfig[LedNo * 5 + 2]) {
PORTA.OUTCLR = PIN0_bm;
PORTA.DIRSET = PIN0_bm;
} else if (1 == LedConfig[LedNo * 5 + 2]) {
PORTA.OUTSET = PIN0_bm;
PORTA.DIRSET = PIN0_bm;
} else {
PORTA.DIRCLR = PIN0_bm;
}
if (0 == LedConfig[LedNo * 5 + 3]) {
PORTE.OUTCLR = PIN1_bm;
PORTE.DIRSET = PIN1_bm;
} else if (1 == LedConfig[LedNo * 5 + 3]) {
PORTE.OUTSET = PIN1_bm;
PORTE.DIRSET = PIN1_bm;
} else {
PORTE.DIRCLR = PIN1_bm;
}
if (0 == LedConfig[LedNo * 5 + 4]) {
PORTE.OUTCLR = PIN0_bm;
PORTE.DIRSET = PIN0_bm;
} else if (1 == LedConfig[LedNo * 5 + 4]) {
PORTE.OUTSET = PIN0_bm;
PORTE.DIRSET = PIN0_bm;
} else {
PORTE.DIRCLR = PIN0_bm;
}
}
// 循环执行,更新指示灯状态
//INLINE void Tick(uint8_t Mask, LEDActionEnum* Action)
void Tick(uint8_t Mask, LEDActionEnum *Action) {
static uint8_t LEDRedBlinkPrescaler = 0;
static uint8_t LEDGreenBlinkPrescaler = 0;
uint8_t *BlinkPrescaler = (Action == &LEDGreenAction) ? &LEDGreenBlinkPrescaler : &LEDRedBlinkPrescaler;
@@ -58,7 +158,7 @@ INLINE void Tick(uint8_t Mask, LEDActionEnum *Action) {
}
break;
case LED_BLINK_1X ... LED_BLINK_8X:
case LED_BLINK_1X ... LED_BLINK_9X:
if (++(*BlinkPrescaler) == BLINK_PRESCALER) {
*BlinkPrescaler = 0;
@@ -88,14 +188,21 @@ INLINE void Tick(uint8_t Mask, LEDActionEnum *Action) {
}
}
void LEDInit(void) {
LED_PORT.DIRSET = LED_MASK;
}
// 指示灯循环
void LEDTick(void) {
Tick(LED_RED, &LEDRedAction);
Tick(LED_GREEN, &LEDGreenAction);
// 默认模式
if (0 == LedMode) {
Tick(LED_RED, &LEDRedAction);
Tick(LED_GREEN, &LEDGreenAction);
} else {
static uint8_t LastLed = 0xFF;
// 配置更改,更新显示
if (LastLed != GlobalSettings.ActiveSettingIdx) {
LastLed = GlobalSettings.ActiveSettingIdx;
Led8Map(LastLed);
}
}
}
void LEDGetFuncList(char *List, uint16_t BufferSize) {
+3 -2
View File
@@ -12,8 +12,8 @@
#include "Common.h"
#define LED_PORT PORTA
#define LED_GREEN PIN4_bm
#define LED_RED PIN3_bm
#define LED_GREEN PIN3_bm
#define LED_RED PIN4_bm
#define LED_MASK (LED_GREEN | LED_RED)
typedef enum LEDFunctionEnum {
@@ -55,6 +55,7 @@ typedef enum LEDActionEnum {
LED_BLINK_6X,
LED_BLINK_7X,
LED_BLINK_8X,
LED_BLINK_9X,
} LEDActionEnum;
+3 -1
View File
@@ -10,6 +10,8 @@
#include "Settings.h"
void LEDHook(LEDHookEnum Func, LEDActionEnum Action);
/*
INLINE void LEDHook(LEDHookEnum Func, LEDActionEnum Action) {
extern LEDActionEnum LEDGreenAction;
extern LEDActionEnum LEDRedAction;
@@ -22,5 +24,5 @@ INLINE void LEDHook(LEDHookEnum Func, LEDActionEnum Action) {
LEDRedAction = Action;
}
}
*/
#endif /* LEDHOOK_H_ */

Some files were not shown because too many files have changed in this diff Show More