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 | 4ba4d22 | 2015-03-02 16:14:09 +0100 | [diff] [blame] | 4 | /* Endpoint numbers */ |
| 5 | #define DATAOUT 1 |
| 6 | #define DATAIN 2 |
| 7 | #define INT 3 |
| 8 | |
Christina Quast | 7123425 | 2015-04-03 11:35:59 +0200 | [diff] [blame] | 9 | #define BUFLEN 5 |
| 10 | |
Christina Quast | b65b881 | 2015-04-04 10:51:37 +0200 | [diff] [blame] | 11 | #define PHONE_DATAOUT 4 |
| 12 | #define PHONE_DATAIN 5 |
| 13 | #define PHONE_INT 6 |
Christina Quast | 7123425 | 2015-04-03 11:35:59 +0200 | [diff] [blame] | 14 | |
Christina Quast | 4ba4d22 | 2015-03-02 16:14:09 +0100 | [diff] [blame] | 15 | typedef 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 Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 21 | extern volatile ring_buffer buf; |
| 22 | |
| 23 | extern volatile bool rcvdChar; |
| 24 | extern volatile uint32_t char_stat; |
| 25 | extern volatile enum confNum simtrace_config; |
Christina Quast | 4ba4d22 | 2015-03-02 16:14:09 +0100 | [diff] [blame] | 26 | |
Christina Quast | 10b2e5a | 2015-02-25 18:40:15 +0100 | [diff] [blame] | 27 | enum confNum { |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 28 | 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] | 29 | }; |
| 30 | |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 31 | /// CCIDDriverConfiguration Descriptors |
| 32 | /// List of descriptors that make up the configuration descriptors of a |
| 33 | /// device using the CCID driver. |
| 34 | typedef 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 Quast | 4b1e98d | 2015-04-06 23:28:02 +0200 | [diff] [blame] | 50 | extern const USBConfigurationDescriptor *configurationDescriptorsArr[]; |
| 51 | |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 52 | /* Helper functions */ |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 53 | |
Christina Quast | 32906bb | 2015-02-24 11:35:19 +0100 | [diff] [blame] | 54 | // FIXME: static function definitions |
Christina Quast | 566d3f9 | 2015-02-24 17:38:57 +0100 | [diff] [blame] | 55 | extern uint32_t _ISO7816_GetChar( uint8_t *pCharToReceive ); |
| 56 | extern uint32_t _ISO7816_SendChar( uint8_t CharToSend ); |
Christina Quast | 27c643d | 2015-02-24 19:09:08 +0100 | [diff] [blame] | 57 | |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 58 | /* Configure functions */ |
| 59 | extern void Sniffer_configure( void ); |
| 60 | extern void CCID_configure( void ); |
| 61 | extern void Phone_configure( void ); |
| 62 | extern void MITM_configure( void ); |
| 63 | |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 64 | /* Init functions */ |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 65 | extern void Sniffer_init( void ); |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 66 | extern void CCID_init( void ); |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 67 | extern void Phone_init( void ); |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 68 | extern void MITM_init( void ); |
Christina Quast | 27c643d | 2015-02-24 19:09:08 +0100 | [diff] [blame] | 69 | |
Christina Quast | c0aa769 | 2015-02-25 14:02:01 +0100 | [diff] [blame] | 70 | extern void SIMtrace_USB_Initialize( void ); |
Christina Quast | c0aa769 | 2015-02-25 14:02:01 +0100 | [diff] [blame] | 71 | extern void _ISO7816_Init( void ); |
| 72 | |
Christina Quast | 95d6616 | 2015-04-09 22:38:47 +0200 | [diff] [blame] | 73 | /* Exit functions */ |
| 74 | extern void Sniffer_exit( void ); |
| 75 | extern void CCID_exit( void ); |
| 76 | extern void Phone_exit( void ); |
| 77 | extern void MITM_exit( void ); |
| 78 | |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 79 | /* Run functions */ |
| 80 | extern void Sniffer_run( void ); |
Christina Quast | db7b1ab | 2015-03-03 12:34:36 +0100 | [diff] [blame] | 81 | extern void CCID_run( void ); |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 82 | extern void Phone_run( void ); |
| 83 | extern void MITM_run( void ); |
| 84 | |
Christina Quast | 531d10b | 2015-03-19 19:27:04 +0100 | [diff] [blame] | 85 | /* Timer helper function */ |
| 86 | void Timer_Init( void ); |
| 87 | void TC0_Counter_Reset( void ); |
| 88 | |
Christina Quast | 1edf350 | 2015-02-27 13:33:52 +0100 | [diff] [blame] | 89 | #endif /* SIMTRACE_H */ |