Mercurial > public > ostc4
comparison Small_CPU/Src/externalInterface.c @ 918:f72613a152dd Evo_2_23
Switch external interface tx communication to DMA:
In the previous version the transmitting of data was done in polling mode. With the introduction of new sensors the length of commands send to the sensor may increase and have a impact to the runtim behavior of the SW. To avoid this the DMA transfers for TX has been activated.
author | Ideenmodellierer |
---|---|
date | Sun, 03 Nov 2024 15:40:55 +0100 |
parents | 4832981f9af8 |
children | eb4109d7d1e9 |
comparison
equal
deleted
inserted
replaced
917:0d6c4b40fae4 | 918:f72613a152dd |
---|---|
103 { | 103 { |
104 uint16_t index; | 104 uint16_t index; |
105 uint16_t coeff; | 105 uint16_t coeff; |
106 activeChannel = 0; | 106 activeChannel = 0; |
107 timeoutCnt = 0; | 107 timeoutCnt = 0; |
108 externalInterfacePresent = 0; | |
109 delayAdcConversion = 0; | 108 delayAdcConversion = 0; |
110 if(externalInterface_StartConversion(activeChannel) == HAL_OK) | 109 if(externalInterface_StartConversion(activeChannel) == HAL_OK) |
111 { | 110 { |
112 externalInterfacePresent = 1; | 111 externalInterfacePresent = 1; |
113 global.deviceDataSendToMaster.hw_Info.extADC = 1; | 112 global.deviceDataSendToMaster.hw_Info.extADC = 1; |
130 | 129 |
131 void externalInterface_InitDatastruct(void) | 130 void externalInterface_InitDatastruct(void) |
132 { | 131 { |
133 uint8_t index = 0; | 132 uint8_t index = 0; |
134 /* init data values */ | 133 /* init data values */ |
135 externalV33_On = 0; | |
136 externalADC_On = 0; | |
137 externalUART_Protocol = 0; | 134 externalUART_Protocol = 0; |
138 externalCO2Value = 0; | 135 externalCO2Value = 0; |
139 externalCO2SignalStrength = 0; | 136 externalCO2SignalStrength = 0; |
140 externalCO2Status = 0; | 137 externalCO2Status = 0; |
141 externalCO2Scale = 0.0; | 138 externalCO2Scale = 0.0; |
214 { | 211 { |
215 delayAdcConversion = 1; | 212 delayAdcConversion = 1; |
216 } | 213 } |
217 timeoutCnt = 0; | 214 timeoutCnt = 0; |
218 } | 215 } |
219 | |
220 } | 216 } |
221 if(timeoutCnt++ >= ADC_TIMEOUT) | 217 if(timeoutCnt++ >= ADC_TIMEOUT) |
222 { | 218 { |
223 externalInterface_StartConversion(activeChannel); | 219 externalInterface_StartConversion(activeChannel); |
224 delayAdcConversion = 0; | 220 delayAdcConversion = 0; |
380 { | 376 { |
381 case EXT_INTERFACE_UART_OFF: | 377 case EXT_INTERFACE_UART_OFF: |
382 case EXT_INTERFACE_UART_CO2: | 378 case EXT_INTERFACE_UART_CO2: |
383 case EXT_INTERFACE_UART_O2: | 379 case EXT_INTERFACE_UART_O2: |
384 case EXT_INTERFACE_UART_SENTINEL: | 380 case EXT_INTERFACE_UART_SENTINEL: |
381 case EXT_INTERFACE_UART_GNSS: | |
385 if((externalAutoDetect <= DETECTION_START) | 382 if((externalAutoDetect <= DETECTION_START) |
386 || ((protocol == EXT_INTERFACE_UART_O2) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3)) | 383 || ((protocol == EXT_INTERFACE_UART_O2) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3)) |
387 | 384 |
388 #ifdef ENABLE_CO2_SUPPORT | 385 #ifdef ENABLE_CO2_SUPPORT |
389 || ((externalAutoDetect >= DETECTION_CO2_0) && (externalAutoDetect <= DETECTION_CO2_3)) | 386 || ((externalAutoDetect >= DETECTION_CO2_0) && (externalAutoDetect <= DETECTION_CO2_3)) |
574 | 571 |
575 memset(Mux2ADCMap,0xFF, sizeof(Mux2ADCMap)); | 572 memset(Mux2ADCMap,0xFF, sizeof(Mux2ADCMap)); |
576 | 573 |
577 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) /* Unmap old mirror instances */ | 574 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) /* Unmap old mirror instances */ |
578 { | 575 { |
579 if((pMap[index2] == SENSOR_DIGO2M) || (pMap[index2] == SENSOR_CO2M)) | 576 if((pMap[index2] == SENSOR_DIGO2M) || (pMap[index2] == SENSOR_CO2M) || (pMap[index2] == SENSOR_GNSSM)) |
580 { | 577 { |
581 pMap[index2] = SENSOR_NONE; | 578 pMap[index2] = SENSOR_NONE; |
582 } | 579 } |
583 } | 580 } |
584 | 581 |
585 /* Map Mux O2 sensors to ADC Slot if ADC slot is not in use */ | 582 /* Map Mux O2 sensors to ADC Slot if ADC slot is not in use */ |
586 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT-1; index++) | 583 for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_SENSOR_CNT-1; index++) |
587 { | 584 { |
588 if(pMap[index] == SENSOR_DIGO2) | 585 if(pMap[index] == SENSOR_DIGO2) |
589 { | 586 { |
590 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) | 587 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) |
591 { | 588 { |
596 break; | 593 break; |
597 } | 594 } |
598 } | 595 } |
599 } | 596 } |
600 } | 597 } |
601 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT-1; index++) | 598 for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_SENSOR_CNT-1; index++) |
602 { | 599 { |
603 if(pMap[index] == SENSOR_CO2) | 600 if(pMap[index] == SENSOR_CO2) |
604 { | 601 { |
605 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) | 602 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) |
606 { | 603 { |
611 break; | 608 break; |
612 } | 609 } |
613 } | 610 } |
614 } | 611 } |
615 } | 612 } |
616 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT-1; index++) | 613 for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_SENSOR_CNT-1; index++) |
617 { | 614 { |
618 if(pMap[index] == SENSOR_GNSS) | 615 if(pMap[index] == SENSOR_GNSS) |
619 { | 616 { |
620 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) | 617 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) |
621 { | 618 { |
657 | 654 |
658 void externalInterface_AutodetectSensor() | 655 void externalInterface_AutodetectSensor() |
659 { | 656 { |
660 static uint8_t sensorIndex = 0; | 657 static uint8_t sensorIndex = 0; |
661 static uint8_t uartMuxChannel = 0; | 658 static uint8_t uartMuxChannel = 0; |
659 #ifdef ENABLE_GNSS_SUPPORT | |
660 static uint8_t detectionDelayCnt = 0; | |
661 #endif | |
662 uint8_t index = 0; | 662 uint8_t index = 0; |
663 #ifdef ENABLE_GNSS_SUPPORT | 663 |
664 uint8_t detectionDelayCnt = 0; | |
665 #endif | |
666 uint8_t cntSensor = 0; | 664 uint8_t cntSensor = 0; |
667 uint8_t cntUARTSensor = 0; | 665 uint8_t cntUARTSensor = 0; |
668 #ifdef ENABLE_CO2_SUPPORT | 666 #ifdef ENABLE_CO2_SUPPORT |
669 uint8_t cmdString[10]; | 667 uint8_t cmdString[10]; |
670 uint8_t cmdLength = 0; | 668 uint8_t cmdLength = 0; |
839 | 837 |
840 | 838 |
841 #if defined ENABLE_SENTINEL_MODE || defined ENABLE_GNSS_SUPPORT | 839 #if defined ENABLE_SENTINEL_MODE || defined ENABLE_GNSS_SUPPORT |
842 #ifdef ENABLE_GNSS_SUPPORT | 840 #ifdef ENABLE_GNSS_SUPPORT |
843 externalAutoDetect = DETECTION_GNSS_0; | 841 externalAutoDetect = DETECTION_GNSS_0; |
842 externalInterface_SwitchUART(EXT_INTERFACE_UART_GNSS); | |
844 #else | 843 #else |
845 #ifdef ENABLE_SENTINEL_MODE | 844 #ifdef ENABLE_SENTINEL_MODE |
846 externalAutoDetect = DETECTION_SENTINEL; | 845 externalAutoDetect = DETECTION_SENTINEL; |
847 #endif | 846 #endif |
848 #endif | 847 #endif |
865 tmpSensorMap[uartMuxChannel - 1 + EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE; | 864 tmpSensorMap[uartMuxChannel - 1 + EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE; |
866 uartMuxChannel = 1; | 865 uartMuxChannel = 1; |
867 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_GNSS; | 866 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_GNSS; |
868 externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; | 867 externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; |
869 externalInterface_CheckBaudrate(SENSOR_GNSS); | 868 externalInterface_CheckBaudrate(SENSOR_GNSS); |
870 externalInterfaceMuxReqIntervall = 200; /* iterations needed for module config */ | 869 externalInterfaceMuxReqIntervall = 500; /* iterations needed for module config */ |
871 detectionDelayCnt = 3; | 870 detectionDelayCnt = 6; |
872 // uartGnss_SendCmd(GNSSCMD_MODE_POLL, cmdString, &cmdLength); | |
873 } | 871 } |
874 break; | 872 break; |
875 case DETECTION_GNSS_0: | 873 case DETECTION_GNSS_0: |
876 case DETECTION_GNSS_1: | 874 case DETECTION_GNSS_1: |
877 case DETECTION_GNSS_2: | 875 case DETECTION_GNSS_2: |
1056 index++; | 1054 index++; |
1057 if(index == MAX_MUX_CHANNEL) | 1055 if(index == MAX_MUX_CHANNEL) |
1058 { | 1056 { |
1059 index = 0; | 1057 index = 0; |
1060 } | 1058 } |
1061 if(((pmap[index + EXT_INTERFACE_MUX_OFFSET] == SENSOR_DIGO2) || (pmap[index + EXT_INTERFACE_MUX_OFFSET] == SENSOR_CO2) || (pmap[index + EXT_INTERFACE_MUX_OFFSET] == SENSOR_GNSS)) | 1059 if(((pmap[index + EXT_INTERFACE_MUX_OFFSET] == SENSOR_DIGO2) |
1060 || (pmap[index + EXT_INTERFACE_MUX_OFFSET] == SENSOR_CO2) | |
1061 || (pmap[index + EXT_INTERFACE_MUX_OFFSET] == SENSOR_GNSS)) | |
1062 && (index != activeUartChannel)) | 1062 && (index != activeUartChannel)) |
1063 { | 1063 { |
1064 newChannel = index; | 1064 newChannel = index; |
1065 break; | 1065 break; |
1066 } | 1066 } |
1157 retryRequest = 0; | 1157 retryRequest = 0; |
1158 timeToTrigger = 1; | 1158 timeToTrigger = 1; |
1159 | 1159 |
1160 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ | 1160 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ |
1161 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) | 1161 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) |
1162 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING)) | 1162 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) |
1163 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT)) | |
1163 { | 1164 { |
1164 forceMuxChannel = 1; | 1165 forceMuxChannel = 1; |
1166 externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; | |
1165 switch(pmap[activeSensorId]) | 1167 switch(pmap[activeSensorId]) |
1166 { | 1168 { |
1167 case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); | 1169 case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); |
1168 break; | 1170 break; |
1169 case SENSOR_CO2: externalInterface_SetCO2Value(0.0); | 1171 case SENSOR_CO2: externalInterface_SetCO2Value(0.0); |