Mercurial > public > ostc4
comparison Small_CPU/Src/externalInterface.c @ 932:effadaa3a1f7 Evo_2_23
Cleanup Gnss UART implementation:
The first draft of the internal UART implementation was just a copy of the external UART handling. To avoid duplicated code and maintainance issue both UARTs (external/internal 6/1) share the same functions. To enable this a control structure has to be used as function input which defines the none shared resources like DMA control and rx/tx buffers
author | Ideenmodellierer |
---|---|
date | Sat, 07 Dec 2024 21:28:08 +0100 |
parents | eb4109d7d1e9 |
children |
comparison
equal
deleted
inserted
replaced
931:5a9bc2e6112d | 932:effadaa3a1f7 |
---|---|
37 #include "uartProtocol_Sentinel.h" | 37 #include "uartProtocol_Sentinel.h" |
38 #include "uartProtocol_GNSS.h" | 38 #include "uartProtocol_GNSS.h" |
39 | 39 |
40 extern SGlobal global; | 40 extern SGlobal global; |
41 extern UART_HandleTypeDef huart1; | 41 extern UART_HandleTypeDef huart1; |
42 extern sUartComCtrl Uart1Ctrl; | |
42 | 43 |
43 #define ADC_ANSWER_LENGTH (5u) /* 3424 will provide addr + 4 data bytes */ | 44 #define ADC_ANSWER_LENGTH (5u) /* 3424 will provide addr + 4 data bytes */ |
44 #define ADC_TIMEOUT (10u) /* conversion stuck for unknown reason => restart */ | 45 #define ADC_TIMEOUT (10u) /* conversion stuck for unknown reason => restart */ |
45 #define ADC_REF_VOLTAGE_MV (2048.0f) /* reference voltage of MPC3424*/ | 46 #define ADC_REF_VOLTAGE_MV (2048.0f) /* reference voltage of MPC3424*/ |
46 #define ADC_CYCLE_INTERVAL_MS (1000u) /* start adc read out once per second*/ | 47 #define ADC_CYCLE_INTERVAL_MS (1000u) /* start adc read out once per second*/ |
934 uartO2_SetChannel(0); | 935 uartO2_SetChannel(0); |
935 activeUartChannel = 0; | 936 activeUartChannel = 0; |
936 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_SENTINEL; | 937 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_SENTINEL; |
937 externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL); | 938 externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL); |
938 externalInterface_CheckBaudrate(SENSOR_SENTINEL); | 939 externalInterface_CheckBaudrate(SENSOR_SENTINEL); |
939 UART_StartDMA_Receiption(); | 940 UART_StartDMA_Receiption(&Uart1Ctrl); |
940 } | 941 } |
941 break; | 942 break; |
942 | 943 |
943 case DETECTION_SENTINEL: | 944 case DETECTION_SENTINEL: |
944 case DETECTION_SENTINEL2: | 945 case DETECTION_SENTINEL2: |
1142 } | 1143 } |
1143 | 1144 |
1144 if(externalInterface_SensorState[activeSensorId] != UART_COMMON_INIT) | 1145 if(externalInterface_SensorState[activeSensorId] != UART_COMMON_INIT) |
1145 { | 1146 { |
1146 UART_ReadData(pmap[activeSensorId]); | 1147 UART_ReadData(pmap[activeSensorId]); |
1147 UART_WriteData(); | 1148 UART_WriteData(&Uart1Ctrl); |
1148 } | 1149 } |
1149 if(externalInterface_SensorState[activeSensorId] == UART_COMMON_INIT) | 1150 if(externalInterface_SensorState[activeSensorId] == UART_COMMON_INIT) |
1150 { | 1151 { |
1151 lastRequestTick = tick; | 1152 lastRequestTick = tick; |
1152 TriggerTick = tick - 10; /* just to make sure control is triggered */ | 1153 TriggerTick = tick - 10; /* just to make sure control is triggered */ |
1173 timeToTrigger = 1; | 1174 timeToTrigger = 1; |
1174 | 1175 |
1175 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ | 1176 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ |
1176 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) | 1177 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) |
1177 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) | 1178 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) |
1178 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT)) | 1179 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT) |
1180 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_SAT)) | |
1179 { | 1181 { |
1180 forceMuxChannel = 1; | 1182 forceMuxChannel = 1; |
1181 externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; | 1183 externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; |
1182 switch(pmap[activeSensorId]) | 1184 switch(pmap[activeSensorId]) |
1183 { | 1185 { |