mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
ISO15693 sniff codec
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
static inline
|
||||
void AntennaLevelInit(void) {
|
||||
ADCA.CAL = (PRODSIGNATURES_ADCACAL1 << 8) | PRODSIGNATURES_ADCACAL0; /* Load calibration data, source: https://www.avrfreaks.net/comment/2080211#comment-2080211 */
|
||||
ADCA.CTRLA = ADC_ENABLE_bm;
|
||||
ADCA.CTRLB = ADC_RESOLUTION_12BIT_gc;
|
||||
ADCA.REFCTRL = ADC_REFSEL_INT1V_gc | ADC_BANDGAP_bm;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "Sniff14443A.h"
|
||||
#include "EM4233.h"
|
||||
#include "NTAG215.h"
|
||||
#include "Sniff15693.h"
|
||||
|
||||
/* Function wrappers */
|
||||
INLINE void ApplicationInit(void) {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
extern bool checkParityBits(uint8_t *Buffer, uint16_t BitCount);
|
||||
|
||||
Sniff14443Command Sniff14443CurrentCommand = Sniff14443_Do_Nothing;
|
||||
//bool selected = false;
|
||||
static enum {
|
||||
STATE_IDLE,
|
||||
STATE_REQA,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* SniffISO15693.h
|
||||
*
|
||||
* Created on: 05.11.2019
|
||||
* Author: ceres-c
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
|
||||
|
||||
#include "../Codec/SniffISO15693.h"
|
||||
#include "Sniff15693.h"
|
||||
|
||||
void SniffISO15693AppInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void SniffISO15693AppReset(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SniffISO15693AppTask(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SniffISO15693AppTick(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint16_t SniffISO15693AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ISO15693_SNIFF_SUPPORT */
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* SniffISO15693.h
|
||||
*
|
||||
* Created on: 05.11.2019
|
||||
* Author: ceres-c
|
||||
*/
|
||||
|
||||
#ifndef SNIFF_15693_H_
|
||||
#define SNIFF_15693_H_
|
||||
|
||||
#include "Application.h"
|
||||
#include "ISO15693-A.h"
|
||||
|
||||
void SniffISO15693AppInit(void);
|
||||
void SniffISO15693AppReset(void);
|
||||
void SniffISO15693AppTask(void);
|
||||
void SniffISO15693AppTick(void);
|
||||
uint16_t SniffISO15693AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes);
|
||||
|
||||
#endif /* SNIFF_15693_H_ */
|
||||
@@ -26,9 +26,13 @@ static volatile struct {
|
||||
uint8_t CodecBuffer[CODEC_BUFFER_SIZE];
|
||||
uint8_t CodecBuffer2[CODEC_BUFFER_SIZE];
|
||||
|
||||
void (* volatile isr_func_CODEC_TIMER_LOADMOD_CCB_VECT)(void) = NULL;
|
||||
void (* volatile isr_func_TCD0_CCC_vect)(void) = NULL;
|
||||
void (* volatile isr_func_CODEC_DEMOD_IN_INT0_VECT)(void) = NULL;
|
||||
void (* volatile isr_func_ACA_AC0_vect)(void);
|
||||
void (* volatile isr_func_CODEC_TIMER_LOADMOD_OVF_VECT)(void) = NULL;
|
||||
void (* volatile isr_func_CODEC_TIMER_LOADMOD_CCA_VECT)(void) = NULL;
|
||||
void (* volatile isr_func_CODEC_TIMER_LOADMOD_CCB_VECT)(void) = NULL;
|
||||
void (* volatile isr_func_CODEC_TIMER_TIMESTAMPS_CCA_VECT)(void) = NULL;
|
||||
|
||||
// the following three functions prevent sending data directly after turning on the reader field
|
||||
void CodecReaderFieldStart(void) { // DO NOT CALL THIS FUNCTION INSIDE APPLICATION!
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#define CODEC_SUBCARRIER_CCEN_PSK TC1_CCAEN_bm
|
||||
#define CODEC_SUBCARRIER_CCEN_OOK TC1_CCBEN_bm
|
||||
#define CODEC_TIMER_SAMPLING TCD0
|
||||
#define CODEC_TIMER_SAMPLING_OVF_VECT TCD0_OVF_vect
|
||||
#define CODEC_TIMER_SAMPLING_CCA_VECT TCD0_CCA_vect
|
||||
#define CODEC_TIMER_SAMPLING_CCB_VECT TCD0_CCB_vect
|
||||
#define CODEC_TIMER_SAMPLING_CCC_VECT TCD0_CCC_vect
|
||||
@@ -64,6 +65,7 @@
|
||||
#define CODEC_THRESHOLD_CALIBRATE_MAX 2048
|
||||
#define CODEC_THRESHOLD_CALIBRATE_STEPS 16
|
||||
#define CODEC_TIMER_TIMESTAMPS TCD1
|
||||
#define CODEC_TIMER_TIMESTAMPS_OVF_VECT TCD1_OVF_vect
|
||||
#define CODEC_TIMER_TIMESTAMPS_CCA_VECT TCD1_CCA_vect
|
||||
#define CODEC_TIMER_TIMESTAMPS_CCB_VECT TCD1_CCB_vect
|
||||
|
||||
@@ -80,6 +82,7 @@
|
||||
#include "Reader14443-2A.h"
|
||||
#include "SniffISO14443-2A.h"
|
||||
#include "ISO15693.h"
|
||||
#include "SniffISO15693.h"
|
||||
|
||||
/* Timing definitions for ISO14443A */
|
||||
#define ISO14443A_SUBCARRIER_DIVIDER 16
|
||||
@@ -123,9 +126,22 @@ void isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void);
|
||||
extern void (* volatile isr_func_CODEC_DEMOD_IN_INT0_VECT)(void);
|
||||
void isr_ISO14443_2A_TCD0_CCC_vect(void);
|
||||
void isr_ISO15693_CODEC_DEMOD_IN_INT0_VECT(void);
|
||||
extern void (* volatile isr_func_CODEC_TIMER_LOADMOD_OVF_VECT)(void);
|
||||
void isr_ISO14443_2A_CODEC_TIMER_LOADMOD_OVF_VECT(void);
|
||||
void isr_SNIFF_ISO15693_CODEC_TIMER_LOADMOD_OVF_VECT(void);
|
||||
extern void (* volatile isr_func_CODEC_TIMER_LOADMOD_CCA_VECT)(void);
|
||||
void isr_Reader14443_2A_CODEC_TIMER_LOADMOD_CCA_VECT(void);
|
||||
void isr_SNIFF_ISO15693_CODEC_TIMER_LOADMOD_CCA_VECT(void);
|
||||
extern void (* volatile isr_func_CODEC_TIMER_LOADMOD_CCB_VECT)(void);
|
||||
void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void);
|
||||
void isr_SniffISO14443_2A_CODEC_TIMER_LOADMOD_CCB_VECT(void);
|
||||
void isr_SNIFF_ISO15693_CODEC_TIMER_LOADMOD_CCA_VECT(void);
|
||||
extern void (* volatile isr_func_CODEC_TIMER_TIMESTAMPS_CCA_VECT)(void);
|
||||
void isr_Reader14443_2A_CODEC_TIMER_TIMESTAMPS_CCA_VECT(void);
|
||||
void isr_SNIFF_ISO15693_CODEC_TIMER_TIMESTAMPS_CCA_VECT(void);
|
||||
extern void (* volatile isr_func_ACA_AC0_vect)(void);
|
||||
void isr_SniffISO14443_2A_ACA_AC0_VECT(void);
|
||||
void isr_SNIFF_ISO15693_ACA_AC0_VECT(void);
|
||||
|
||||
INLINE void CodecInit(void) {
|
||||
ActiveConfiguration.CodecInitFunc();
|
||||
@@ -166,9 +182,6 @@ INLINE void CodecInitCommon(void) {
|
||||
EVSYS.CH0MUX = CODEC_DEMOD_IN_EVMUX0;
|
||||
EVSYS.CH1MUX = CODEC_DEMOD_IN_EVMUX1;
|
||||
|
||||
EVSYS.CH2MUX = CODEC_DEMOD_IN_EVMUX0;
|
||||
|
||||
|
||||
/* Configure loadmod pin configuration and use a virtual port configuration
|
||||
* for single instruction cycle access */
|
||||
CODEC_LOADMOD_PORT.DIRSET = CODEC_LOADMOD_MASK;
|
||||
|
||||
@@ -223,7 +223,7 @@ ISR(CODEC_TIMER_SAMPLING_CCA_VECT) {
|
||||
}
|
||||
|
||||
// Enumulate as a card to send card responds
|
||||
ISR(CODEC_TIMER_LOADMOD_OVF_VECT) {
|
||||
ISR_SHARED isr_ISO14443_2A_CODEC_TIMER_LOADMOD_OVF_VECT(void) {
|
||||
/* Bit rate timer. Output a half bit on the output. */
|
||||
|
||||
static void *JumpTable[] = {
|
||||
@@ -386,6 +386,7 @@ void ISO14443ACodecInit(void) {
|
||||
|
||||
isr_func_TCD0_CCC_vect = &isr_Reader14443_2A_TCD0_CCC_vect;
|
||||
isr_func_CODEC_DEMOD_IN_INT0_VECT = &isr_ISO14443_2A_TCD0_CCC_vect;
|
||||
isr_func_CODEC_TIMER_LOADMOD_OVF_VECT = &isr_ISO14443_2A_CODEC_TIMER_LOADMOD_OVF_VECT;
|
||||
CodecInitCommon();
|
||||
StartDemod();
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ void ISO15693CodecTask(void) {
|
||||
|
||||
if (DemodByteCount > 0) {
|
||||
LogEntry(LOG_INFO_CODEC_RX_DATA, CodecBuffer, DemodByteCount);
|
||||
LEDHook(LED_CODEC_RX, LED_PULSE);
|
||||
//LEDHook(LED_CODEC_RX, LED_PULSE);
|
||||
|
||||
if (CodecBuffer[0] & REQ_SUBCARRIER_DUAL) {
|
||||
bDualSubcarrier = true;
|
||||
|
||||
@@ -48,9 +48,10 @@ void Reader14443ACodecInit(void) {
|
||||
/* Initialize common peripherals and start listening
|
||||
* for incoming data. */
|
||||
CodecInitCommon();
|
||||
|
||||
// 中断回调
|
||||
/* Register shared interrupt handlers */
|
||||
isr_func_TCD0_CCC_vect = &isr_Reader14443_2A_TCD0_CCC_vect;
|
||||
isr_func_CODEC_TIMER_LOADMOD_CCA_VECT = &isr_Reader14443_2A_CODEC_TIMER_LOADMOD_CCA_VECT;
|
||||
isr_func_CODEC_TIMER_TIMESTAMPS_CCA_VECT = &isr_Reader14443_2A_CODEC_TIMER_TIMESTAMPS_CCA_VECT;
|
||||
CodecSetDemodPower(true);
|
||||
|
||||
CODEC_TIMER_SAMPLING.PER = SAMPLE_RATE_SYSTEM_CYCLES - 1;
|
||||
@@ -215,7 +216,7 @@ void Reader14443AMillerEOC(void) {
|
||||
}
|
||||
|
||||
// EOC of Card->Reader found
|
||||
ISR(CODEC_TIMER_TIMESTAMPS_CCA_VECT) { // EOC found
|
||||
ISR_SHARED isr_Reader14443_2A_CODEC_TIMER_TIMESTAMPS_CCA_VECT(void) { // EOC found
|
||||
Reader14443A_EOC();
|
||||
}
|
||||
|
||||
@@ -231,7 +232,8 @@ ISR(ACA_AC1_vect) { // this interrupt either finds the SOC or gets triggered bef
|
||||
// according to the pause and modulated period
|
||||
// if the half bit duration is modulated, then add 1 to buffer
|
||||
// if the half bit duration is not modulated, then add 0 to buffer
|
||||
ISR(CODEC_TIMER_LOADMOD_CCA_VECT) { // pause found
|
||||
// ISR(CODEC_TIMER_LOADMOD_CCA_VECT) { // pause found
|
||||
ISR_SHARED isr_Reader14443_2A_CODEC_TIMER_LOADMOD_CCA_VECT(void) { // pause found
|
||||
uint8_t tmp = CODEC_TIMER_TIMESTAMPS.CNTL;
|
||||
CODEC_TIMER_TIMESTAMPS.CNT = 0;
|
||||
|
||||
|
||||
@@ -347,8 +347,7 @@ INLINE void Insert1(void) {
|
||||
}
|
||||
|
||||
// This interrupt find Card -> Reader SOC
|
||||
ISR(ACA_AC0_vect) { // this interrupt either finds the SOC or gets triggered before
|
||||
|
||||
ISR_SHARED isr_SniffISO14443_2A_ACA_AC0_VECT (void) { // this interrupt either finds the SOC or gets triggered before
|
||||
ACA.AC0CTRL &= ~AC_INTLVL_HI_gc; // disable this interrupt
|
||||
// enable the pause-finding timer
|
||||
CODEC_TIMER_LOADMOD.CTRLD = TC_EVACT_RESTART_gc | TC_EVSEL_CH2_gc;
|
||||
@@ -480,6 +479,7 @@ void Sniff14443ACodecInit(void) {
|
||||
#endif
|
||||
// Common Codec Register settings
|
||||
CodecInitCommon();
|
||||
isr_func_ACA_AC0_vect = &isr_SniffISO14443_2A_ACA_AC0_VECT;
|
||||
isr_func_CODEC_TIMER_LOADMOD_CCB_VECT = &isr_SniffISO14443_2A_CODEC_TIMER_LOADMOD_CCB_VECT;
|
||||
// Enable demodulator power
|
||||
CodecSetDemodPower(true);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* SniffISO15693.h
|
||||
*
|
||||
* Created on: 05.11.2019
|
||||
* Author: ceres-c
|
||||
*/
|
||||
|
||||
#ifndef SNIFF_ISO15693_H_
|
||||
#define SNIFF_ISO15693_H_
|
||||
|
||||
#include "Terminal/CommandLine.h"
|
||||
|
||||
#define ISO15693_APP_NO_RESPONSE 0x0000
|
||||
|
||||
#define SUBCARRIER_1 32
|
||||
#define SUBCARRIER_2 28
|
||||
#define SUBCARRIER_OFF 0
|
||||
#define SOF_PATTERN 0x1D
|
||||
#define EOF_PATTERN 0xB8
|
||||
|
||||
//Used when checking the request sent from the reader
|
||||
#define ISO15693_REQ_SUBCARRIER_SINGLE 0x00
|
||||
#define ISO15693_REQ_SUBCARRIER_DUAL 0x01
|
||||
#define ISO15693_REQ_DATARATE_LOW 0x00
|
||||
#define ISO15693_REQ_DATARATE_HIGH 0x02
|
||||
|
||||
/* Codec Interface */
|
||||
void SniffISO15693CodecInit(void);
|
||||
void SniffISO15693CodecDeInit(void);
|
||||
void SniffISO15693CodecTask(void);
|
||||
|
||||
/* Application Interface */
|
||||
void SniffISO15693CodecStart(void);
|
||||
void SniffISO15693CodecReset(void);
|
||||
|
||||
/* Internal functions */
|
||||
INLINE void SNIFF_ISO15693_READER_EOC_VCD(void);
|
||||
INLINE void CardSniffInit(void);
|
||||
|
||||
|
||||
#endif /* SNIFF_ISO15693_H_ */
|
||||
@@ -411,14 +411,14 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
#endif
|
||||
#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
|
||||
[CONFIG_ISO15693_SNIFF] = {
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = ApplicationInitDummy,
|
||||
.ApplicationResetFunc = ApplicationResetDummy,
|
||||
.ApplicationTaskFunc = ApplicationTaskDummy,
|
||||
.ApplicationTickFunc = ApplicationTickDummy,
|
||||
.ApplicationProcessFunc = ApplicationProcessDummy,
|
||||
.CodecInitFunc = SniffISO15693CodecInit,
|
||||
.CodecDeInitFunc = SniffISO15693CodecDeInit,
|
||||
.CodecTaskFunc = SniffISO15693CodecTask,
|
||||
.ApplicationInitFunc = SniffISO15693AppInit,
|
||||
.ApplicationResetFunc = SniffISO15693AppReset,
|
||||
.ApplicationTaskFunc = SniffISO15693AppTask,
|
||||
.ApplicationTickFunc = SniffISO15693AppTick,
|
||||
.ApplicationProcessFunc = SniffISO15693AppProcess,
|
||||
.ApplicationGetUidFunc = ApplicationGetUidDummy,
|
||||
.ApplicationSetUidFunc = ApplicationSetUidDummy,
|
||||
.UidSize = 0,
|
||||
|
||||
@@ -44,6 +44,22 @@ CODEC_DEMOD_IN_INT0_VECT:
|
||||
CODEC_TIMER_SAMPLING_CCC_VECT:
|
||||
call_isr isr_func_TCD0_CCC_vect
|
||||
|
||||
.global CODEC_TIMER_LOADMOD_OVF_VECT
|
||||
CODEC_TIMER_LOADMOD_OVF_VECT:
|
||||
call_isr isr_func_CODEC_TIMER_LOADMOD_OVF_VECT
|
||||
|
||||
.global CODEC_TIMER_LOADMOD_CCA_VECT
|
||||
CODEC_TIMER_LOADMOD_CCA_VECT:
|
||||
call_isr isr_func_CODEC_TIMER_LOADMOD_CCA_VECT
|
||||
|
||||
.global CODEC_TIMER_LOADMOD_CCB_VECT
|
||||
CODEC_TIMER_LOADMOD_CCB_VECT:
|
||||
call_isr isr_func_CODEC_TIMER_LOADMOD_CCB_VECT
|
||||
call_isr isr_func_CODEC_TIMER_LOADMOD_CCB_VECT
|
||||
|
||||
.global CODEC_TIMER_TIMESTAMPS_CCA_VECT
|
||||
CODEC_TIMER_TIMESTAMPS_CCA_VECT:
|
||||
call_isr isr_func_CODEC_TIMER_TIMESTAMPS_CCA_VECT
|
||||
|
||||
.global ACA_AC0_vect
|
||||
ACA_AC0_vect:
|
||||
call_isr isr_func_ACA_AC0_vect
|
||||
|
||||
@@ -21,7 +21,7 @@ SETTINGS += -DCONFIG_NTAG215_SUPPORT
|
||||
SETTINGS += -DCONFIG_VICINITY_SUPPORT
|
||||
SETTINGS += -DCONFIG_SL2S2002_SUPPORT
|
||||
SETTINGS += -DCONFIG_TITAGITSTANDARD_SUPPORT
|
||||
# SETTINGS += -DCONFIG_ISO15693_SNIFF_SUPPORT
|
||||
SETTINGS += -DCONFIG_ISO15693_SNIFF_SUPPORT
|
||||
SETTINGS += -DCONFIG_EM4233_SUPPORT
|
||||
|
||||
#Support magic mode on mifare classic configuration
|
||||
@@ -112,9 +112,9 @@ OPTIMIZATION = s
|
||||
SRC += Chameleon-Mini.c LUFADescriptors.c System.c ISRSharing.S Configuration.c Random.c Common.c Memory.c MemoryAsm.S Button.c Log.c Settings.c LED.c Map.c AntennaLevel.c Uart.c uartcmd.c
|
||||
SRC += Terminal/Terminal.c Terminal/Commands.c Terminal/XModem.c Terminal/CommandLine.c
|
||||
SRC += Codec/Codec.c Codec/ISO14443-2A.c Codec/Reader14443-2A.c Codec/SniffISO14443-2A.c Codec/Reader14443-ISR.S
|
||||
SRC += Application/MifareUltralight.c Application/MifareClassic.c Application/ISO14443-3A.c Application/Crypto1.c Application/Reader14443A.c Application/Sniff14443A.c Application/CryptoTDEA.S
|
||||
SRC += Codec/ISO15693.c
|
||||
SRC += Application/Vicinity.c Application/Sl2s2002.c Application/TITagitstandard.c Application/ISO15693-A.c Application/EM4233.c Application/NTAG215.c
|
||||
SRC += Application/MifareUltralight.c Application/MifareClassic.c Application/ISO14443-3A.c Application/Crypto1.c Application/Reader14443A.c Application/Sniff14443A.c Application/CryptoTDEA.S Application/NTAG215.c
|
||||
SRC += Codec/ISO15693.c Codec/SniffISO15693.c
|
||||
SRC += Application/Vicinity.c Application/Sl2s2002.c Application/TITagitstandard.c Application/ISO15693-A.c Application/EM4233.c Application/Sniff15693.c
|
||||
SRC += $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
|
||||
LUFA_PATH = ../LUFA
|
||||
CC_FLAGS = -flto -DUSE_LUFA_CONFIG_HEADER -DFLASH_DATA_ADDR=$(FLASH_DATA_ADDR) -DFLASH_DATA_SIZE=$(FLASH_DATA_SIZE) -DSPM_HELPER_ADDR=$(SPM_HELPER_ADDR) -DBUILD_DATE=$(BUILD_DATE) -DCOMMIT_ID=\"$(COMMIT_ID)\" $(SETTINGS)
|
||||
@@ -135,7 +135,7 @@ AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_WRITE_APP_LATEST = -U application:w:Latest/Chameleon-RevG.hex
|
||||
AVRDUDE_WRITE_EEPROM_LATEST = -U eeprom:w:Latest/Chameleon-RevG.eep
|
||||
|
||||
.PHONY: program program-latest dfu-flip dfu-prog check_size style
|
||||
.PHONY: program program-latest dfu-flip dfu-prog dfu-reset check_size style
|
||||
|
||||
# Default target
|
||||
all:
|
||||
@@ -188,6 +188,10 @@ dfu-prog: $(TARGET).hex $(TARGET).eep check_size
|
||||
dfu-programmer $(MCU) flash $(TARGET).hex
|
||||
dfu-programmer $(MCU) reset
|
||||
|
||||
# Reset the device after firmware upgrade
|
||||
dfu-reset:
|
||||
dfu-programmer $(MCU) reset
|
||||
|
||||
check_size:
|
||||
@{ \
|
||||
set -e; \
|
||||
|
||||
Reference in New Issue
Block a user