Mercurial > public > ostc4
changeset 839:061174d88af9 Evo_2_23
Code cleanup: UART protocol definitions
In the first external interface implementation the discovery part took care for the uart protocol selection. Since the introduction of the automatic detection the protocol handling has been moved into the RTE. However the definitions were still in the in the exchange header (Discovery <=> RTE). To avoid confusions the definitions have been moved into RTE scope only.
author | Ideenmodellierer |
---|---|
date | Sun, 07 Jan 2024 21:20:15 +0100 |
parents | aed39d19269c |
children | 7e714662b93f |
files | Common/Inc/data_exchange.h Discovery/Src/data_exchange_main.c Small_CPU/Inc/externalInterface.h Small_CPU/Src/baseCPU2.c Small_CPU/Src/externalInterface.c |
diffstat | 5 files changed, 26 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/data_exchange.h Fri Jan 05 16:01:22 2024 +0100 +++ b/Common/Inc/data_exchange.h Sun Jan 07 21:20:15 2024 +0100 @@ -38,10 +38,6 @@ /* 4th nibble command channel */ #define EXT_INTERFACE_33V_ON (0x8000u) /* Bit set to enable 3.3V power interface */ #define EXT_INTERFACE_ADC_ON (0x4000u) /* Bit set to enable ADC conversion */ -#define EXT_INTERFACE_UART_MASK (0x0700u) /* Reserve 3 bits for UART protocol selection */ -#define EXT_INTERFACE_UART_CO2 (0x0100u) /* Activate protocol for CO2 sensor */ -#define EXT_INTERFACE_UART_SENTINEL (0x0200u) /* Activate Sentinel Backup monitor protocol */ -#define EXT_INTERFACE_UART_O2 (0x0400u) /* Activate digital o2 sensor protocol (DiveO2) */ /* Command subset */ #define EXT_INTERFACE_AUTODETECT (0x0001u) /* Start auto detection of connected sensors */
--- a/Discovery/Src/data_exchange_main.c Fri Jan 05 16:01:22 2024 +0100 +++ b/Discovery/Src/data_exchange_main.c Sun Jan 07 21:20:15 2024 +0100 @@ -423,13 +423,9 @@ { externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON; } - if(SensorActive[SENSOR_DIGO2]) + if((SensorActive[SENSOR_DIGO2]) || (SensorActive[SENSOR_CO2])) { - externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_O2; - } - else if(SensorActive[SENSOR_CO2]) /* TODO: at the moment only one serial sensor is supported => else condition. to be changed once multiplexing is available */ - { - externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_CO2; /* CO2 sensor has to be activated via auto detection */ + externalInterface_Cmd |= EXT_INTERFACE_33V_ON; } #ifdef ENABLE_SENTINEL_MODE
--- a/Small_CPU/Inc/externalInterface.h Fri Jan 05 16:01:22 2024 +0100 +++ b/Small_CPU/Inc/externalInterface.h Sun Jan 07 21:20:15 2024 +0100 @@ -43,6 +43,16 @@ #define COMMON_SENSOR_STATE_INIT (0x0u) /* All individual state definitions shall start with a INIT state = 0 */ #define COMMON_SENSOR_STATE_INVALID (0xFFu) /* All individual state definitions shall not use 0xFF for operation control */ + +enum /* Definitions for supported UART protocols */ +{ + EXT_INTERFACE_UART_OFF = 0, + EXT_INTERFACE_UART_CO2, + EXT_INTERFACE_UART_SENTINEL, + EXT_INTERFACE_UART_O2 +}; + + typedef enum { DETECTION_OFF = 0, /* no detection requested */
--- a/Small_CPU/Src/baseCPU2.c Fri Jan 05 16:01:22 2024 +0100 +++ b/Small_CPU/Src/baseCPU2.c Sun Jan 07 21:20:15 2024 +0100 @@ -494,7 +494,7 @@ */ EXTI_Test_Button_DeInit(); - externalInterface_SwitchUART(0); + externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF); externalInterface_SwitchPower33(false); if (hasExternalClock()) SystemClock_Config_HSI();
--- a/Small_CPU/Src/externalInterface.c Fri Jan 05 16:01:22 2024 +0100 +++ b/Small_CPU/Src/externalInterface.c Sun Jan 07 21:20:15 2024 +0100 @@ -368,18 +368,18 @@ { switch(protocol) { - case 0: - case (EXT_INTERFACE_UART_CO2 >> 8): - case (EXT_INTERFACE_UART_O2 >> 8): - case (EXT_INTERFACE_UART_SENTINEL >> 8): + case EXT_INTERFACE_UART_OFF: + case EXT_INTERFACE_UART_CO2: + case EXT_INTERFACE_UART_O2: + case EXT_INTERFACE_UART_SENTINEL: if((externalAutoDetect <= DETECTION_START) - || ((protocol == EXT_INTERFACE_UART_O2 >> 8) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3)) + || ((protocol == EXT_INTERFACE_UART_O2) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3)) #ifdef ENABLE_CO2_SUPPORT || ((externalAutoDetect >= DETECTION_CO2_0) && (externalAutoDetect <= DETECTION_CO2_3)) #endif #ifdef ENABLE_SENTINEL_MODE - || ((protocol == EXT_INTERFACE_UART_SENTINEL >> 8) && (externalAutoDetect == DETECTION_SENTINEL)) + || ((protocol == EXT_INTERFACE_UART_SENTINEL) && (externalAutoDetect == DETECTION_SENTINEL)) #endif ) { @@ -651,7 +651,7 @@ if(externalInterfacePresent) { externalInterface_SwitchPower33(0); - externalInterface_SwitchUART(0); + externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF); for(index = 0; index < MAX_ADC_CHANNEL; index++) { externalChannel_mV[index] = 0; @@ -686,7 +686,7 @@ } externalInterfaceMuxReqIntervall = 1100; externalAutoDetect = DETECTION_UARTMUX; - externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8); + externalInterface_SwitchUART(EXT_INTERFACE_UART_O2); UART_MUX_SelectAddress(MAX_MUX_CHANNEL); uartO2_SetChannel(MAX_MUX_CHANNEL); activeUartChannel = MAX_MUX_CHANNEL; @@ -707,7 +707,7 @@ activeUartChannel = 0; tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_DIGO2; externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; - externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8); + externalInterface_SwitchUART(EXT_INTERFACE_UART_O2); if(foundSensorMap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) { UART_MUX_SelectAddress(0); @@ -724,7 +724,7 @@ tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE; if(uartMuxChannel) { - externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8); + externalInterface_SwitchUART(EXT_INTERFACE_UART_O2); UART_MUX_SelectAddress(uartMuxChannel); externalInterface_SensorState[uartMuxChannel + EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; uartO2_SetChannel(uartMuxChannel); @@ -795,7 +795,7 @@ #ifdef ENABLE_SENTINEL_MODE if(externalAutoDetect == DETECTION_SENTINEL) { - externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL >> 8); + externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL); UART_StartDMA_Receiption(); } break; @@ -814,7 +814,7 @@ #endif break; case DETECTION_DONE: externalAutoDetect = DETECTION_OFF; - externalInterface_SwitchUART(0); + externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF); activeUartChannel = 0xFF; cntSensor = 0; cntUARTSensor = 0; @@ -1077,7 +1077,7 @@ #if 0 #ifdef ENABLE_SENTINEL_MODE - if(externalInterface_GetUARTProtocol() & (EXT_INTERFACE_UART_SENTINEL >> 8)) + if(externalInterface_GetUARTProtocol() & (EXT_INTERFACE_UART_SENTINEL)) { UART_HandleSentinelData(); }