FreeCalypso > hg > fc-magnetite
changeset 306:67d1fd7c824c
serialswitch.c: allow enabling SERIAL_DYNAMIC_SWITCH outside of BTEMOBILE
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 02 Nov 2017 05:42:39 +0000 |
parents | 9026fa2630e4 |
children | 6d1eac845d3e |
files | src/cs/drivers/drv_app/uart/serialswitch.c |
diffstat | 1 files changed, 48 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/uart/serialswitch.c Wed Nov 01 23:07:25 2017 +0000 +++ b/src/cs/drivers/drv_app/uart/serialswitch.c Thu Nov 02 05:42:39 2017 +0000 @@ -41,7 +41,7 @@ #include <string.h> /* needed for memcmp & memset */ -#if (defined (BTEMOBILE) && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH #include "ffs/ffs.h" #include "rvf/rvf_api.h" #include "inth/iq.h" @@ -123,7 +123,7 @@ #endif static SYS_UWORD16 serial_cfg = 0x0048; /* All dummies */ -#if (defined BTEMOBILE && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH /* * Global variables used for Dynamic Switch. */ @@ -627,7 +627,7 @@ #endif #endif -#if (defined BTEMOBILE && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH /* * Structure used to store initialization parameters related to the AT-Cmd/F&D flow. * Numbers of paramaters (in case of multiple calls) have been figured out from @@ -714,22 +714,22 @@ #ifdef BTEMOBILE static const t_bt_functions *bt_functions; - - #if (CHIPSET != 12) - static SYS_BOOL uart_fd_initialized = 0; - #endif +#endif + +#ifdef SERIAL_DYNAMIC_SWITCH + static SYS_BOOL uart_fd_initialized = 0; #endif static SYS_UWORD8 fd_buffer[FD_MAX_BUFFER_SIZE]; static SYS_BOOL fd_driver_enabled; -#if (defined BTEMOBILE && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH static t_data_flow data_flow_parameters; #else static SYS_WORD16 bufSize; #endif -#if (defined BTEMOBILE && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH /* * Variables used to count calls to SER_fd_XXX functions. */ @@ -1011,7 +1011,7 @@ static T_FDRET dummy_fd_Init (T_fd_UartId device) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH data_flow_parameters.bufSize = FD_MAX_BUFFER_SIZE; #else bufSize = FD_MAX_BUFFER_SIZE; @@ -1141,7 +1141,7 @@ static T_FDRET dummy_fd_InpAvail (T_fd_UartId device) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH return (data_flow_parameters.bufSize); #else return (bufSize); @@ -1163,7 +1163,7 @@ static T_FDRET dummy_fd_OutpAvail (T_fd_UartId device) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH return (data_flow_parameters.bufSize); #else return (bufSize); @@ -1270,7 +1270,7 @@ SYS_UWORD16 buffer_size[2]; destination[0] = &(fd_buffer[0]); - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH buffer_size[0] = data_flow_parameters.bufSize; #else buffer_size[0] = bufSize; @@ -1278,7 +1278,7 @@ (*writeInFunc) (0, &dummyInstall, 1, &(destination[0]), &(buffer_size[0])); - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH return ((T_FDRET) (data_flow_parameters.bufSize - buffer_size[0])); #else return ((T_FDRET) (bufSize - buffer_size[0])); @@ -1337,7 +1337,7 @@ dummy_fd_GetLineState (T_fd_UartId device, SYS_UWORD32 *state) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH *state = data_flow_parameters.bufSize << RXBLEV; #else *state = bufSize << RXBLEV; @@ -1734,8 +1734,8 @@ SYS_UWORD16 *pt_current_config = &(current_config); /* - * Basic UARTs initializations. - */ + * Basic UARTs initializations. + */ for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { @@ -1743,7 +1743,7 @@ int_uart[uart_id].device_used = 0; int_uart[uart_id].deep_sleep_set_up = 0; } - + #if ((CHIPSET == 2) || (CHIPSET == 3)) uart_spurious_interrupts = 0; #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) @@ -1807,8 +1807,8 @@ } /* - * If not, the default configuration is selected. - */ + * If not, the default configuration is selected. + */ if (!valid_config_selected) { @@ -1856,7 +1856,7 @@ for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { if (!(int_uart[uart_id].device_used)) - initialize_uart_sleep (uart_id); + initialize_uart_sleep (uart_id); else { /* if (int_uart[uart_id].device_used) */ @@ -1937,7 +1937,7 @@ SER_WriteConfig (char *new_config, SYS_BOOL write_to_flash) { -#if (defined BTEMOBILE && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH int uart_id; SYS_BOOL status = 1; @@ -1984,7 +1984,7 @@ SYS_BOOL SER_ImmediateSwitch (void) { -#if (defined BTEMOBILE && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH int uart_id; SYS_BOOL valid_config = 0; T_AppliSerialInfo *serial_info = &appli_ser_cfg_info; @@ -2035,12 +2035,14 @@ serial_cfg = serial_cfg + ((uart_id + 1) << (12 - (4 * SER_BLUETOOTH_HCI))); +#if 0 /* * Check if the Bluetooth HCI flow is enabled on the same UART. */ if (ser_cfg_info[uart_id] == BLUETOOTH_HCI) valid_config = 1; +#endif break; @@ -2049,9 +2051,11 @@ } } +#if 0 if (!valid_config) return (0); /* Bluetooth HCI flow not enabled in the new serial config, or enabled but using a different UART. */ +#endif /* * Finally check if the new serial config is allowed by the application. @@ -2107,7 +2111,9 @@ tr_functions[flow] = &dummy_trace; fd_functions = &dummy_fax_data; - bt_functions = &dummy_bt_hci; + #ifdef BTEMOBILE + bt_functions = &dummy_bt_hci; + #endif rvf_enable (); /* end of the critical section */ @@ -2126,6 +2132,7 @@ uart_fd_initialized = 0; } } +#if 0 else { /* @@ -2137,6 +2144,7 @@ (void) NU_Delete_HISR (&timer_hisr_ctrl_block); } +#endif /* * Initialization of the new flows (Only AT-Cmd/F&D or Riviera/Layer1 Trace) @@ -2169,6 +2177,7 @@ TR_BAUD_CONFIG, rvt_activate_RX_HISR); +#if 0 /* * Create the HISR used to reset and restart the sleep * timer in case of incoming characters on the Trace flow. @@ -2186,6 +2195,7 @@ TIMER_HISR_PRIORITY, &(timer_hisr_stack[0]), TIMER_HISR_STACK_SIZE); +#endif } else /* Other Trace flows are disabled */ initialize_uart_sleep (uart_nb); @@ -2466,14 +2476,14 @@ { T_FDRET status; - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH data_flow_parameters.bufSize = FD_MAX_BUFFER_SIZE; #else bufSize = FD_MAX_BUFFER_SIZE; #endif status = fd_functions->fd_Initialize (fd_functions->device); - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH /* * Check if the UARTFAX driver has actually been initialized. */ @@ -2501,7 +2511,7 @@ T_parity parity) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH if (fd_UAF_SetComPar < 2) { /* @@ -2532,7 +2542,7 @@ SYS_UWORD16 txThreshold) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH if (fd_UAF_SetBuffer < 1) { /* @@ -2562,7 +2572,7 @@ SYS_UWORD8 XOFF) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH if (fd_UAF_SetFlowCtrl < 2) { /* @@ -2591,7 +2601,7 @@ SYS_UWORD16 guardPeriod) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH if (fd_UAF_SetEscape < 2) { /* @@ -2648,7 +2658,7 @@ SYS_UWORD32 state))) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH if (fd_UAF_ReadData < 1) { /* @@ -2680,7 +2690,7 @@ SYS_UWORD16 size[]))) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH if (fd_UAF_WriteData < 1) { /* @@ -2726,7 +2736,7 @@ SYS_UWORD32 mask) { - #if (defined BTEMOBILE && (CHIPSET != 12)) + #ifdef SERIAL_DYNAMIC_SWITCH if (fd_UAF_SetLineState < 4) { /* @@ -2827,12 +2837,12 @@ * being processed. A return is used to simplify the code. */ -#if (defined BTEMOBILE && (CHIPSET != 12)) +#ifdef SERIAL_DYNAMIC_SWITCH if (uart_sleep_timer_enabled || dynamic_switch) #else if (uart_sleep_timer_enabled) #endif - return (0); + return (0); /* * Check if both UARTs are ready to enter Deep Sleep. @@ -2902,7 +2912,7 @@ if ((uart->device_used) && (uart->deep_sleep_set_up)) { - + /* * Check if the specified UART is used by a Trace or * by a Fax & Data flow. @@ -2958,7 +2968,7 @@ /* * Check if the specified UART is actually used, and has not yet - * been waked up. + * been waked up. */ if ((uart->device_used) && @@ -3085,7 +3095,7 @@ it_identified = 1; uart_sleep_timer_enabled = 1; - DISABLE_WAKE_UP_INTERRUPT (uart); + DISABLE_WAKE_UP_INTERRUPT (uart); } uart_id++;