blob: 249a55b2fa4901a9b3b808b1a6ea36c3a8d49405 [file] [log] [blame]
Christina Quastc0aa7692015-02-25 14:02:01 +01001#ifndef SIMTRACE_H
2#define SIMTRACE_H
Christina Quast32906bb2015-02-24 11:35:19 +01003
Christina Quast4ba4d222015-03-02 16:14:09 +01004/* Endpoint numbers */
5#define DATAOUT 1
6#define DATAIN 2
7#define INT 3
8
Christina Quast71234252015-04-03 11:35:59 +02009#define BUFLEN 5
10
Christina Quastb65b8812015-04-04 10:51:37 +020011#define PHONE_DATAOUT 4
12#define PHONE_DATAIN 5
13#define PHONE_INT 6
Christina Quast71234252015-04-03 11:35:59 +020014
Christina Quast4ba4d222015-03-02 16:14:09 +010015typedef struct ring_buffer
16{
17 uint8_t buf[BUFLEN*2]; // data buffer
18 uint8_t idx; // number of items in the buffer
19} ring_buffer;
20
Christina Quast95d66162015-04-09 22:38:47 +020021extern volatile ring_buffer buf;
22
23extern volatile bool rcvdChar;
24extern volatile uint32_t char_stat;
25extern volatile enum confNum simtrace_config;
Christina Quast4ba4d222015-03-02 16:14:09 +010026
Christina Quast10b2e5a2015-02-25 18:40:15 +010027enum confNum {
Christina Quastdb7b1ab2015-03-03 12:34:36 +010028 CFG_NUM_SNIFF = 1, CFG_NUM_CCID, CFG_NUM_PHONE, CFG_NUM_MITM, NUM_CONF
Christina Quast10b2e5a2015-02-25 18:40:15 +010029};
30
Christina Quastdb7b1ab2015-03-03 12:34:36 +010031/// CCIDDriverConfiguration Descriptors
32/// List of descriptors that make up the configuration descriptors of a
33/// device using the CCID driver.
34typedef struct {
35
36 /// Configuration descriptor
37 USBConfigurationDescriptor configuration;
38 /// Interface descriptor
39 USBInterfaceDescriptor interface;
40 /// CCID descriptor
41 CCIDDescriptor ccid;
42 /// Bulk OUT endpoint descriptor
43 USBEndpointDescriptor bulkOut;
44 /// Bulk IN endpoint descriptor
45 USBEndpointDescriptor bulkIn;
46 /// Interrupt OUT endpoint descriptor
47 USBEndpointDescriptor interruptIn;
48} __attribute__ ((packed)) CCIDDriverConfigurationDescriptors;
49
Christina Quast4b1e98d2015-04-06 23:28:02 +020050extern const USBConfigurationDescriptor *configurationDescriptorsArr[];
51
Christina Quastdb7b1ab2015-03-03 12:34:36 +010052/* Helper functions */
Christina Quastdb7b1ab2015-03-03 12:34:36 +010053
Christina Quast32906bb2015-02-24 11:35:19 +010054// FIXME: static function definitions
Christina Quast566d3f92015-02-24 17:38:57 +010055extern uint32_t _ISO7816_GetChar( uint8_t *pCharToReceive );
56extern uint32_t _ISO7816_SendChar( uint8_t CharToSend );
Christina Quast27c643d2015-02-24 19:09:08 +010057
Christina Quast95d66162015-04-09 22:38:47 +020058/* Configure functions */
59extern void Sniffer_configure( void );
60extern void CCID_configure( void );
61extern void Phone_configure( void );
62extern void MITM_configure( void );
63
Christina Quast1edf3502015-02-27 13:33:52 +010064/* Init functions */
Christina Quast95d66162015-04-09 22:38:47 +020065extern void Sniffer_init( void );
Christina Quastdb7b1ab2015-03-03 12:34:36 +010066extern void CCID_init( void );
Christina Quast95d66162015-04-09 22:38:47 +020067extern void Phone_init( void );
Christina Quast1edf3502015-02-27 13:33:52 +010068extern void MITM_init( void );
Christina Quast27c643d2015-02-24 19:09:08 +010069
Christina Quastc0aa7692015-02-25 14:02:01 +010070extern void SIMtrace_USB_Initialize( void );
Christina Quastc0aa7692015-02-25 14:02:01 +010071extern void _ISO7816_Init( void );
72
Christina Quast95d66162015-04-09 22:38:47 +020073/* Exit functions */
74extern void Sniffer_exit( void );
75extern void CCID_exit( void );
76extern void Phone_exit( void );
77extern void MITM_exit( void );
78
Christina Quast1edf3502015-02-27 13:33:52 +010079/* Run functions */
80extern void Sniffer_run( void );
Christina Quastdb7b1ab2015-03-03 12:34:36 +010081extern void CCID_run( void );
Christina Quast1edf3502015-02-27 13:33:52 +010082extern void Phone_run( void );
83extern void MITM_run( void );
84
Christina Quast531d10b2015-03-19 19:27:04 +010085/* Timer helper function */
86void Timer_Init( void );
87void TC0_Counter_Reset( void );
88
Christina Quast1edf3502015-02-27 13:33:52 +010089#endif /* SIMTRACE_H */