Consistent config num enum for main.c and usb.c

This commit is contained in:
Christina Quast 2015-02-25 18:40:15 +01:00
parent 54d0c1fca8
commit 10b2e5accc
3 changed files with 16 additions and 19 deletions

View File

@ -1,6 +1,10 @@
#ifndef SIMTRACE_H #ifndef SIMTRACE_H
#define SIMTRACE_H #define SIMTRACE_H
enum confNum {
CFG_NUM_SNIFF = 1, CFG_NUM_PHONE, CFG_NUM_MITM, NUM_CONF
};
// FIXME: static function definitions // FIXME: static function definitions
extern uint32_t _ISO7816_GetChar( uint8_t *pCharToReceive ); extern uint32_t _ISO7816_GetChar( uint8_t *pCharToReceive );
extern uint32_t _ISO7816_SendChar( uint8_t CharToSend ); extern uint32_t _ISO7816_SendChar( uint8_t CharToSend );

View File

@ -5,20 +5,10 @@
#include "board.h" #include "board.h"
/*------------------------------------------------------------------------------
* Internal definitions
*------------------------------------------------------------------------------*/
#define CONF_NONE 0
#define CONF_SNIFFER 1
#define CONF_CCID_READER 2
#define CONF_SIMCARD_EMUL 3
#define CONF_MITM 4
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Internal variables * Internal variables
*------------------------------------------------------------------------------*/ *------------------------------------------------------------------------------*/
uint8_t simtrace_config = CONF_NONE; uint8_t simtrace_config = 0;
uint8_t conf_changed = 1; uint8_t conf_changed = 1;
uint8_t rcvdChar = 0; uint8_t rcvdChar = 0;
@ -69,9 +59,10 @@ extern int main( void )
/* FIXME: Or should we move the while loop into every case, and break out /* FIXME: Or should we move the while loop into every case, and break out
in case the config changes? */ in case the config changes? */
switch(simtrace_config) { switch(simtrace_config) {
case CONF_SNIFFER: case CFG_NUM_SNIFF:
if (conf_changed) { if (conf_changed) {
Sniffer_Init(); Sniffer_Init();
printf("****+ Changed to CFG_NUM_SNIFF\n\r");
conf_changed = 0; conf_changed = 0;
} else { } else {
if (rcvdChar != 0) { if (rcvdChar != 0) {
@ -80,17 +71,18 @@ extern int main( void )
} }
} }
break; break;
case CONF_CCID_READER: /* case CONF_CCID_READER:
if (conf_changed) { if (conf_changed) {
// Init // Init
conf_changed = 0; conf_changed = 0;
} else { } else {
// Receive char // Receive char
} }
break; break; */
case CONF_SIMCARD_EMUL: case CFG_NUM_PHONE:
if (conf_changed) { if (conf_changed) {
Phone_Master_Init(); Phone_Master_Init();
printf("****+ Changed to CFG_NUM_PHONE\n\r");
conf_changed = 0; conf_changed = 0;
/* Configure ISO7816 driver */ /* Configure ISO7816 driver */
// FIXME: PIO_Configure(pPwr, PIO_LISTSIZE( pPwr )); // FIXME: PIO_Configure(pPwr, PIO_LISTSIZE( pPwr ));
@ -100,8 +92,9 @@ extern int main( void )
// ISO7816_SendChar(char_to_send); // ISO7816_SendChar(char_to_send);
} }
break; break;
case CONF_MITM: case CFG_NUM_MITM:
if (conf_changed) { if (conf_changed) {
printf("****+ Changed to CFG_NUM_MITM\n\r");
// Init // Init
conf_changed = 0; conf_changed = 0;
} else { } else {

View File

@ -171,7 +171,7 @@ const SIMTraceDriverConfigurationDescriptorSniffer configurationDescriptorSniffe
USBGenericDescriptor_CONFIGURATION, USBGenericDescriptor_CONFIGURATION,
sizeof(SIMTraceDriverConfigurationDescriptorSniffer), sizeof(SIMTraceDriverConfigurationDescriptorSniffer),
1, /* There is one interface in this configuration */ 1, /* There is one interface in this configuration */
1, /* This is configuration #1 */ CFG_NUM_SNIFF, /* configuration number */
SNIFFER_CONF_STR, /* string descriptor for this configuration */ SNIFFER_CONF_STR, /* string descriptor for this configuration */
USBD_BMATTRIBUTES, USBD_BMATTRIBUTES,
USBConfigurationDescriptor_POWER(100) USBConfigurationDescriptor_POWER(100)
@ -243,7 +243,7 @@ const SIMTraceDriverConfigurationDescriptorPhone configurationDescriptorPhone =
USBGenericDescriptor_CONFIGURATION, USBGenericDescriptor_CONFIGURATION,
sizeof(SIMTraceDriverConfigurationDescriptorSniffer), sizeof(SIMTraceDriverConfigurationDescriptorSniffer),
1, /* There is one interface in this configuration */ 1, /* There is one interface in this configuration */
2, /* This is configuration #2 */ CFG_NUM_PHONE, /* configuration number */
PHONE_CONF_STR, /* string descriptor for this configuration */ PHONE_CONF_STR, /* string descriptor for this configuration */
USBD_BMATTRIBUTES, USBD_BMATTRIBUTES,
USBConfigurationDescriptor_POWER(100) USBConfigurationDescriptor_POWER(100)
@ -305,7 +305,7 @@ const SIMTraceDriverConfigurationDescriptorMITM configurationDescriptorMITM = {
USBGenericDescriptor_CONFIGURATION, USBGenericDescriptor_CONFIGURATION,
sizeof(SIMTraceDriverConfigurationDescriptorMITM), sizeof(SIMTraceDriverConfigurationDescriptorMITM),
2, /* There are two interfaces in this configuration */ 2, /* There are two interfaces in this configuration */
3, /* This is configuration #3 */ CFG_NUM_MITM, /* configuration number */
MITM_CONF_STR, /* string descriptor for this configuration */ MITM_CONF_STR, /* string descriptor for this configuration */
USBD_BMATTRIBUTES, USBD_BMATTRIBUTES,
USBConfigurationDescriptor_POWER(100) USBConfigurationDescriptor_POWER(100)