mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
Porting Rickventura changes to the main repo
This commit is contained in:
committed by
Thorsten Bosbach
parent
9636574341
commit
429f541eab
@@ -1,54 +1,56 @@
|
||||
/*
|
||||
* Application.h
|
||||
*
|
||||
* Created on: 18.02.2013
|
||||
* Author: skuser
|
||||
*/
|
||||
|
||||
#ifndef APPLICATION_H_
|
||||
#define APPLICATION_H_
|
||||
|
||||
#include "../Common.h"
|
||||
#include "../Configuration.h"
|
||||
#include "../Log.h"
|
||||
|
||||
/* Applications */
|
||||
#include "MifareUltralight.h"
|
||||
#include "MifareClassic.h"
|
||||
#include "Reader14443A.h"
|
||||
#include "Vicinity.h"
|
||||
#include "Sl2s2002.h"
|
||||
#include "Sniff14443A.h"
|
||||
|
||||
/* Function wrappers */
|
||||
INLINE void ApplicationInit(void) {
|
||||
ActiveConfiguration.ApplicationInitFunc();
|
||||
}
|
||||
|
||||
INLINE void ApplicationTask(void) {
|
||||
ActiveConfiguration.ApplicationTaskFunc();
|
||||
}
|
||||
|
||||
INLINE void ApplicationTick(void) {
|
||||
ActiveConfiguration.ApplicationTickFunc();
|
||||
}
|
||||
|
||||
INLINE uint16_t ApplicationProcess(uint8_t* ByteBuffer, uint16_t ByteCount) {
|
||||
return ActiveConfiguration.ApplicationProcessFunc(ByteBuffer, ByteCount);
|
||||
}
|
||||
|
||||
INLINE void ApplicationReset(void) {
|
||||
ActiveConfiguration.ApplicationResetFunc();
|
||||
//LogEntry(LOG_INFO_RESET_APP, NULL, 0);
|
||||
}
|
||||
|
||||
INLINE void ApplicationGetUid(ConfigurationUidType Uid) {
|
||||
ActiveConfiguration.ApplicationGetUidFunc(Uid);
|
||||
}
|
||||
|
||||
INLINE void ApplicationSetUid(ConfigurationUidType Uid) {
|
||||
ActiveConfiguration.ApplicationSetUidFunc(Uid);
|
||||
LogEntry(LOG_INFO_UID_SET, Uid, ActiveConfiguration.UidSize);
|
||||
}
|
||||
|
||||
#endif /* APPLICATION_H_ */
|
||||
/*
|
||||
* Application.h
|
||||
*
|
||||
* Created on: 18.02.2013
|
||||
* Author: skuser
|
||||
*/
|
||||
|
||||
#ifndef APPLICATION_H_
|
||||
#define APPLICATION_H_
|
||||
|
||||
#include "../Common.h"
|
||||
#include "../Configuration.h"
|
||||
#include "../Log.h"
|
||||
|
||||
/* Applications */
|
||||
#include "MifareUltralight.h"
|
||||
#include "MifareClassic.h"
|
||||
#include "Reader14443A.h"
|
||||
#include "Vicinity.h"
|
||||
#include "Sl2s2002.h"
|
||||
#include "TITagitstandard.h"
|
||||
#include "Sniff14443A.h"
|
||||
|
||||
|
||||
/* Function wrappers */
|
||||
INLINE void ApplicationInit(void) {
|
||||
ActiveConfiguration.ApplicationInitFunc();
|
||||
}
|
||||
|
||||
INLINE void ApplicationTask(void) {
|
||||
ActiveConfiguration.ApplicationTaskFunc();
|
||||
}
|
||||
|
||||
INLINE void ApplicationTick(void) {
|
||||
ActiveConfiguration.ApplicationTickFunc();
|
||||
}
|
||||
|
||||
INLINE uint16_t ApplicationProcess(uint8_t* ByteBuffer, uint16_t ByteCount) {
|
||||
return ActiveConfiguration.ApplicationProcessFunc(ByteBuffer, ByteCount);
|
||||
}
|
||||
|
||||
INLINE void ApplicationReset(void) {
|
||||
ActiveConfiguration.ApplicationResetFunc();
|
||||
//LogEntry(LOG_INFO_RESET_APP, NULL, 0);
|
||||
}
|
||||
|
||||
INLINE void ApplicationGetUid(ConfigurationUidType Uid) {
|
||||
ActiveConfiguration.ApplicationGetUidFunc(Uid);
|
||||
}
|
||||
|
||||
INLINE void ApplicationSetUid(ConfigurationUidType Uid) {
|
||||
ActiveConfiguration.ApplicationSetUidFunc(Uid);
|
||||
LogEntry(LOG_INFO_UID_SET, Uid, ActiveConfiguration.UidSize);
|
||||
}
|
||||
|
||||
#endif /* APPLICATION_H_ */
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* TITagitstandard.c
|
||||
*
|
||||
* Created on: 01-03-2017
|
||||
* Author: Phillip Nash
|
||||
* modified by rickventura for texas 15693 tag-it STANDARD
|
||||
*/
|
||||
|
||||
|
||||
#include "TITagitstandard.h"
|
||||
#include "../Codec/ISO15693.h"
|
||||
#include "../Memory.h"
|
||||
#include "Crypto1.h"
|
||||
#include "../Random.h"
|
||||
#include "ISO15693-A.h"
|
||||
|
||||
#define BYTES_PER_PAGE 4
|
||||
#define MEM_UID_ADDRESS 0x20
|
||||
|
||||
static enum {
|
||||
STATE_READY,
|
||||
STATE_SELECTED,
|
||||
STATE_QUIET
|
||||
} State;
|
||||
|
||||
//ISO15693UidType Uid = {0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x07, 0xE0};
|
||||
//0xE0 = iso15693
|
||||
//0x07 = TEXAS INSTRUMENTS
|
||||
//0xC0 0xC1 = "Tagitstandard" 0xC4 or 0xC5 "TagitPro" 0x00 or 0x01 or 0x80 or 0x81 "Tagitplus"
|
||||
|
||||
|
||||
void TITagitstandardAppInit(void)
|
||||
{
|
||||
State = STATE_READY;
|
||||
}
|
||||
|
||||
void TITagitstandardAppReset(void)
|
||||
{
|
||||
State = STATE_READY;
|
||||
}
|
||||
|
||||
|
||||
void TITagitstandardAppTask(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TITagitstandardAppTick(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// void sendIntToTermina(uint8_t val)
|
||||
// {
|
||||
// char buf[16];
|
||||
// snprintf(buf,16, "%02x",val);
|
||||
// TerminalSendString(buf);
|
||||
// }
|
||||
|
||||
uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (FrameBytes >= ISO15693_MIN_FRAME_SIZE) {
|
||||
if(ISO15693CheckCRC(FrameBuf, FrameBytes - ISO15693_CRC16_SIZE)) {
|
||||
// At this point, we have a valid ISO15693 frame
|
||||
uint8_t Command = FrameBuf[1];
|
||||
uint16_t ResponseByteCount = ISO15693_APP_NO_RESPONSE;
|
||||
uint8_t Uid[8];
|
||||
|
||||
//MemoryReadBlock(actualTagIt, 0, 44); // read the whole tag from FRAM
|
||||
MemoryReadBlock(Uid, MEM_UID_ADDRESS, ActiveConfiguration.UidSize);
|
||||
|
||||
//for (j==0 ; j < ActiveConfiguration.UidSize; j++) Uid[j] = actualTagIt[MEM_UID_ADDRESS + j] ;
|
||||
|
||||
switch(State) {
|
||||
case STATE_READY:
|
||||
if (Command == ISO15693_CMD_INVENTORY) {
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FrameBuf[1] = 0x00; /* DSFID */
|
||||
ISO15693CopyUid(&FrameBuf[2], Uid);
|
||||
|
||||
ResponseByteCount = 10;
|
||||
|
||||
|
||||
} else if (Command == ISO15693_CMD_STAY_QUIET) {
|
||||
if (ISO15693Addressed(FrameBuf,Uid)) {
|
||||
State = STATE_QUIET;
|
||||
|
||||
}
|
||||
|
||||
} else if (Command == ISO15693_CMD_READ_SINGLE) {
|
||||
uint8_t *FramePtr ;
|
||||
uint8_t PageAddress ;
|
||||
|
||||
|
||||
if ((FrameBuf[0] & ISO15693_REQ_FLAG_ADDRESS) && ISO15693CompareUid(&FrameBuf[2], Uid) )
|
||||
PageAddress = FrameBuf[10]; /*when receiving anaddressed request pick block number from the 10th byte in the request*/
|
||||
else
|
||||
PageAddress = FrameBuf[2];
|
||||
|
||||
|
||||
if (FrameBuf[0] & ISO15693_REQ_FLAG_OPTION)
|
||||
{ /*request with option flag set */
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FrameBuf[1] = ( PageAddress == 8 || PageAddress == 9) ? 0x02 : 0x00; /* block security status:when request has the option flag set*/
|
||||
FramePtr = FrameBuf + 2;
|
||||
ResponseByteCount = 6;
|
||||
|
||||
} else { /*request with option flag not set*/
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FramePtr = FrameBuf + 1 ;
|
||||
ResponseByteCount = 5;
|
||||
}
|
||||
|
||||
MemoryReadBlock(FramePtr, PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
|
||||
|
||||
}
|
||||
|
||||
else if (Command ==ISO15693_CMD_WRITE_SINGLE){
|
||||
uint8_t* Dataptr;
|
||||
uint8_t PageAddress ;
|
||||
|
||||
|
||||
if ((FrameBuf[0] & ISO15693_REQ_FLAG_ADDRESS) && ISO15693CompareUid(&FrameBuf[2], Uid) ){
|
||||
PageAddress = FrameBuf[10]; /*when receiving anaddressed request pick block number from 10th byte in the request*/
|
||||
Dataptr = &FrameBuf[11];
|
||||
}
|
||||
else {
|
||||
|
||||
PageAddress = FrameBuf[2];/*when receiving an unanaddressed request pick block number from 2nd byte in the request*/
|
||||
Dataptr = &FrameBuf[3];
|
||||
|
||||
}
|
||||
|
||||
MemoryWriteBlock( Dataptr , PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
|
||||
FrameBuf[0] = 0x00;
|
||||
ResponseByteCount = 1;
|
||||
|
||||
}
|
||||
break;
|
||||
case STATE_SELECTED:
|
||||
|
||||
break;
|
||||
|
||||
case STATE_QUIET:
|
||||
if (Command == ISO15693_CMD_RESET_TO_READY) {
|
||||
if (ISO15693Addressed(FrameBuf,Uid)) {
|
||||
FrameBuf[0] = 0;
|
||||
ResponseByteCount = 1;
|
||||
State = STATE_READY;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (ResponseByteCount > 0) {
|
||||
/* There is data to be sent. Append CRC */
|
||||
ISO15693AppendCRC(FrameBuf, ResponseByteCount);
|
||||
ResponseByteCount += ISO15693_CRC16_SIZE;
|
||||
}
|
||||
|
||||
return ResponseByteCount;
|
||||
|
||||
} else { // Invalid CRC
|
||||
return ISO15693_APP_NO_RESPONSE;
|
||||
}
|
||||
} else { // Min frame size not met
|
||||
return ISO15693_APP_NO_RESPONSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TITagitstandardGetUid(ConfigurationUidType Uid)
|
||||
{
|
||||
MemoryReadBlock(&Uid[0], MEM_UID_ADDRESS, ActiveConfiguration.UidSize);
|
||||
}
|
||||
|
||||
void TITagitstandardSetUid(ConfigurationUidType Uid)
|
||||
{
|
||||
MemoryWriteBlock(Uid, MEM_UID_ADDRESS, ActiveConfiguration.UidSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* MifareClassic.h
|
||||
*
|
||||
* Created on: 01.03.2017
|
||||
* Author: skuser
|
||||
* modified by rickventura
|
||||
*/
|
||||
|
||||
#ifndef TITAGITSTANDARD_H_
|
||||
#define TITAGITSTANDARD_H_
|
||||
|
||||
#include "Application.h"
|
||||
#include "ISO15693-A.h"
|
||||
|
||||
#define ISO15693_GENERIC_UID_SIZE 8 //ISO15693_UID_SIZE
|
||||
#define ISO15693_GENERIC_MEM_SIZE 44 //TAG-IT STANDARD MAX MEM SIZE
|
||||
|
||||
void TITagitstandardAppInit(void);
|
||||
void TITagitstandardAppReset(void);
|
||||
void TITagitstandardAppTask(void);
|
||||
void TITagitstandardAppTick(void);
|
||||
uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes);
|
||||
void TITagitstandardGetUid(ConfigurationUidType Uid);
|
||||
void TITagitstandardSetUid(ConfigurationUidType Uid);
|
||||
|
||||
|
||||
|
||||
#endif /* VICINITY_H_ */
|
||||
@@ -46,6 +46,10 @@ static const MapEntryType PROGMEM ConfigurationMap[] = {
|
||||
#ifdef CONFIG_SL2S2002_SUPPORT
|
||||
{ .Id = CONFIG_SL2S2002, .Text = "SL2S2002" },
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TITAGITSTANDARD_SUPPORT
|
||||
{ .Id = CONFIG_TITAGITSTANDARD, .Text = "TITAGITSTANDARD" },
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Include all Codecs and Applications */
|
||||
@@ -280,6 +284,24 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.ReadOnly = false
|
||||
},
|
||||
#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 = ISO15693_GENERIC_UID_SIZE,
|
||||
.MemorySize = ISO15693_GENERIC_MEM_SIZE,
|
||||
.ReadOnly = false
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
ConfigurationType ActiveConfiguration;
|
||||
|
||||
@@ -51,6 +51,9 @@ typedef enum {
|
||||
#endif
|
||||
#ifdef CONFIG_SL2S2002_SUPPORT
|
||||
CONFIG_SL2S2002,
|
||||
#endif
|
||||
#ifdef CONFIG_TITAGITSTANDARD_SUPPORT
|
||||
CONFIG_TITAGITSTANDARD,
|
||||
#endif
|
||||
/* This HAS to be the last element */
|
||||
CONFIG_COUNT
|
||||
|
||||
@@ -14,6 +14,7 @@ SETTINGS += -DCONFIG_ISO14443A_SNIFF_SUPPORT
|
||||
SETTINGS += -DCONFIG_ISO14443A_READER_SUPPORT
|
||||
SETTINGS += -DCONFIG_VICINITY_SUPPORT
|
||||
SETTINGS += -DCONFIG_SL2S2002_SUPPORT
|
||||
SETTINGS += -DCONFIG_TITAGITSTANDARD_SUPPORT
|
||||
SETTINGS += -DCONFIG_ISO15693_SNIFF_SUPPORT
|
||||
|
||||
#Support magic mode on mifare classic configuration
|
||||
@@ -98,7 +99,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/ISO15693-A.c
|
||||
SRC += Application/Vicinity.c Application/Sl2s2002.c Application/TITagitstandard.c Application/ISO15693-A.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)
|
||||
|
||||
Reference in New Issue
Block a user