mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
added vdwels changes
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "MifareClassic.h"
|
||||
#include "Reader14443A.h"
|
||||
#include "Vicinity.h"
|
||||
#include "Sl2s2002.h"
|
||||
|
||||
|
||||
/* Function wrappers */
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* ISO15693.c
|
||||
*
|
||||
* Created on: 01-03-2017
|
||||
* Author: Phillip Nash
|
||||
*/
|
||||
|
||||
|
||||
#include "Sl2s2002.h"
|
||||
#include "../Codec/ISO15693.h"
|
||||
#include "../Memory.h"
|
||||
#include "Crypto1.h"
|
||||
#include "../Random.h"
|
||||
#include "ISO15693-A.h"
|
||||
|
||||
#define BYTES_PER_PAGE 4
|
||||
|
||||
static enum {
|
||||
STATE_READY,
|
||||
STATE_SELECTED,
|
||||
STATE_QUIET
|
||||
} State;
|
||||
|
||||
|
||||
ISO15693UidType Sl2s2002Uid = {0x78, 0xD3, 0xF4, 0x3F, 0x50, 0x01, 0x04, 0xE0};
|
||||
|
||||
//ISO15693UidType Sl2s2002Uid = {0x60, 0x0B, 0x88, 0x77, 0x06, 0x44, 0x02, 0xE1};
|
||||
|
||||
|
||||
|
||||
void Sl2s2002AppInit(void)
|
||||
{
|
||||
State = STATE_READY;
|
||||
}
|
||||
|
||||
void Sl2s2002AppReset(void)
|
||||
{
|
||||
State = STATE_READY;
|
||||
}
|
||||
|
||||
|
||||
void Sl2s2002AppTask(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Sl2s2002AppTick(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// void sendIntToTermina(uint8_t val)
|
||||
// {
|
||||
// char buf[16];
|
||||
// snprintf(buf,16, "%02x",val);
|
||||
// TerminalSendString(buf);
|
||||
// }
|
||||
|
||||
uint16_t Sl2s2002AppProcess(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;
|
||||
|
||||
//TerminalSendString("Received command: ");
|
||||
// for (int i = 0; i < (FrameBytes - 2); i++) {
|
||||
// sendIntToTermina(FrameBuf[i]);
|
||||
// }
|
||||
// TerminalSendString("\n");
|
||||
|
||||
|
||||
switch(State) {
|
||||
case STATE_READY:
|
||||
if (Command == ISO15693_CMD_INVENTORY) {
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FrameBuf[1] = 0x00; /* DSFID */
|
||||
ISO15693CopyUid(&FrameBuf[2], Sl2s2002Uid);
|
||||
ResponseByteCount = 10;
|
||||
} else if (Command == ISO15693_CMD_STAY_QUIET) {
|
||||
if (ISO15693Addressed(FrameBuf, Sl2s2002Uid)) {
|
||||
State = STATE_QUIET;
|
||||
}
|
||||
} else if (Command == ISO15693_CMD_GET_SYS_INFO) {
|
||||
if (ISO15693Addressed(FrameBuf, Sl2s2002Uid)) {
|
||||
FrameBuf[0] = 0; /* Flags */
|
||||
FrameBuf[1] = 0x0F; /* InfoFlags */
|
||||
ISO15693CopyUid(&FrameBuf[2], Sl2s2002Uid);
|
||||
FrameBuf[10] = 0x00;
|
||||
FrameBuf[11] = 0xC2;
|
||||
FrameBuf[12] = 0x04;
|
||||
FrameBuf[13] = 0x03;
|
||||
FrameBuf[14] = 0x01;
|
||||
ResponseByteCount = 15;
|
||||
}
|
||||
} else if (Command == ISO15693_CMD_READ_SINGLE) {
|
||||
if (ISO15693Addressed(FrameBuf, Sl2s2002Uid)) {
|
||||
uint8_t PageAddress = FrameBuf[10];
|
||||
FrameBuf[0] = 0; /* Flags */
|
||||
MemoryReadBlock(FrameBuf + 1, PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
|
||||
ResponseByteCount = 5;
|
||||
}
|
||||
} else if (Command == ISO15693_CMD_READ_MULTIPLE) {
|
||||
if (ISO15693Addressed(FrameBuf, Sl2s2002Uid)) {
|
||||
uint8_t PageAddressStart = FrameBuf[10];
|
||||
uint8_t PageAddressEnd = FrameBuf[11];
|
||||
FrameBuf[0] = 0; /* Flags */
|
||||
MemoryReadBlock(FrameBuf + 1, PageAddressStart * BYTES_PER_PAGE, BYTES_PER_PAGE * (PageAddressEnd - PageAddressStart + 1));
|
||||
ResponseByteCount = 1 + BYTES_PER_PAGE * (PageAddressEnd - PageAddressStart + 1);
|
||||
}
|
||||
} else if (Command == ISO15693_CMD_GET_BLOCK_SEC) {
|
||||
if (ISO15693Addressed(FrameBuf, Sl2s2002Uid)) {
|
||||
uint8_t PageAddressStart = FrameBuf[10];
|
||||
uint8_t PageAddressEnd = FrameBuf[11];
|
||||
FrameBuf[0] = 0; /* Flags */
|
||||
for (int i = 1; i <= (PageAddressEnd - PageAddressStart + 1); i++) {
|
||||
FrameBuf[i] = 0x00;
|
||||
}
|
||||
ResponseByteCount = 1 + (PageAddressEnd - PageAddressStart + 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case STATE_SELECTED:
|
||||
|
||||
break;
|
||||
|
||||
case STATE_QUIET:
|
||||
if (Command == ISO15693_CMD_RESET_TO_READY) {
|
||||
if (ISO15693Addressed(FrameBuf, Sl2s2002Uid)) {
|
||||
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 Sl2s2002GetUid(ConfigurationUidType Uid)
|
||||
{
|
||||
memcpy(Uid, Sl2s2002Uid, sizeof(ConfigurationUidType));
|
||||
}
|
||||
|
||||
void Sl2s2002SetUid(ConfigurationUidType Uid)
|
||||
{
|
||||
memcpy(Sl2s2002Uid, Uid, sizeof(ConfigurationUidType));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* MifareClassic.h
|
||||
*
|
||||
* Created on: 01.03.2017
|
||||
* Author: skuser
|
||||
*/
|
||||
|
||||
#ifndef SL2S2002_H_
|
||||
#define SL2S2002_H_
|
||||
|
||||
#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);
|
||||
void Sl2s2002AppTick(void);
|
||||
uint16_t Sl2s2002AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes);
|
||||
void Sl2s2002GetUid(ConfigurationUidType Uid);
|
||||
void Sl2s2002SetUid(ConfigurationUidType Uid);
|
||||
|
||||
|
||||
|
||||
#endif /* VICINITY_H_ */
|
||||
@@ -40,6 +40,12 @@ static const MapEntryType PROGMEM ConfigurationMap[] = {
|
||||
#ifdef CONFIG_VICINITY_SUPPORT
|
||||
{ .Id = CONFIG_VICINITY, .Text = "VICINITY" },
|
||||
#endif
|
||||
#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
|
||||
{ .Id = CONFIG_ISO15693_SNIFF, .Text = "ISO15693_SNIFF" },
|
||||
#endif
|
||||
#ifdef CONFIG_SL2S2002_SUPPORT
|
||||
{ .Id = CONFIG_SL2S2002, .Text = "SL2S2002" },
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Include all Codecs and Applications */
|
||||
@@ -240,6 +246,40 @@ static const PROGMEM ConfigurationType ConfigurationTable[] = {
|
||||
.ReadOnly = false
|
||||
},
|
||||
#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
|
||||
},
|
||||
#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
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
ConfigurationType ActiveConfiguration;
|
||||
|
||||
@@ -45,6 +45,12 @@ typedef enum {
|
||||
#endif
|
||||
#ifdef CONFIG_VICINITY_SUPPORT
|
||||
CONFIG_VICINITY,
|
||||
#endif
|
||||
#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
|
||||
CONFIG_ISO15693_SNIFF,
|
||||
#endif
|
||||
#ifdef CONFIG_SL2S2002_SUPPORT
|
||||
CONFIG_SL2S2002,
|
||||
#endif
|
||||
/* This HAS to be the last element */
|
||||
CONFIG_COUNT
|
||||
|
||||
@@ -13,6 +13,8 @@ SETTINGS += -DCONFIG_MF_ULTRALIGHT_SUPPORT
|
||||
SETTINGS += -DCONFIG_ISO14443A_SNIFF_SUPPORT
|
||||
SETTINGS += -DCONFIG_ISO14443A_READER_SUPPORT
|
||||
SETTINGS += -DCONFIG_VICINITY_SUPPORT
|
||||
SETTINGS += -DCONFIG_SL2S2002_SUPPORT
|
||||
SETTINGS += -DCONFIG_ISO15693_SNIFF_SUPPORT
|
||||
|
||||
#Support magic mode on mifare classic configuration
|
||||
SETTINGS += -DSUPPORT_MF_CLASSIC_MAGIC_MODE
|
||||
@@ -94,7 +96,7 @@ OPTIMIZATION = s
|
||||
SRC += $(TARGET).c LUFADescriptors.c System.c Configuration.c Random.c Common.c Memory.c MemoryAsm.S Button.c Log.c Settings.c LED.c Map.c AntennaLevel.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/Reader14443-ISR.S Codec/ISO15693.c
|
||||
SRC += Application/MifareUltralight.c Application/MifareClassic.c Application/ISO14443-3A.c Application/Crypto1.c Application/Reader14443A.c Application/Vicinity.c Application/ISO15693-A.c
|
||||
SRC += Application/MifareUltralight.c Application/MifareClassic.c Application/ISO14443-3A.c Application/Crypto1.c Application/Reader14443A.c Application/Vicinity.c Application/Sl2s2002.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