blob: 00d2b7382a57b2d940cb76a2eecf3867bda9d188 [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 Quast4db82e02015-04-11 18:14:41 +02004#include "ringbuffer.h"
5
Christina Quast4ba4d222015-03-02 16:14:09 +01006/* Endpoint numbers */
7#define DATAOUT 1
8#define DATAIN 2
9#define INT 3
10
Christina Quast235409a2015-06-24 16:05:09 +020011#define BUFLEN 512
Christina Quast71234252015-04-03 11:35:59 +020012
Christina Quastb65b8812015-04-04 10:51:37 +020013#define PHONE_DATAOUT 4
14#define PHONE_DATAIN 5
15#define PHONE_INT 6
Christina Quast71234252015-04-03 11:35:59 +020016
Christina Quastec9c09e2015-04-16 10:45:39 +020017#define CLK_MASTER true
18#define CLK_SLAVE false
19
20/* ===================================================*/
21/* Taken from iso7816_4.c */
22/* ===================================================*/
23/** Flip flop for send and receive char */
24#define USART_SEND 0
25#define USART_RCV 1
26
Christina Quast3eab56e2015-04-10 15:38:49 +020027
Christina Quast4db82e02015-04-11 18:14:41 +020028extern volatile ringbuf sim_rcv_buf;
Christina Quast95d66162015-04-09 22:38:47 +020029
30extern volatile bool rcvdChar;
31extern volatile uint32_t char_stat;
Christina Quast4ba4d222015-03-02 16:14:09 +010032
Christina Quaste4cbfe62015-04-20 13:07:28 +020033extern const Pin pinPhoneRST;
34
Christina Quast10b2e5a2015-02-25 18:40:15 +010035enum confNum {
Christina Quastdb7b1ab2015-03-03 12:34:36 +010036 CFG_NUM_SNIFF = 1, CFG_NUM_CCID, CFG_NUM_PHONE, CFG_NUM_MITM, NUM_CONF
Christina Quast10b2e5a2015-02-25 18:40:15 +010037};
38
Christina Quastdb7b1ab2015-03-03 12:34:36 +010039/// CCIDDriverConfiguration Descriptors
40/// List of descriptors that make up the configuration descriptors of a
41/// device using the CCID driver.
42typedef struct {
43
44 /// Configuration descriptor
45 USBConfigurationDescriptor configuration;
46 /// Interface descriptor
47 USBInterfaceDescriptor interface;
48 /// CCID descriptor
49 CCIDDescriptor ccid;
50 /// Bulk OUT endpoint descriptor
51 USBEndpointDescriptor bulkOut;
52 /// Bulk IN endpoint descriptor
53 USBEndpointDescriptor bulkIn;
54 /// Interrupt OUT endpoint descriptor
55 USBEndpointDescriptor interruptIn;
56} __attribute__ ((packed)) CCIDDriverConfigurationDescriptors;
57
Christina Quast4b1e98d2015-04-06 23:28:02 +020058extern const USBConfigurationDescriptor *configurationDescriptorsArr[];
59
Christina Quast2b8a18b2015-04-12 09:31:36 +020060int check_data_from_phone();
Christina Quastcb646bc2015-05-03 14:21:26 +020061void update_fidi(uint8_t fidi);
Christina Quastbe235272015-05-02 17:56:32 +020062
Christina Quaste4cbfe62015-04-20 13:07:28 +020063void ISR_PhoneRST( const Pin *pPin);
Christina Quastdb7b1ab2015-03-03 12:34:36 +010064
Christina Quast95d66162015-04-09 22:38:47 +020065/* Configure functions */
66extern void Sniffer_configure( void );
67extern void CCID_configure( void );
68extern void Phone_configure( void );
69extern void MITM_configure( void );
70
Christina Quast1edf3502015-02-27 13:33:52 +010071/* Init functions */
Christina Quast95d66162015-04-09 22:38:47 +020072extern void Sniffer_init( void );
Christina Quastdb7b1ab2015-03-03 12:34:36 +010073extern void CCID_init( void );
Christina Quast95d66162015-04-09 22:38:47 +020074extern void Phone_init( void );
Christina Quast1edf3502015-02-27 13:33:52 +010075extern void MITM_init( void );
Christina Quast27c643d2015-02-24 19:09:08 +010076
Christina Quastc0aa7692015-02-25 14:02:01 +010077extern void SIMtrace_USB_Initialize( void );
Christina Quastc0aa7692015-02-25 14:02:01 +010078
Christina Quast95d66162015-04-09 22:38:47 +020079/* Exit functions */
80extern void Sniffer_exit( void );
81extern void CCID_exit( void );
82extern void Phone_exit( void );
83extern void MITM_exit( void );
84
Christina Quast1edf3502015-02-27 13:33:52 +010085/* Run functions */
86extern void Sniffer_run( void );
Christina Quastdb7b1ab2015-03-03 12:34:36 +010087extern void CCID_run( void );
Christina Quast1edf3502015-02-27 13:33:52 +010088extern void Phone_run( void );
89extern void MITM_run( void );
90
Christina Quast531d10b2015-03-19 19:27:04 +010091/* Timer helper function */
92void Timer_Init( void );
93void TC0_Counter_Reset( void );
94
Christina Quast1edf3502015-02-27 13:33:52 +010095#endif /* SIMTRACE_H */