mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
merged ceres-c
This commit is contained in:
Binary file not shown.
@@ -20,7 +20,7 @@
|
||||
#include "Sl2s2002.h"
|
||||
#include "TITagitstandard.h"
|
||||
#include "Sniff14443A.h"
|
||||
|
||||
#include "EM4233.h"
|
||||
|
||||
/* Function wrappers */
|
||||
INLINE void ApplicationInit(void) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* EM4233.h
|
||||
*
|
||||
* Created on: 04.12.2018
|
||||
* Author: ceres-c & MrMoDDoM
|
||||
*/
|
||||
|
||||
#ifndef EM4233_H_
|
||||
#define EM4233_H_
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#define EM4233_STD_UID_SIZE ISO15693_GENERIC_UID_SIZE
|
||||
#define EM4233_STD_MEM_SIZE 0xD0 // Bytes
|
||||
#define EM4233_BYTES_PER_BLCK 0x04
|
||||
#define EM4233_BLCKS_PER_PAGE 0x04
|
||||
#define EM4233_NUMBER_OF_BLCKS ( EM4233_STD_MEM_SIZE / EM4233_BYTES_PER_BLCK )
|
||||
#define EM4233_NUMBER_OF_PAGES ( EM4233_STD_MEM_SIZE / (EM4233_BYTES_PER_BLCK * EM4233_BLCKS_PER_PAGE) )
|
||||
|
||||
#define EM4233_IC_REFERENCE 0x02 // From EM4233SLIC datasheet and checked against real tags
|
||||
|
||||
#define EM4233_MEM_UID_ADDRESS 0xD0 // From 0x0100 to 0x0107 - UID
|
||||
#define EM4233_MEM_AFI_ADDRESS 0xD8 // AFI byte address
|
||||
#define EM4233_MEM_DSFID_ADDRESS 0xD9 // DSFID byte adress
|
||||
#define EM4233_MEM_INF_ADDRESS 0xDC // Some status bits
|
||||
|
||||
#define EM4233_MEM_LSM_ADDRESS 0xE0 // From 0xE0 to 0x0113 - Lock status masks
|
||||
#define EM4233_MEM_PSW_ADDRESS 0x0114 // From 0x0114 to 0x0117 - 32 bit Password
|
||||
#define EM4233_MEM_KEY_ADDRESS 0x0118 // From 0x0118 to 0x0123 - 96 bit Encryption Key
|
||||
|
||||
#define EM4233_SYSINFO_BYTE 0x0F // == DSFID - AFI - VICC mem size - IC ref are present
|
||||
|
||||
/* Bit masks */
|
||||
#define EM4233_MASK_READ_PROT ( 1 << 2 ) // For lock status byte
|
||||
#define EM4233_MASK_WRITE_PROT ( 1 << 3 )
|
||||
#define EM4233_MASK_AFI_STATUS ( 1 << 0 )
|
||||
#define EM4233_MASK_DSFID_STATUS ( 1 << 1 )
|
||||
|
||||
/* Custom command code */
|
||||
#define EM4233_CMD_SET_EAS 0xA2
|
||||
#define EM4233_CMD_RST_EAS 0xA3
|
||||
#define EM4233_CMD_LCK_EAS 0xA4
|
||||
#define EM4233_CMD_ACT_EAS 0xA5
|
||||
#define EM4233_CMD_PRT_EAS 0xA6
|
||||
#define EM4233_CMD_WRT_EAS_ID 0xA7
|
||||
#define EM4233_CMD_WRT_EAS_CFG 0xA8
|
||||
#define EM4233_CMD_WRT_PSW 0xB4
|
||||
#define EM4233_CMD_WRT_MEM_PAG 0xB6
|
||||
#define EM4233_CMD_GET_BLKS_PRT_STS 0xB8
|
||||
#define EM4233_CMD_DESTROY 0xB9
|
||||
#define EM4233_CMD_ENABLE_PRCY 0xBA
|
||||
#define EM4233_CMD_DISBLE_PRCY 0xBB
|
||||
#define EM4233_CMD_FST_READ_BLKS 0xC3
|
||||
|
||||
/* Proprietary command code */
|
||||
#define EM4233_CMD_LOGIN 0xE4
|
||||
|
||||
|
||||
void EM4233AppInit(void);
|
||||
void EM4233AppReset(void);
|
||||
void EM4233AppTask(void);
|
||||
void EM4233AppTick(void);
|
||||
uint16_t EM4233AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes);
|
||||
void EM4233GetUid(ConfigurationUidType Uid);
|
||||
void EM4233SetUid(ConfigurationUidType Uid);
|
||||
void EM4233FlipUid(ConfigurationUidType Uid);
|
||||
|
||||
#endif /* EM4233_H_ */
|
||||
@@ -65,7 +65,7 @@ bool ISO15693CheckCRC(void* FrameBuf, uint16_t FrameBufSize)
|
||||
*
|
||||
* Authors: ceres-c & MrMoDDoM
|
||||
*/
|
||||
bool ISO15693PrepareFrame(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame* FrameStruct, uint8_t* MyUid)
|
||||
bool ISO15693PrepareFrame(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame* FrameStruct, uint8_t IsSelected, uint8_t* MyUid, uint8_t MyAFI)
|
||||
{
|
||||
if ((FrameBytes < ISO15693_MIN_FRAME_SIZE) || !ISO15693CheckCRC(FrameBuf, FrameBytes - ISO15693_CRC16_SIZE))
|
||||
/* malformed frame */
|
||||
@@ -75,10 +75,13 @@ bool ISO15693PrepareFrame(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame*
|
||||
FrameStruct -> Flags = &FrameBuf[ISO15693_ADDR_FLAGS];
|
||||
FrameStruct -> Command = &FrameBuf[ISO15693_REQ_ADDR_CMD];
|
||||
|
||||
if(!(FrameBuf[ISO15693_ADDR_FLAGS] & ISO15693_REQ_FLAG_INVENTORY)) /* if inventory flag is not set */
|
||||
if(!(FrameBuf[ISO15693_ADDR_FLAGS] & ISO15693_REQ_FLAG_INVENTORY)) { /* if inventory flag is not set */
|
||||
FrameStruct -> Addressed = (FrameBuf[ISO15693_ADDR_FLAGS] & ISO15693_REQ_FLAG_ADDRESS); /* check for addressed flag */
|
||||
else /* otherwise always false */
|
||||
FrameStruct -> Selected = (FrameBuf[ISO15693_ADDR_FLAGS] & ISO15693_REQ_FLAG_SELECT); /* check for selected flag */
|
||||
} else { /* otherwise always false */
|
||||
FrameStruct -> Addressed = false;
|
||||
FrameStruct -> Selected = false;
|
||||
}
|
||||
|
||||
if (FrameStruct -> Addressed)
|
||||
/* UID sits between CMD and PARAM */
|
||||
@@ -86,12 +89,76 @@ bool ISO15693PrepareFrame(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame*
|
||||
else
|
||||
FrameStruct -> Parameters = &FrameBuf[ISO15693_REQ_ADDR_PARAM];
|
||||
|
||||
if ( (*FrameStruct -> Command) >= 0xA0) { /* if command is Custom or Proprietary */
|
||||
/* then between CMD and UID is placed another byte which is IC Mfg Code, but we don't need it */
|
||||
if (FrameBuf[ISO15693_REQ_ADDR_PARAM] != MyUid[1])
|
||||
/* if IC Mfg Code is different from our Mfg code (2nd byte of UID), then don't respond */
|
||||
return false;
|
||||
FrameStruct -> Parameters += 0x01;
|
||||
}
|
||||
else if ( ((*FrameStruct -> Command) == ISO15693_CMD_INVENTORY) && (FrameBuf[ISO15693_ADDR_FLAGS] & ISO15693_REQ_FLAG_AFI)) { /* or if it is Inventory with AFI flag set */
|
||||
/* then between CMD and UID is placed another byte which is requested AFI, but we don't need it */
|
||||
if (FrameBuf[ISO15693_REQ_ADDR_PARAM] != MyAFI)
|
||||
/* if requested AFI is different from our current one, then don't respond */
|
||||
return false;
|
||||
FrameStruct -> Parameters += 0x01;
|
||||
}
|
||||
|
||||
FrameStruct -> ParamLen = FrameBuf + (FrameBytes - ISO15693_CRC16_SIZE) - (FrameStruct -> Parameters);
|
||||
|
||||
if (FrameStruct -> Addressed && !ISO15693CompareUid(&FrameBuf[ISO15693_REQ_ADDR_PARAM], MyUid)) {
|
||||
/* addressed request but we're not the addressee */
|
||||
return false;
|
||||
} else if (FrameStruct -> Selected && !IsSelected) {
|
||||
/* selected request but we're not in selected state */
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ISO15693AntiColl
|
||||
*
|
||||
* This function performs ISO15693 Anticollision
|
||||
*
|
||||
* Returns:
|
||||
* - true: Inventory is addressed to us and a response is needed
|
||||
* - false: Request is not addressed to us (different bitmask)
|
||||
* and no response should be issued.
|
||||
*
|
||||
* Authors: ceres-c
|
||||
*
|
||||
* TODO:
|
||||
* - Implement 16 slots mode (still, it seems to work as it is, even for 16 slots mode ._.)
|
||||
*/
|
||||
bool ISO15693AntiColl(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame* FrameStruct, uint8_t* MyUid) {
|
||||
uint8_t CurrentUID[ ISO15693_GENERIC_UID_SIZE ]; /* Holds the UID flipped */
|
||||
ISO15693CopyUid(CurrentUID, MyUid);
|
||||
|
||||
uint8_t MaskLenght = *FrameStruct -> Parameters; /* First byte of parameters is mask lenght... */
|
||||
uint8_t* MaskValue = FrameStruct -> Parameters + 1; /* ... then the mask itself begins */
|
||||
uint8_t BytesNum = MaskLenght / 8; /* Gets the number of full bytes in mask */
|
||||
uint8_t BitsNum = MaskLenght % 8; /* Gets the number of spare bits */
|
||||
|
||||
uint8_t B; /* B stands for Bytes and will be our reference point (I know, terrible name, I'm sorry) */
|
||||
/* Compare the full bytes in mask with UID */
|
||||
for (B = 0; B < BytesNum; B++ ) {
|
||||
if (CurrentUID[B] != MaskValue[B])
|
||||
return false; /* UID different */
|
||||
}
|
||||
/* Once we got here, B points for sure to the last byte of the mask, the one composed of spare bits */
|
||||
|
||||
/* Compare spare bits in mask with bits of UID */
|
||||
uint8_t BitsMask = ((1 << BitsNum) - 1); /* (1 << Bits) = 00010000 -> (1 << Bits) - 1 = 00001111 */
|
||||
if ((MaskValue[B] & BitsMask) != (CurrentUID[B] & BitsMask)) {
|
||||
/* |-----------------------| Here we extract bits from the mask we received from the reader
|
||||
* |------------------------| Here we extract bits from the UID
|
||||
* The two extracted bit vectors are compared, if different then we're not the addressee.
|
||||
* Only the latest byte of MaskValue and UID is considered.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,21 +68,28 @@
|
||||
#define ISO15693_GENERIC_UID_SIZE 0x08
|
||||
#define ISO15693_GENERIC_MEM_SIZE 8192
|
||||
|
||||
#define ISO15693_CRC16_SIZE 2 /* Bytes */
|
||||
#define ISO15693_CRC16_SIZE 0x2 /* Bytes */
|
||||
#define ISO15693_CRC16_POLYNORMAL 0x8408
|
||||
#define ISO15693_CRC16_PRESET 0xFFFF
|
||||
|
||||
/* The lock status byte has bits assigned as follow */
|
||||
#define ISO15693_MASK_UNLOCKED ( 0 << 0 )
|
||||
#define ISO15693_MASK_USER_LOCK ( 1 << 0 )
|
||||
#define ISO15693_MASK_FACTORY_LOCK ( 1 << 1 )
|
||||
|
||||
typedef struct {
|
||||
uint8_t* Flags;
|
||||
uint8_t* Command;
|
||||
uint8_t* Parameters;
|
||||
uint8_t ParamLen;
|
||||
bool Addressed;
|
||||
bool Selected;
|
||||
} CurrentFrame;
|
||||
|
||||
void ISO15693AppendCRC(uint8_t* FrameBuf, uint16_t FrameBufSize);
|
||||
bool ISO15693CheckCRC(void* FrameBuf, uint16_t FrameBufSize);
|
||||
bool ISO15693PrepareFrame(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame* FrameStruct, uint8_t* MyUid);
|
||||
bool ISO15693PrepareFrame(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame* FrameStruct, uint8_t IsSelected, uint8_t* MyUid, uint8_t MyAFI);
|
||||
bool ISO15693AntiColl(uint8_t* FrameBuf, uint16_t FrameBytes, CurrentFrame* FrameStruct, uint8_t* MyUid);
|
||||
|
||||
INLINE
|
||||
bool ISO15693CompareUid(uint8_t* Uid1, uint8_t* Uid2)
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
#include "Application.h"
|
||||
#include "ISO15693-A.h"
|
||||
|
||||
#define ISO15693_GENERIC_UID_SIZE 8 //ISO15693_UID_SIZE
|
||||
#define ISO15693_GENERIC_MEM_SIZE 8192 //ISO15693_MAX_MEM_SIZE
|
||||
|
||||
void Sl2s2002AppInit(void);
|
||||
void Sl2s2002AppReset(void);
|
||||
void Sl2s2002AppTask(void);
|
||||
|
||||
@@ -16,6 +16,7 @@ static enum {
|
||||
STATE_QUIET
|
||||
} State;
|
||||
|
||||
uint8_t MyAFI; /* Holds current tag's AFI (is used in inventory) */
|
||||
uint16_t UserLockBits_Mask = 0; /* Holds lock state of blocks */
|
||||
uint16_t FactoryLockBits_Mask = 0; /* Holds lock state of blocks */
|
||||
CurrentFrame FrameInfo;
|
||||
@@ -32,6 +33,9 @@ void TITagitstandardAppInit(void)
|
||||
FrameInfo.Parameters = NULL;
|
||||
FrameInfo.ParamLen = 0;
|
||||
FrameInfo.Addressed = false;
|
||||
FrameInfo.Selected = false;
|
||||
|
||||
MemoryReadBlock(&MyAFI, TITAGIT_MEM_AFI_ADDRESS, 1);
|
||||
}
|
||||
|
||||
void TITagitstandardAppReset(void)
|
||||
@@ -43,6 +47,7 @@ void TITagitstandardAppReset(void)
|
||||
FrameInfo.Parameters = NULL;
|
||||
FrameInfo.ParamLen = 0;
|
||||
FrameInfo.Addressed = false;
|
||||
FrameInfo.Selected = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +67,7 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
uint8_t Uid[ActiveConfiguration.UidSize];
|
||||
TITagitstandardGetUid(Uid);
|
||||
|
||||
if (!ISO15693PrepareFrame(FrameBuf, FrameBytes, &FrameInfo, Uid))
|
||||
if (!ISO15693PrepareFrame(FrameBuf, FrameBytes, &FrameInfo, State == STATE_SELECTED, Uid, MyAFI))
|
||||
return ISO15693_APP_NO_RESPONSE;
|
||||
|
||||
switch(State) {
|
||||
@@ -114,10 +119,12 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
if (FrameInfo.ParamLen != 5)
|
||||
break; /* malformed: not enough or too much data */
|
||||
|
||||
if (PageAddress > TITAGIT_NUMBER_OF_SECTORS)
|
||||
if (PageAddress > TITAGIT_NUMBER_OF_SECTORS) {
|
||||
FrameBuf[ISO15693_ADDR_FLAGS] = ISO15693_RES_FLAG_ERROR;
|
||||
FrameBuf[ISO15693_RES_ADDR_PARAM] = ISO15693_RES_ERR_OPT_NOT_SUPP;
|
||||
ResponseByteCount = 2;
|
||||
break; /* malformed: trying to write in a non-existing block */
|
||||
}
|
||||
|
||||
Dataptr = PageAddress + 0x01;
|
||||
|
||||
@@ -141,11 +148,12 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
if (FrameInfo.ParamLen != 1)
|
||||
break; /* malformed: not enough or too much data */
|
||||
|
||||
if (PageAddress > TITAGIT_NUMBER_OF_SECTORS)
|
||||
if (PageAddress > TITAGIT_NUMBER_OF_SECTORS) {
|
||||
FrameBuf[ISO15693_ADDR_FLAGS] = ISO15693_RES_FLAG_ERROR;
|
||||
FrameBuf[ISO15693_RES_ADDR_PARAM] = ISO15693_RES_ERR_OPT_NOT_SUPP;
|
||||
ResponseByteCount = 2;
|
||||
break; /* malformed: trying to lock a non-existing block */
|
||||
}
|
||||
|
||||
if ((FactoryLockBits_Mask & (1 << PageAddress)) || (UserLockBits_Mask & (1 << PageAddress))) {
|
||||
FrameBuf[ISO15693_ADDR_FLAGS] = ISO15693_RES_FLAG_ERROR;
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
#include "Application.h"
|
||||
|
||||
#define TITAGIT_STD_UID_SIZE ISO15693_GENERIC_UID_SIZE //ISO15693_UID_SIZE
|
||||
#define TITAGIT_STD_MEM_SIZE 44 //TAG-IT STANDARD MAX MEM SIZE
|
||||
#define TITAGIT_STD_MEM_SIZE 44 //TAG-IT STANDARD MAX MEM SIZE
|
||||
#define TITAGIT_BYTES_PER_PAGE 4
|
||||
#define TITAGIT_NUMBER_OF_SECTORS ( TITAGIT_STD_MEM_SIZE / TITAGIT_BYTES_PER_PAGE )
|
||||
#define TITAGIT_MEM_UID_ADDRESS 0x20
|
||||
#define TITAGIT_MEM_AFI_ADDRESS 0x28 // AFI byte address
|
||||
|
||||
void TITagitstandardAppInit(void);
|
||||
void TITagitstandardAppReset(void);
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
#include "Application.h"
|
||||
#include "ISO15693-A.h"
|
||||
|
||||
#define ISO15693_GENERIC_UID_SIZE 8 //ISO15693_UID_SIZE
|
||||
#define ISO15693_GENERIC_MEM_SIZE 8192 //ISO15693_MAX_MEM_SIZE
|
||||
|
||||
void VicinityAppInit(void);
|
||||
void VicinityAppReset(void);
|
||||
void VicinityAppTask(void);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* Created on: 25.01.2017
|
||||
* Author: Phillip Nash
|
||||
* Modified by: ceres-c
|
||||
*/
|
||||
|
||||
#include "ISO15693.h"
|
||||
@@ -81,44 +82,75 @@ static volatile uint16_t ReadCommandFromReader = 0;
|
||||
|
||||
#ifdef CONFIG_VICINITY_SUPPORT
|
||||
|
||||
// Started when a single pulse has been detected
|
||||
// ISR(CODEC_DEMOD_IN_INT0_VECT)
|
||||
/* 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:
|
||||
* CODEC_DEMOD_IN_PORT.INT0MASK = CODEC_DEMOD_IN_MASK0;
|
||||
* and unregistered writing the INT0MASK to 0
|
||||
*/
|
||||
// ISR(CODEC_DEMOD_IN_INT0_VECT)
|
||||
void isr_ISO15693_CODEC_DEMOD_IN_INT0_VECT(void)
|
||||
{
|
||||
// Start sample timer
|
||||
/* Start sample timer CODEC_TIMER_SAMPLING (TCD0).
|
||||
* Set Counter Channel C (CCC) with relevant bitmask (TC0_CCCIF_bm),
|
||||
* the period for clock sampling is specified in StartISO15693Demod.
|
||||
*/
|
||||
CODEC_TIMER_SAMPLING.INTFLAGS = TC0_CCCIF_bm;
|
||||
/* Sets register INTCTRLB to TC_CCCINTLVL_HI_gc = (0x03<<4) to enable compare/capture for high level interrupts on Channel C (CCC) */
|
||||
CODEC_TIMER_SAMPLING.INTCTRLB = TC_CCCINTLVL_HI_gc;
|
||||
/* Disable this interrupt */
|
||||
|
||||
/* Disable this interrupt as we've already sensed the relevant pulse and will use our internal clock from now on */
|
||||
CODEC_DEMOD_IN_PORT.INT0MASK = 0;
|
||||
}
|
||||
|
||||
/* This function is called from isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT
|
||||
* when we have 8 bits in SampleRegister and they represent an end of frame.
|
||||
*/
|
||||
INLINE void ISO15693_EOC(void)
|
||||
{
|
||||
BitRate1 = 256 * 4;
|
||||
/* Set bitrate required by the reader on SOF for our following response */
|
||||
BitRate1 = 256 * 4; // 256 * 4 - 1
|
||||
if (CodecBuffer[0] & ISO15693_REQ_DATARATE_HIGH)
|
||||
BitRate1 = 256;
|
||||
|
||||
if (CodecBuffer[0] & ISO15693_REQ_SUBCARRIER_DUAL)
|
||||
{
|
||||
BitRate2 = 252 * 4;
|
||||
BitRate2 = 252 * 4; // 252 * 4 - 3
|
||||
if (CodecBuffer[0] & ISO15693_REQ_DATARATE_HIGH)
|
||||
BitRate2 = 252;
|
||||
} else {
|
||||
BitRate2 = BitRate1;
|
||||
}
|
||||
|
||||
CODEC_TIMER_LOADMOD.CTRLD = 0;
|
||||
CODEC_TIMER_LOADMOD.INTFLAGS = TC0_CCBIF_bm;
|
||||
/* Disable event action for CODEC_TIMER_LOADMOD (TCE0) as we're done receiving data */
|
||||
CODEC_TIMER_LOADMOD.CTRLD = TC_EVACT_OFF_gc;
|
||||
/* Set Counter Channel B (CCB) with relevant bitmask (TC0_CCBIF_bm), the period for clock sampling is specified below */
|
||||
CODEC_TIMER_LOADMOD.INTFLAGS = TC0_CCBIF_bm; // TODO This might not be needed since commenting it does not break anything
|
||||
/* Sets register INTCTRLB to TC_CCBINTLVL_HI_gc = (0x03<<2) to enable compare/capture for high level interrupts on channel B */
|
||||
CODEC_TIMER_LOADMOD.INTCTRLB = TC_CCBINTLVL_HI_gc;
|
||||
/* Set the period for CODEC_TIMER_LOADMOD (TCE0) to Bitrate - 1 because PERBUF is 0-based
|
||||
*
|
||||
* TODO Why are we using PERBUF instead of PER?
|
||||
* With PERBUF the period register will occur on the next overflow.
|
||||
*/
|
||||
CODEC_TIMER_LOADMOD.PERBUF = BitRate1 - 1;
|
||||
|
||||
Flags.DemodFinished = 1;
|
||||
/* Sets timer off for CODEC_TIMER_SAMPLING (TCD0) disabling clock source */
|
||||
CODEC_TIMER_SAMPLING.CTRLA = TC_CLKSEL_OFF_gc;
|
||||
/* Sets register INTCTRLB to 0 to disable all compare/capture interrupts */
|
||||
CODEC_TIMER_SAMPLING.INTCTRLB = 0;
|
||||
}
|
||||
|
||||
/* This function is registered to CODEC_TIMER_SAMPLING (TCD0)'s Counter Channel C (CCC).
|
||||
* When the timer is enabled, this is called on counter's overflow
|
||||
*
|
||||
* It demodulates bits received from the reader and saves them in CodecBuffer.
|
||||
*
|
||||
* It disables its own interrupt when receives an EOF (calling ISO15693_EOC) or when it receives garbage
|
||||
*/
|
||||
// ISR(CODEC_TIMER_SAMPLING_CCC_VECT) // Reading data sent from the reader
|
||||
void isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void)
|
||||
void isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void)
|
||||
{
|
||||
/* Shift demod data */
|
||||
SampleRegister = (SampleRegister << 1) | (!(CODEC_DEMOD_IN_PORT.IN & CODEC_DEMOD_IN_MASK) ? 0x01 : 0x00);
|
||||
@@ -137,13 +169,15 @@ void isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void)
|
||||
} else if (SampleRegister == SOC_1_OF_256_CODE) {
|
||||
DemodState = DEMOD_1_OUT_OF_256_STATE;
|
||||
SampleDataCount = 0;
|
||||
} else { // No SOC. Restart and try again
|
||||
} else { // No SOC. Restart and try again, we probably received garbage.
|
||||
Flags.DemodFinished = 1;
|
||||
/* Sets timer off for CODEC_TIMER_SAMPLING (TCD0) disabling clock source */
|
||||
CODEC_TIMER_SAMPLING.CTRLA = TC_CLKSEL_OFF_gc;
|
||||
/* Sets register INTCTRLB to 0 to disable all compare/capture interrupts */
|
||||
CODEC_TIMER_SAMPLING.INTCTRLB = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case DEMOD_1_OUT_OF_4_STATE:
|
||||
if (SampleRegister == EOC_CODE)
|
||||
{
|
||||
@@ -184,7 +218,7 @@ void isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case DEMOD_1_OUT_OF_256_STATE:
|
||||
if (SampleRegister == EOC_CODE)
|
||||
{
|
||||
@@ -230,21 +264,28 @@ void isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void)
|
||||
}
|
||||
|
||||
|
||||
/* This function is registered to CODEC_TIMER_LOADMOD (TCE0)'s Counter Channel B (CCB).
|
||||
* When the timer is enabled, this is called on counter's overflow
|
||||
*
|
||||
* It modulates the carrier with consuming bytes in CodecBuffer until ByteCount is 0.
|
||||
*
|
||||
* It disables its own interrupt when all data has been sent
|
||||
*/
|
||||
//ISR(CODEC_TIMER_LOADMOD_CCB_VECT)
|
||||
void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
{
|
||||
static void* JumpTable[] = {
|
||||
[LOADMOD_START_SINGLE] = &&LOADMOD_START_SINGLE_LABEL,
|
||||
[LOADMOD_SOF_SINGLE] = &&LOADMOD_SOF_SINGLE_LABEL,
|
||||
[LOADMOD_BIT0_SINGLE] = &&LOADMOD_BIT0_SINGLE_LABEL,
|
||||
[LOADMOD_BIT1_SINGLE] = &&LOADMOD_BIT1_SINGLE_LABEL,
|
||||
[LOADMOD_EOF_SINGLE] = &&LOADMOD_EOF_SINGLE_LABEL,
|
||||
[LOADMOD_START_DUAL] = &&LOADMOD_START_DUAL_LABEL,
|
||||
[LOADMOD_SOF_DUAL] = &&LOADMOD_SOF_DUAL_LABEL,
|
||||
[LOADMOD_BIT0_DUAL] = &&LOADMOD_BIT0_DUAL_LABEL,
|
||||
[LOADMOD_BIT1_DUAL] = &&LOADMOD_BIT1_DUAL_LABEL,
|
||||
[LOADMOD_EOF_DUAL] = &&LOADMOD_EOF_DUAL_LABEL,
|
||||
[LOADMOD_FINISHED] = &&LOADMOD_FINISHED_LABEL
|
||||
[LOADMOD_START_SINGLE] = &&LOADMOD_START_SINGLE_LABEL,
|
||||
[LOADMOD_SOF_SINGLE] = &&LOADMOD_SOF_SINGLE_LABEL,
|
||||
[LOADMOD_BIT0_SINGLE] = &&LOADMOD_BIT0_SINGLE_LABEL,
|
||||
[LOADMOD_BIT1_SINGLE] = &&LOADMOD_BIT1_SINGLE_LABEL,
|
||||
[LOADMOD_EOF_SINGLE] = &&LOADMOD_EOF_SINGLE_LABEL,
|
||||
[LOADMOD_START_DUAL] = &&LOADMOD_START_DUAL_LABEL,
|
||||
[LOADMOD_SOF_DUAL] = &&LOADMOD_SOF_DUAL_LABEL,
|
||||
[LOADMOD_BIT0_DUAL] = &&LOADMOD_BIT0_DUAL_LABEL,
|
||||
[LOADMOD_BIT1_DUAL] = &&LOADMOD_BIT1_DUAL_LABEL,
|
||||
[LOADMOD_EOF_DUAL] = &&LOADMOD_EOF_DUAL_LABEL,
|
||||
[LOADMOD_FINISHED] = &&LOADMOD_FINISHED_LABEL
|
||||
};
|
||||
|
||||
if ( (StateRegister >= LOADMOD_START_SINGLE) && (StateRegister <= LOADMOD_FINISHED) ) {
|
||||
@@ -252,12 +293,12 @@ void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LOADMOD_START_SINGLE_LABEL:
|
||||
CodecStartSubcarrier();
|
||||
ShiftRegister = SOF_PATTERN;
|
||||
/* Application produced data. With this interrupt we are aligned to the bit-grid. */
|
||||
ShiftRegister = SOF_PATTERN;
|
||||
BitSent = 0;
|
||||
// fallthrough
|
||||
/* Fallthrough */
|
||||
LOADMOD_SOF_SINGLE_LABEL:
|
||||
if (ShiftRegister & 0x80) {
|
||||
CodecSetLoadmodState(true);
|
||||
@@ -265,6 +306,8 @@ void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
CodecSetLoadmodState(false);
|
||||
}
|
||||
|
||||
CodecStartSubcarrier();
|
||||
|
||||
ShiftRegister <<= 1;
|
||||
BitSent++;
|
||||
|
||||
@@ -276,7 +319,7 @@ void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
StateRegister = LOADMOD_SOF_SINGLE;
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
LOADMOD_BIT0_SINGLE_LABEL: //Manchester encoding
|
||||
if (ShiftRegister & 0x01) {
|
||||
/* Deactivate carrier */
|
||||
@@ -288,7 +331,7 @@ void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
|
||||
StateRegister = LOADMOD_BIT1_SINGLE;
|
||||
return;
|
||||
|
||||
|
||||
LOADMOD_BIT1_SINGLE_LABEL: //Manchester encoding
|
||||
if (ShiftRegister & 0x01) {
|
||||
CodecSetLoadmodState(true);
|
||||
@@ -312,7 +355,7 @@ void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
LOADMOD_EOF_SINGLE_LABEL: //End of Manchester encoding
|
||||
/* Output EOF */
|
||||
if (ShiftRegister & 0x80) {
|
||||
@@ -333,12 +376,12 @@ void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
return;
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
|
||||
LOADMOD_START_DUAL_LABEL:
|
||||
CodecStartSubcarrier();
|
||||
ShiftRegister = SOF_PATTERN;
|
||||
BitSent = 0;
|
||||
CodecSetLoadmodState(true);
|
||||
CodecStartSubcarrier();
|
||||
// fallthrough
|
||||
LOADMOD_SOF_DUAL_LABEL:
|
||||
if (ShiftRegister & 0x80) {
|
||||
@@ -423,21 +466,25 @@ void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void)
|
||||
return;
|
||||
|
||||
LOADMOD_FINISHED_LABEL:
|
||||
/* Sets timer off for CODEC_TIMER_LOADMOD (TCE0) disabling clock source as we're done modulating */
|
||||
CODEC_TIMER_LOADMOD.CTRLA = TC_CLKSEL_OFF_gc;
|
||||
/* Sets register INTCTRLB to 0 to disable all compare/capture interrupts */
|
||||
CODEC_TIMER_LOADMOD.INTCTRLB = 0;
|
||||
CodecSetSubcarrier(CODEC_SUBCARRIERMOD_OFF, SUBCARRIER_1);
|
||||
CodecSetSubcarrier(CODEC_SUBCARRIERMOD_OFF, 0);
|
||||
Flags.LoadmodFinished = 1;
|
||||
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 */
|
||||
CodecBufferPtr = CodecBuffer;
|
||||
Flags.DemodFinished = 0;
|
||||
Flags.LoadmodFinished = 0;
|
||||
DemodState = DEMOD_SOC_STATE;
|
||||
StateRegister = LOADMOD_WAIT;
|
||||
DataRegister = 0;
|
||||
SampleRegister = 0;
|
||||
BitSampleCount = 0;
|
||||
@@ -445,35 +492,71 @@ void StartISO15693Demod(void) {
|
||||
ModulationPauseCount = 0;
|
||||
ByteCount = 0;
|
||||
ShiftRegister = 0;
|
||||
|
||||
|
||||
/* Activate Power for demodulator */
|
||||
CodecSetDemodPower(true);
|
||||
|
||||
/* Configure sampling-timer free running and sync to first modulation-pause. */
|
||||
/* Resets the counter to 0 */
|
||||
CODEC_TIMER_SAMPLING.CNT = 0;
|
||||
CODEC_TIMER_SAMPLING.PER = ISO15693_SAMPLE_PERIOD - 1;
|
||||
CODEC_TIMER_SAMPLING.CCC = ISO15693_SAMPLE_PERIOD / 2 - 14 - 1; /* Half bit. ISR compensate*/
|
||||
/* Set the period for CODEC_TIMER_SAMPLING (TCD0) to ISO15693_SAMPLE_PERIOD - 1 because PER is 0-based */
|
||||
CODEC_TIMER_SAMPLING.PER = ISO15693_SAMPLE_PERIOD - 1;
|
||||
/* Set Counter Channel C (CCC) register with half bit period - 1. (- 14 to compensate ISR timing overhead) */
|
||||
CODEC_TIMER_SAMPLING.CCC = ISO15693_SAMPLE_PERIOD / 2 - 14 - 1;
|
||||
/* Set timer for CODEC_TIMER_SAMPLING (TCD0) to ISO15693_SAMPLE_CLK = TC_CLKSEL_DIV2_gc = System Clock / 2
|
||||
*
|
||||
* TODO Why system clock / 2 and not iso period?
|
||||
*/
|
||||
CODEC_TIMER_SAMPLING.CTRLA = ISO15693_SAMPLE_CLK;
|
||||
/* Set event action for CODEC_TIMER_SAMPLING (TCD0) to restart and trigger CODEC_TIMER_MODSTART_EVSEL = TC_EVSEL_CH0_gc = Event Channel 0 */
|
||||
CODEC_TIMER_SAMPLING.CTRLD = TC_EVACT_RESTART_gc | CODEC_TIMER_MODSTART_EVSEL;
|
||||
/* Set Counter Channel C (CCC) with relevant bitmask (TC0_CCCIF_bm), the period for clock sampling is specified above */
|
||||
CODEC_TIMER_SAMPLING.INTFLAGS = TC0_CCCIF_bm;
|
||||
/* Sets register INTCTRLB to TC_CCCINTLVL_OFF_gc = (0x00<<4) to disable compare/capture C interrupts
|
||||
*
|
||||
* TODO Why turn it off?
|
||||
*/
|
||||
CODEC_TIMER_SAMPLING.INTCTRLB = TC_CCCINTLVL_OFF_gc;
|
||||
|
||||
/* Set event action for CODEC_TIMER_LOADMOD (TCE0) to restart and trigger CODEC_TIMER_MODSTART_EVSEL = TC_EVSEL_CH0_gc = Event Channel 0 */
|
||||
CODEC_TIMER_LOADMOD.CTRLD = TC_EVACT_RESTART_gc | CODEC_TIMER_MODSTART_EVSEL;
|
||||
CODEC_TIMER_LOADMOD.PER = 4192 + 128 + 128 - 1;
|
||||
/* Set the period for CODEC_TIMER_LOADMOD (TCE0) to... some magic numbers?
|
||||
* Using PER instead of PERBUF breaks it when receiving ISO15693_APP_NO_RESPONSE from Application.
|
||||
*
|
||||
* TODO What are these numbers?
|
||||
*/
|
||||
CODEC_TIMER_LOADMOD.PERBUF = 4192 + 128 + 128 - 1;
|
||||
/* Sets register INTCTRLA to 0 to disable timer error or overflow interrupts */
|
||||
CODEC_TIMER_LOADMOD.INTCTRLA = 0;
|
||||
/* Sets register INTCTRLB to 0 to disable all compare/capture interrupts */
|
||||
CODEC_TIMER_LOADMOD.INTCTRLB = 0;
|
||||
/* Set timer for CODEC_TIMER_SAMPLING (TCD0) to TC_CLKSEL_EVCH6_gc = Event Channel 6 */
|
||||
CODEC_TIMER_LOADMOD.CTRLA = TC_CLKSEL_EVCH6_gc;
|
||||
|
||||
/* Start looking out for modulation pause via interrupt. */
|
||||
CODEC_DEMOD_IN_PORT.INTFLAGS = 0x03;
|
||||
/* Sets register INTFLAGS to PORT_INT0LVL_HI_gc = (0x03<<0) to enable compare/capture for high level interrupts on CODEC_DEMOD_IN_PORT (PORTB) */
|
||||
CODEC_DEMOD_IN_PORT.INTFLAGS = PORT_INT0LVL_HI_gc;
|
||||
/* Sets INT0MASK to CODEC_DEMOD_IN_MASK0 = PIN1_bm to use it as source for port interrupt 0 */
|
||||
CODEC_DEMOD_IN_PORT.INT0MASK = CODEC_DEMOD_IN_MASK0;
|
||||
}
|
||||
|
||||
void ISO15693CodecInit(void)
|
||||
{
|
||||
CodecInitCommon();
|
||||
|
||||
/* Register isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT function
|
||||
* to CODEC_TIMER_SAMPLING (TCD0)'s Counter Channel C (CCC)
|
||||
*/
|
||||
isr_func_TCD0_CCC_vect = &isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT;
|
||||
/* Register isr_ISO15693_CODEC_DEMOD_IN_INT0_VECT function
|
||||
* to CODEC_DEMOD_IN_PORT (PORTB) interrupt 0
|
||||
*/
|
||||
isr_func_CODEC_DEMOD_IN_INT0_VECT = &isr_ISO15693_CODEC_DEMOD_IN_INT0_VECT;
|
||||
/* Register isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT function
|
||||
* to CODEC_TIMER_LOADMOD (TCE0)'s Counter Channel B (CCB)
|
||||
*/
|
||||
isr_func_CODEC_TIMER_LOADMOD_CCB_VECT = &isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT;
|
||||
|
||||
StartISO15693Demod();
|
||||
}
|
||||
|
||||
@@ -482,10 +565,12 @@ void ISO15693CodecDeInit(void)
|
||||
/* Gracefully shutdown codec */
|
||||
CODEC_DEMOD_IN_PORT.INT0MASK = 0;
|
||||
|
||||
/* Reset global variables to default values */
|
||||
CodecBufferPtr = CodecBuffer;
|
||||
Flags.DemodFinished = 0;
|
||||
Flags.LoadmodFinished = 0;
|
||||
DemodState = DEMOD_SOC_STATE;
|
||||
StateRegister = LOADMOD_WAIT;
|
||||
DataRegister = 0;
|
||||
SampleRegister = 0;
|
||||
BitSampleCount = 0;
|
||||
@@ -494,15 +579,22 @@ void ISO15693CodecDeInit(void)
|
||||
ByteCount = 0;
|
||||
ShiftRegister = 0;
|
||||
|
||||
//Disable sample timer
|
||||
/* Disable sample timer */
|
||||
/* Sets timer off for CODEC_TIMER_SAMPLING (TCD0) disabling clock source */
|
||||
CODEC_TIMER_SAMPLING.CTRLA = TC_CLKSEL_OFF_gc;
|
||||
/* Disable event action for CODEC_TIMER_SAMPLING (TCD0) */
|
||||
CODEC_TIMER_SAMPLING.CTRLD = TC_EVACT_OFF_gc;
|
||||
/* Sets register INTCTRLB to TC_CCCINTLVL_OFF_gc = (0x00<<4) to disable compare/capture C interrupts */
|
||||
CODEC_TIMER_SAMPLING.INTCTRLB = TC_CCCINTLVL_OFF_gc;
|
||||
/* Restore Counter Channel C (CCC) interrupt mask (TC0_CCCIF_bm) */
|
||||
CODEC_TIMER_SAMPLING.INTFLAGS = TC0_CCCIF_bm;
|
||||
|
||||
//Disable load modulation
|
||||
/* Disable load modulation */
|
||||
/* Disable event action for CODEC_TIMER_LOADMOD (TCE0) */
|
||||
CODEC_TIMER_LOADMOD.CTRLD = TC_EVACT_OFF_gc;
|
||||
/* Sets register INTCTRLB to TC_CCBINTLVL_OFF_gc = (0x00<<2) to disable compare/capture B interrupts */
|
||||
CODEC_TIMER_LOADMOD.INTCTRLB = TC_CCBINTLVL_OFF_gc;
|
||||
/* Restore Counter Channel B (CCB) interrupt mask (TC0_CCBIF_bm) */
|
||||
CODEC_TIMER_LOADMOD.INTFLAGS = TC0_CCBIF_bm;
|
||||
|
||||
CodecSetSubcarrier(CODEC_SUBCARRIERMOD_OFF, 0);
|
||||
@@ -514,54 +606,54 @@ void ISO15693CodecTask(void)
|
||||
{
|
||||
if (Flags.DemodFinished) {
|
||||
Flags.DemodFinished = 0;
|
||||
|
||||
|
||||
uint16_t DemodByteCount = ByteCount;
|
||||
uint16_t AppReceivedByteCount = 0;
|
||||
bool bDualSubcarrier = false;
|
||||
|
||||
|
||||
if (DemodByteCount > 0)
|
||||
{
|
||||
LogEntry(LOG_INFO_CODEC_RX_DATA, CodecBuffer, DemodByteCount);
|
||||
LEDHook(LED_CODEC_RX, LED_PULSE);
|
||||
|
||||
if (CodecBuffer[0] & ISO15693_REQ_SUBCARRIER_DUAL)
|
||||
{
|
||||
bDualSubcarrier = true;
|
||||
}
|
||||
LogEntry(LOG_INFO_CODEC_RX_DATA, CodecBuffer, DemodByteCount);
|
||||
AppReceivedByteCount = ApplicationProcess(CodecBuffer, DemodByteCount);
|
||||
|
||||
} else {
|
||||
ApplicationReset();
|
||||
}
|
||||
|
||||
//This is only reached when we've received a valid frame
|
||||
if (AppReceivedByteCount > 0) {
|
||||
|
||||
/* This is only reached when we've received a valid frame */
|
||||
if (AppReceivedByteCount != ISO15693_APP_NO_RESPONSE) {
|
||||
LogEntry(LOG_INFO_CODEC_TX_DATA, CodecBuffer, AppReceivedByteCount);
|
||||
CodecBufferPtr = CodecBuffer;
|
||||
LEDHook(LED_CODEC_TX, LED_PULSE);
|
||||
|
||||
ByteCount = AppReceivedByteCount;
|
||||
|
||||
CodecStartSubcarrier();
|
||||
CodecBufferPtr = CodecBuffer;
|
||||
|
||||
/* Start loadmodulating */
|
||||
if (bDualSubcarrier) {
|
||||
StateRegister = LOADMOD_START_DUAL;
|
||||
CodecSetSubcarrier(CODEC_SUBCARRIERMOD_OOK, SUBCARRIER_2);
|
||||
StateRegister = LOADMOD_START_DUAL;
|
||||
} else {
|
||||
StateRegister = LOADMOD_START_SINGLE;
|
||||
CodecSetSubcarrier(CODEC_SUBCARRIERMOD_OOK, SUBCARRIER_1);
|
||||
StateRegister = LOADMOD_START_SINGLE;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
/* No data to be processed. Disable T1 waiting and
|
||||
* start listening again */
|
||||
/* No data to process. Disable CODEC_TIMER_LOADMOD (TCE0) counter and start listening again */
|
||||
/* Sets timer off for CODEC_TIMER_LOADMOD (TCE0) disabling clock source as we're done modulating */
|
||||
CODEC_TIMER_LOADMOD.CTRLA = TC_CLKSEL_OFF_gc;
|
||||
CODEC_TIMER_LOADMOD.INTCTRLB = TC_CCBINTLVL_OFF_gc;
|
||||
/* Sets register INTCTRLB to 0 to disable all compare/capture interrupts */
|
||||
CODEC_TIMER_LOADMOD.INTCTRLB = 0;
|
||||
|
||||
StartISO15693Demod();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Flags.LoadmodFinished) {
|
||||
Flags.LoadmodFinished = 0;
|
||||
/* Load modulation has been finished. Stop it and start to listen
|
||||
* for incoming data again. */
|
||||
/* Load modulation has been finished. Stop it and start to listen for incoming data again. */
|
||||
StartISO15693Demod();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
|
||||
#define ISO15693_APP_NO_RESPONSE 0x0000
|
||||
|
||||
/* VERY OUTDATED */
|
||||
#define TIMER_SAMPLING TCC0
|
||||
#define TIMER_T1_BITRATE TCD1
|
||||
#define TIMER_SUBCARRIER TCD0
|
||||
|
||||
#define SUBCARRIER_1 32
|
||||
#define SUBCARRIER_2 28
|
||||
#define SUBCARRIER_OFF 0
|
||||
|
||||
@@ -38,17 +38,19 @@ static const MapEntryType PROGMEM ConfigurationMap[] = {
|
||||
{ .Id = CONFIG_ISO14443A_READER, .Text = "ISO14443A_READER" },
|
||||
#endif
|
||||
#ifdef CONFIG_VICINITY_SUPPORT
|
||||
{ .Id = CONFIG_VICINITY, .Text = "VICINITY" },
|
||||
{ .Id = CONFIG_VICINITY, .Text = "VICINITY" },
|
||||
#endif
|
||||
#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
|
||||
{ .Id = CONFIG_ISO15693_SNIFF, .Text = "ISO15693_SNIFF" },
|
||||
{ .Id = CONFIG_ISO15693_SNIFF, .Text = "ISO15693_SNIFF" },
|
||||
#endif
|
||||
#ifdef CONFIG_SL2S2002_SUPPORT
|
||||
{ .Id = CONFIG_SL2S2002, .Text = "SL2S2002" },
|
||||
{ .Id = CONFIG_SL2S2002, .Text = "SL2S2002" },
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TITAGITSTANDARD_SUPPORT
|
||||
{ .Id = CONFIG_TITAGITSTANDARD, .Text = "TITAGITSTANDARD" },
|
||||
{ .Id = CONFIG_TITAGITSTANDARD, .Text = "TITAGITSTANDARD" },
|
||||
#endif
|
||||
#ifdef CONFIG_EM4233_SUPPORT
|
||||
{ .Id = CONFIG_EM4233, .Text = "EM4233" },
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -83,7 +85,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = 0,
|
||||
.MemorySize = 0,
|
||||
.ReadOnly = true,
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
},
|
||||
#ifdef CONFIG_MF_ULTRALIGHT_SUPPORT
|
||||
[CONFIG_MF_ULTRALIGHT] = {
|
||||
@@ -100,7 +102,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = MIFARE_ULTRALIGHT_UID_SIZE,
|
||||
.MemorySize = MIFARE_ULTRALIGHT_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
},
|
||||
[CONFIG_MF_ULTRALIGHT_EV1_80B] = {
|
||||
.CodecInitFunc = ISO14443ACodecInit,
|
||||
@@ -116,7 +118,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = MIFARE_ULTRALIGHT_UID_SIZE,
|
||||
.MemorySize = MIFARE_ULTRALIGHT_EV11_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
},
|
||||
[CONFIG_MF_ULTRALIGHT_EV1_164B] = {
|
||||
.CodecInitFunc = ISO14443ACodecInit,
|
||||
@@ -132,7 +134,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = MIFARE_ULTRALIGHT_UID_SIZE,
|
||||
.MemorySize = MIFARE_ULTRALIGHT_EV12_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_MF_CLASSIC_1K_SUPPORT
|
||||
@@ -150,7 +152,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = MIFARE_CLASSIC_UID_SIZE,
|
||||
.MemorySize = MIFARE_CLASSIC_1K_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_MF_CLASSIC_1K_7B_SUPPORT
|
||||
@@ -168,7 +170,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = ISO14443A_UID_SIZE_DOUBLE,
|
||||
.MemorySize = MIFARE_CLASSIC_1K_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_MF_CLASSIC_4K_SUPPORT
|
||||
@@ -186,7 +188,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = MIFARE_CLASSIC_UID_SIZE,
|
||||
.MemorySize = MIFARE_CLASSIC_4K_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_MF_CLASSIC_4K_7B_SUPPORT
|
||||
@@ -204,7 +206,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = ISO14443A_UID_SIZE_DOUBLE,
|
||||
.MemorySize = MIFARE_CLASSIC_4K_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
.TagFamily = TAG_FAMILY_ISO14443A
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_ISO14443A_SNIFF_SUPPORT
|
||||
@@ -222,7 +224,7 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = 0,
|
||||
.MemorySize = 0,
|
||||
.ReadOnly = true,
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_ISO14443A_READER_SUPPORT
|
||||
@@ -240,80 +242,97 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.UidSize = 0,
|
||||
.MemorySize = 0,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_VICINITY_SUPPORT
|
||||
[CONFIG_VICINITY] = {
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = VicinityAppInit,
|
||||
.ApplicationResetFunc = VicinityAppReset,
|
||||
.ApplicationTaskFunc = VicinityAppTask,
|
||||
.ApplicationTickFunc = VicinityAppTick,
|
||||
.ApplicationProcessFunc = VicinityAppProcess,
|
||||
.ApplicationGetUidFunc = VicinityGetUid,
|
||||
.ApplicationSetUidFunc = VicinitySetUid,
|
||||
.UidSize = ISO15693_GENERIC_UID_SIZE,
|
||||
.MemorySize = ISO15693_GENERIC_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO15693
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = VicinityAppInit,
|
||||
.ApplicationResetFunc = VicinityAppReset,
|
||||
.ApplicationTaskFunc = VicinityAppTask,
|
||||
.ApplicationTickFunc = VicinityAppTick,
|
||||
.ApplicationProcessFunc = VicinityAppProcess,
|
||||
.ApplicationGetUidFunc = VicinityGetUid,
|
||||
.ApplicationSetUidFunc = VicinitySetUid,
|
||||
.UidSize = ISO15693_GENERIC_UID_SIZE,
|
||||
.MemorySize = ISO15693_GENERIC_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO15693
|
||||
},
|
||||
#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,
|
||||
.ApplicationGetUidFunc = ApplicationGetUidDummy,
|
||||
.ApplicationSetUidFunc = ApplicationSetUidDummy,
|
||||
.UidSize = 0,
|
||||
.MemorySize = 0,
|
||||
.ReadOnly = true,
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = ApplicationInitDummy,
|
||||
.ApplicationResetFunc = ApplicationResetDummy,
|
||||
.ApplicationTaskFunc = ApplicationTaskDummy,
|
||||
.ApplicationTickFunc = ApplicationTickDummy,
|
||||
.ApplicationProcessFunc = ApplicationProcessDummy,
|
||||
.ApplicationGetUidFunc = ApplicationGetUidDummy,
|
||||
.ApplicationSetUidFunc = ApplicationSetUidDummy,
|
||||
.UidSize = 0,
|
||||
.MemorySize = 0,
|
||||
.ReadOnly = true,
|
||||
.TagFamily = TAG_FAMILY_NONE
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_SL2S2002_SUPPORT
|
||||
[CONFIG_SL2S2002] = {
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = Sl2s2002AppInit,
|
||||
.ApplicationResetFunc = Sl2s2002AppReset,
|
||||
.ApplicationTaskFunc = Sl2s2002AppTask,
|
||||
.ApplicationTickFunc = Sl2s2002AppTick,
|
||||
.ApplicationProcessFunc = Sl2s2002AppProcess,
|
||||
.ApplicationGetUidFunc = Sl2s2002GetUid,
|
||||
.ApplicationSetUidFunc = Sl2s2002SetUid,
|
||||
.UidSize = ISO15693_GENERIC_UID_SIZE,
|
||||
.MemorySize = ISO15693_GENERIC_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO15693
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = Sl2s2002AppInit,
|
||||
.ApplicationResetFunc = Sl2s2002AppReset,
|
||||
.ApplicationTaskFunc = Sl2s2002AppTask,
|
||||
.ApplicationTickFunc = Sl2s2002AppTick,
|
||||
.ApplicationProcessFunc = Sl2s2002AppProcess,
|
||||
.ApplicationGetUidFunc = Sl2s2002GetUid,
|
||||
.ApplicationSetUidFunc = Sl2s2002SetUid,
|
||||
.UidSize = ISO15693_GENERIC_UID_SIZE,
|
||||
.MemorySize = ISO15693_GENERIC_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO15693
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TITAGITSTANDARD_SUPPORT
|
||||
[CONFIG_TITAGITSTANDARD] = {
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = TITagitstandardAppInit,
|
||||
.ApplicationResetFunc = TITagitstandardAppReset,
|
||||
.ApplicationTaskFunc = TITagitstandardAppTask,
|
||||
.ApplicationTickFunc = TITagitstandardAppTick,
|
||||
.ApplicationProcessFunc = TITagitstandardAppProcess,
|
||||
.ApplicationGetUidFunc = TITagitstandardGetUid,
|
||||
.ApplicationSetUidFunc = TITagitstandardSetUid,
|
||||
.UidSize = TITAGIT_STD_UID_SIZE,
|
||||
.MemorySize = TITAGIT_STD_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO15693
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = TITagitstandardAppInit,
|
||||
.ApplicationResetFunc = TITagitstandardAppReset,
|
||||
.ApplicationTaskFunc = TITagitstandardAppTask,
|
||||
.ApplicationTickFunc = TITagitstandardAppTick,
|
||||
.ApplicationProcessFunc = TITagitstandardAppProcess,
|
||||
.ApplicationGetUidFunc = TITagitstandardGetUid,
|
||||
.ApplicationSetUidFunc = TITagitstandardSetUid,
|
||||
.UidSize = TITAGIT_STD_UID_SIZE,
|
||||
.MemorySize = TITAGIT_STD_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO15693
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_EM4233_SUPPORT
|
||||
[CONFIG_EM4233] = {
|
||||
.CodecInitFunc = ISO15693CodecInit,
|
||||
.CodecDeInitFunc = ISO15693CodecDeInit,
|
||||
.CodecTaskFunc = ISO15693CodecTask,
|
||||
.ApplicationInitFunc = EM4233AppInit,
|
||||
.ApplicationResetFunc = EM4233AppReset,
|
||||
.ApplicationTaskFunc = EM4233AppTask,
|
||||
.ApplicationTickFunc = EM4233AppTick,
|
||||
.ApplicationProcessFunc = EM4233AppProcess,
|
||||
.ApplicationGetUidFunc = EM4233GetUid,
|
||||
.ApplicationSetUidFunc = EM4233SetUid,
|
||||
.UidSize = EM4233_STD_UID_SIZE,
|
||||
.MemorySize = EM4233_STD_MEM_SIZE,
|
||||
.ReadOnly = false,
|
||||
.TagFamily = TAG_FAMILY_ISO15693
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -54,6 +54,9 @@ typedef enum {
|
||||
#endif
|
||||
#ifdef CONFIG_TITAGITSTANDARD_SUPPORT
|
||||
CONFIG_TITAGITSTANDARD,
|
||||
#endif
|
||||
#ifdef CONFIG_EM4233_SUPPORT
|
||||
CONFIG_EM4233,
|
||||
#endif
|
||||
/* This HAS to be the last element */
|
||||
CONFIG_COUNT
|
||||
|
||||
Binary file not shown.
@@ -16,6 +16,7 @@ SETTINGS += -DCONFIG_VICINITY_SUPPORT
|
||||
SETTINGS += -DCONFIG_SL2S2002_SUPPORT
|
||||
SETTINGS += -DCONFIG_TITAGITSTANDARD_SUPPORT
|
||||
SETTINGS += -DCONFIG_ISO15693_SNIFF_SUPPORT
|
||||
SETTINGS += -DCONFIG_EM4233_SUPPORT
|
||||
|
||||
#Support magic mode on mifare classic configuration
|
||||
SETTINGS += -DSUPPORT_MF_CLASSIC_MAGIC_MODE
|
||||
@@ -99,7 +100,7 @@ SRC += Terminal/Terminal.c Terminal/Commands.c Terminal/XModem.c Termina
|
||||
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
|
||||
SRC += Codec/ISO15693.c
|
||||
SRC += Application/Vicinity.c Application/Sl2s2002.c Application/TITagitstandard.c Application/ISO15693-A.c
|
||||
SRC += Application/Vicinity.c Application/Sl2s2002.c Application/TITagitstandard.c Application/ISO15693-A.c Application/EM4233.c
|
||||
SRC += $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
|
||||
LUFA_PATH = ../LUFA
|
||||
CC_FLAGS = -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)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//------------------------------------------------
|
||||
//--- 010 Editor v9.0.1 Binary Template
|
||||
//
|
||||
// File: EM4233 ChameleonMini dump format
|
||||
// Authors: ceres-c
|
||||
// Version: 1.0
|
||||
// Purpose: Quick edit of custom dumps
|
||||
// Category: Electronics
|
||||
// File Mask:
|
||||
// ID Bytes:
|
||||
// History:
|
||||
// 1.0 2018-12-27 ceres-c: Initial release
|
||||
//------------------------------------------------
|
||||
|
||||
struct FILE {
|
||||
struct Card_dump {
|
||||
char Data[4] <format=hex>;
|
||||
} block [52];
|
||||
|
||||
struct Emulation_data {
|
||||
char UID[8] <format=hex, fgcolor=cDkGreen>;
|
||||
char AFI[1] <format=binary, fgcolor=cLtRed>;
|
||||
char DSFID[1] <format=binary, fgcolor=cDkAqua>;
|
||||
char RFU[2] <fgcolor=cBlack>;
|
||||
char Info_bits[4] <format=binary, fgcolor=cDkBlue>;
|
||||
struct Lock_status_bytes {
|
||||
char lsbyte <format=binary, fgcolor=cDkRed>;
|
||||
} lsb [52];
|
||||
char Password[4] <format=hex, fgcolor=cPurple>;
|
||||
char Key[12] <format=hex, fgcolor=cDkPurple>;
|
||||
} emudata;
|
||||
|
||||
} file <bgcolor=cSilver>;
|
||||
Reference in New Issue
Block a user