2010-02-21 05:24:25 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Jonathan Westhues, Aug 2005
|
2011-05-18 20:33:32 +08:00
|
|
|
// Gerhard de Koning Gans, April 2008, May 2011
|
2010-02-21 08:12:52 +08:00
|
|
|
//
|
|
|
|
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
|
|
|
// at your option, any later version. See the LICENSE.txt file for the text of
|
|
|
|
// the license.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Definitions internal to the app source.
|
2010-02-21 05:24:25 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef __APPS_H
|
|
|
|
#define __APPS_H
|
|
|
|
|
2010-02-21 06:51:00 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2010-02-21 05:24:25 +08:00
|
|
|
typedef unsigned char byte_t;
|
|
|
|
|
|
|
|
// The large multi-purpose buffer, typically used to hold A/D samples,
|
|
|
|
// maybe processed in some way.
|
2012-06-29 18:24:05 +08:00
|
|
|
uint32_t BigBuf[10000];
|
|
|
|
// BIG CHANGE - UNDERSTAND THIS BEFORE WE COMMIT
|
|
|
|
#define TRACE_OFFSET 0
|
|
|
|
#define TRACE_SIZE 3000
|
|
|
|
#define RECV_CMD_OFFSET 3032
|
|
|
|
#define RECV_CMD_SIZE 64
|
|
|
|
#define RECV_RES_OFFSET 3096
|
|
|
|
#define RECV_RES_SIZE 64
|
|
|
|
#define DMA_BUFFER_OFFSET 3160
|
|
|
|
#define DMA_BUFFER_SIZE 4096
|
|
|
|
#define FREE_BUFFER_OFFSET 7256
|
|
|
|
#define FREE_BUFFER_SIZE 2744
|
|
|
|
|
2012-06-28 21:38:40 +08:00
|
|
|
extern const uint8_t OddByteParity[256];
|
|
|
|
extern uint8_t *trace; // = (uint8_t *) BigBuf;
|
|
|
|
extern int traceLen; // = 0;
|
|
|
|
extern int rsamples; // = 0;
|
|
|
|
extern int tracing; // = TRUE;
|
|
|
|
extern uint8_t trigger;
|
2010-02-21 05:24:25 +08:00
|
|
|
|
2010-10-08 18:23:04 +08:00
|
|
|
// This may be used (sparingly) to declare a function to be copied to
|
|
|
|
// and executed from RAM
|
|
|
|
#define RAMFUNC __attribute((long_call, section(".ramfunc")))
|
|
|
|
|
2010-02-21 05:24:25 +08:00
|
|
|
/// appmain.h
|
|
|
|
void ReadMem(int addr);
|
|
|
|
void __attribute__((noreturn)) AppMain(void);
|
|
|
|
void SamyRun(void);
|
|
|
|
//void DbpIntegers(int a, int b, int c);
|
|
|
|
void DbpString(char *str);
|
|
|
|
void Dbprintf(const char *fmt, ...);
|
2010-10-19 22:25:17 +08:00
|
|
|
void Dbhexdump(int len, uint8_t *d);
|
2010-02-21 05:24:25 +08:00
|
|
|
|
2011-06-10 21:35:10 +08:00
|
|
|
int AvgAdc(int ch);
|
|
|
|
|
2010-02-21 05:24:25 +08:00
|
|
|
void ToSendStuffBit(int b);
|
|
|
|
void ToSendReset(void);
|
|
|
|
void ListenReaderField(int limit);
|
2010-02-21 06:51:00 +08:00
|
|
|
void AcquireRawAdcSamples125k(int at134khz);
|
2010-02-21 05:24:25 +08:00
|
|
|
void DoAcquisition125k(void);
|
|
|
|
extern int ToSendMax;
|
2010-02-21 06:51:00 +08:00
|
|
|
extern uint8_t ToSend[];
|
|
|
|
extern uint32_t BigBuf[];
|
2010-02-21 05:24:25 +08:00
|
|
|
|
|
|
|
/// fpga.h
|
2010-02-21 06:51:00 +08:00
|
|
|
void FpgaSendCommand(uint16_t cmd, uint16_t v);
|
|
|
|
void FpgaWriteConfWord(uint8_t v);
|
2010-02-21 05:24:25 +08:00
|
|
|
void FpgaDownloadAndGo(void);
|
|
|
|
void FpgaGatherVersion(char *dst, int len);
|
|
|
|
void FpgaSetupSsc(void);
|
|
|
|
void SetupSpi(int mode);
|
2010-02-21 06:51:00 +08:00
|
|
|
void FpgaSetupSscDma(uint8_t *buf, int len);
|
|
|
|
void SetAdcMuxFor(uint32_t whichGpio);
|
2010-02-21 05:24:25 +08:00
|
|
|
|
|
|
|
// Definitions for the FPGA commands.
|
|
|
|
#define FPGA_CMD_SET_CONFREG (1<<12)
|
|
|
|
#define FPGA_CMD_SET_DIVISOR (2<<12)
|
|
|
|
// Definitions for the FPGA configuration word.
|
|
|
|
#define FPGA_MAJOR_MODE_LF_READER (0<<5)
|
|
|
|
#define FPGA_MAJOR_MODE_LF_SIMULATOR (1<<5)
|
|
|
|
#define FPGA_MAJOR_MODE_HF_READER_TX (2<<5)
|
|
|
|
#define FPGA_MAJOR_MODE_HF_READER_RX_XCORR (3<<5)
|
|
|
|
#define FPGA_MAJOR_MODE_HF_SIMULATOR (4<<5)
|
|
|
|
#define FPGA_MAJOR_MODE_HF_ISO14443A (5<<5)
|
|
|
|
#define FPGA_MAJOR_MODE_LF_PASSTHRU (6<<5)
|
|
|
|
#define FPGA_MAJOR_MODE_OFF (7<<5)
|
|
|
|
// Options for the HF reader, tx to tag
|
|
|
|
#define FPGA_HF_READER_TX_SHALLOW_MOD (1<<0)
|
|
|
|
// Options for the HF reader, correlating against rx from tag
|
|
|
|
#define FPGA_HF_READER_RX_XCORR_848_KHZ (1<<0)
|
|
|
|
#define FPGA_HF_READER_RX_XCORR_SNOOP (1<<1)
|
|
|
|
#define FPGA_HF_READER_RX_XCORR_QUARTER_FREQ (1<<2)
|
|
|
|
// Options for the HF simulated tag, how to modulate
|
|
|
|
#define FPGA_HF_SIMULATOR_NO_MODULATION (0<<0)
|
|
|
|
#define FPGA_HF_SIMULATOR_MODULATE_BPSK (1<<0)
|
|
|
|
#define FPGA_HF_SIMULATOR_MODULATE_212K (2<<0)
|
|
|
|
// Options for ISO14443A
|
|
|
|
#define FPGA_HF_ISO14443A_SNIFFER (0<<0)
|
|
|
|
#define FPGA_HF_ISO14443A_TAGSIM_LISTEN (1<<0)
|
|
|
|
#define FPGA_HF_ISO14443A_TAGSIM_MOD (2<<0)
|
|
|
|
#define FPGA_HF_ISO14443A_READER_LISTEN (3<<0)
|
|
|
|
#define FPGA_HF_ISO14443A_READER_MOD (4<<0)
|
|
|
|
|
|
|
|
/// lfops.h
|
2010-02-21 06:51:00 +08:00
|
|
|
void AcquireRawAdcSamples125k(int at134khz);
|
|
|
|
void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,uint8_t *command);
|
2010-02-21 05:24:25 +08:00
|
|
|
void ReadTItag(void);
|
2010-02-21 06:51:00 +08:00
|
|
|
void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc);
|
2010-02-21 05:24:25 +08:00
|
|
|
void AcquireTiType(void);
|
|
|
|
void AcquireRawBitsTI(void);
|
|
|
|
void SimulateTagLowFrequency(int period, int gap, int ledcontrol);
|
|
|
|
void CmdHIDsimTAG(int hi, int lo, int ledcontrol);
|
|
|
|
void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol);
|
|
|
|
void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen);
|
2012-07-02 16:37:50 +08:00
|
|
|
void CopyHIDtoT55x7(int hi, int lo); // Clone an HID card to T5557/T5567
|
2012-03-07 21:44:53 +08:00
|
|
|
void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo);
|
2012-07-02 16:37:50 +08:00
|
|
|
void CopyIndala64toT55x7(int hi, int lo); // Clone Indala 64-bit tag by UID to T55x7
|
|
|
|
void CopyIndala224toT55x7(int uid1, int uid2, int uid3, int uid4, int uid5, int uid6, int uid7); // Clone Indala 224-bit tag by UID to T55x7
|
2010-02-21 05:24:25 +08:00
|
|
|
|
|
|
|
/// iso14443.h
|
|
|
|
void SimulateIso14443Tag(void);
|
2010-02-21 06:51:00 +08:00
|
|
|
void AcquireRawAdcSamplesIso14443(uint32_t parameter);
|
|
|
|
void ReadSRI512Iso14443(uint32_t parameter);
|
|
|
|
void ReadSRIX4KIso14443(uint32_t parameter);
|
|
|
|
void ReadSTMemoryIso14443(uint32_t parameter,uint32_t dwLast);
|
2011-09-06 18:28:22 +08:00
|
|
|
void RAMFUNC SnoopIso14443(void);
|
2010-02-21 05:24:25 +08:00
|
|
|
|
|
|
|
/// iso14443a.h
|
2010-10-08 18:23:04 +08:00
|
|
|
void RAMFUNC SnoopIso14443a(void);
|
2012-06-29 18:24:05 +08:00
|
|
|
void SimulateIso14443aTag(int tagType, int uid_1st, int uid_2nd); // ## simulate iso14443a tag
|
2010-07-13 21:39:30 +08:00
|
|
|
void ReaderIso14443a(UsbCommand * c, UsbCommand * ack);
|
2012-06-28 21:38:40 +08:00
|
|
|
// Also used in iclass.c
|
|
|
|
int LogTrace(const uint8_t * btBytes, int iLen, int iSamples, uint32_t dwParity, int bReader);
|
|
|
|
uint32_t GetParity(const uint8_t * pbtCmd, int iLen);
|
|
|
|
void iso14a_set_trigger(int enable);
|
|
|
|
void iso14a_clear_tracelen(void);
|
|
|
|
void iso14a_set_tracing(int enable);
|
2011-06-18 02:39:54 +08:00
|
|
|
|
|
|
|
// mifarecmd.h
|
2010-02-21 06:51:00 +08:00
|
|
|
void ReaderMifare(uint32_t parameter);
|
2011-05-26 20:55:15 +08:00
|
|
|
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data);
|
|
|
|
void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
|
|
|
void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
2011-06-07 20:35:52 +08:00
|
|
|
void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
|
|
|
void MifareChkKeys(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
2011-05-26 20:55:15 +08:00
|
|
|
void Mifare1ksim(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
2011-06-18 02:39:54 +08:00
|
|
|
void MifareSetDbgLvl(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
|
|
|
void MifareEMemClr(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
|
|
|
void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
|
|
|
void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
|
|
|
void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
2012-07-05 15:31:56 +08:00
|
|
|
void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain); // Work with "magic Chinese" card
|
2012-07-05 22:05:01 +08:00
|
|
|
void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
2010-02-21 05:24:25 +08:00
|
|
|
|
|
|
|
/// iso15693.h
|
2010-10-19 22:25:17 +08:00
|
|
|
void RecordRawAdcSamplesIso15693(void);
|
2010-02-21 05:24:25 +08:00
|
|
|
void AcquireRawAdcSamplesIso15693(void);
|
2010-02-21 06:51:00 +08:00
|
|
|
void ReaderIso15693(uint32_t parameter); // Simulate an ISO15693 reader - greg
|
|
|
|
void SimTagIso15693(uint32_t parameter); // simulate an ISO15693 tag - greg
|
2010-10-19 22:25:17 +08:00
|
|
|
void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
|
|
|
|
void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t data[]); // send arbitrary commands from CLI - atrox
|
|
|
|
void SetDebugIso15693(uint32_t flag);
|
2010-02-21 05:24:25 +08:00
|
|
|
|
2011-05-18 20:33:32 +08:00
|
|
|
/// iclass.h
|
|
|
|
void RAMFUNC SnoopIClass(void);
|
2012-06-28 21:38:40 +08:00
|
|
|
void SimulateIClass(uint8_t arg0, uint8_t *datain);
|
|
|
|
void ReaderIClass(uint8_t arg0);
|
2011-05-18 20:33:32 +08:00
|
|
|
|
2010-02-21 05:24:25 +08:00
|
|
|
/// util.h
|
|
|
|
|
|
|
|
#endif
|