Christina Quast | c0aa769 | 2015-02-25 14:02:01 +0100 | [diff] [blame] | 1 | #ifndef SIMTRACE_H |
| 2 | #define SIMTRACE_H |
Christina Quast | 32906bb | 2015-02-24 11:35:19 +0100 | [diff] [blame] | 3 | |
Christina Quast | 4db82e0 | 2015-04-11 18:14:41 +0200 | [diff] [blame] | 4 | #include "ringbuffer.h" |
| 5 | |
Christina Quast | 4ba4d22 | 2015-03-02 16:14:09 +0100 | [diff] [blame] | 6 | /* Endpoint numbers */ |
| 7 | #define DATAOUT 1 |
| 8 | #define DATAIN 2 |
| 9 | #define INT 3 |
| 10 | |
Christina Quast | 235409a | 2015-06-24 16:05:09 +0200 | [diff] [blame] | 11 | #define BUFLEN 512 |
Christina Quast | 7123425 | 2015-04-03 11:35:59 +0200 | [diff] [blame] | 12 | |
Christina Quast | b65b881 | 2015-04-04 10:51:37 +0200 | [diff] [blame] | 13 | #define PHONE_DATAOUT 4 |
| 14 | #define PHONE_DATAIN 5 |
| 15 | #define PHONE_INT 6 |
Christina Quast | 7123425 | 2015-04-03 11:35:59 +0200 | [diff] [blame] | 16 | |
Christina Quast | ec9c09e | 2015-04-16 10:45:39 +0200 | [diff] [blame] | 17 | #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 Quast | 3eab56e | 2015-04-10 15:38:49 +0200 | [diff] [blame] | 27 | |
Christina Quast | 4db82e0 | 2015-04-11 18:14:41 +0200 | [diff] [blame] | 28 | extern volatile ringbuf sim_rcv_buf; |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 29 | |
| 30 | extern volatile bool rcvdChar; |
| 31 | extern volatile uint32_t char_stat; |
Christina Quast | 4ba4d22 | 2015-03-02 16:14:09 +0100 | [diff] [blame] | 32 | |
Christina Quast | e4cbfe6 | 2015-04-20 13:07:28 +0200 | [diff] [blame] | 33 | extern const Pin pinPhoneRST; |
| 34 | |
Christina Quast | 10b2e5a | 2015-02-25 18:40:15 +0100 | [diff] [blame] | 35 | enum confNum { |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 36 | CFG_NUM_SNIFF = 1, CFG_NUM_CCID, CFG_NUM_PHONE, CFG_NUM_MITM, NUM_CONF |
Christina Quast | 10b2e5a | 2015-02-25 18:40:15 +0100 | [diff] [blame] | 37 | }; |
| 38 | |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 39 | /// CCIDDriverConfiguration Descriptors |
| 40 | /// List of descriptors that make up the configuration descriptors of a |
| 41 | /// device using the CCID driver. |
| 42 | typedef 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 Quast | 4b1e98d | 2015-04-06 23:28:02 +0200 | [diff] [blame] | 58 | extern const USBConfigurationDescriptor *configurationDescriptorsArr[]; |
| 59 | |
Christina Quast | 2b8a18b | 2015-04-12 09:31:36 +0200 | [diff] [blame] | 60 | int check_data_from_phone(); |
Christina Quast | cb646bc | 2015-05-03 14:21:26 +0200 | [diff] [blame] | 61 | void update_fidi(uint8_t fidi); |
Christina Quast | be23527 | 2015-05-02 17:56:32 +0200 | [diff] [blame] | 62 | |
Christina Quast | e4cbfe6 | 2015-04-20 13:07:28 +0200 | [diff] [blame] | 63 | void ISR_PhoneRST( const Pin *pPin); |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 64 | |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 65 | /* Configure functions */ |
| 66 | extern void Sniffer_configure( void ); |
| 67 | extern void CCID_configure( void ); |
| 68 | extern void Phone_configure( void ); |
| 69 | extern void MITM_configure( void ); |
| 70 | |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 71 | /* Init functions */ |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 72 | extern void Sniffer_init( void ); |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 73 | extern void CCID_init( void ); |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 74 | extern void Phone_init( void ); |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 75 | extern void MITM_init( void ); |
Christina Quast | 27c643d | 2015-02-24 19:09:08 +0100 | [diff] [blame] | 76 | |
Christina Quast | c0aa769 | 2015-02-25 14:02:01 +0100 | [diff] [blame] | 77 | extern void SIMtrace_USB_Initialize( void ); |
Christina Quast | c0aa769 | 2015-02-25 14:02:01 +0100 | [diff] [blame] | 78 | |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 79 | /* Exit functions */ |
| 80 | extern void Sniffer_exit( void ); |
| 81 | extern void CCID_exit( void ); |
| 82 | extern void Phone_exit( void ); |
| 83 | extern void MITM_exit( void ); |
| 84 | |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 85 | /* Run functions */ |
| 86 | extern void Sniffer_run( void ); |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 87 | extern void CCID_run( void ); |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 88 | extern void Phone_run( void ); |
| 89 | extern void MITM_run( void ); |
| 90 | |
Christina Quast | 531d10b | 2015-03-19 19:27:04 +0100 | [diff] [blame] | 91 | /* Timer helper function */ |
| 92 | void Timer_Init( void ); |
| 93 | void TC0_Counter_Reset( void ); |
| 94 | |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 95 | #endif /* SIMTRACE_H */ |