Mercurial > public > ostc4
comparison Small_CPU/Src/externalInterface.c @ 842:c3dd461ca3f9 Evo_2_23
Migrated Sentinel protocol to new UART structure:
The Sentinel protocol had not been migrated to the new UART structure which was introduced with the introduction of the UART MUX. The Sentinel is now supported by autodetection again (development version only)
author | Ideenmodellierer |
---|---|
date | Mon, 15 Jan 2024 21:44:18 +0100 |
parents | 061174d88af9 |
children | ad96f99ebc78 |
comparison
equal
deleted
inserted
replaced
841:70092f552f5a | 842:c3dd461ca3f9 |
---|---|
32 #include "uart.h" | 32 #include "uart.h" |
33 #include "data_exchange.h" | 33 #include "data_exchange.h" |
34 #include "pressure.h" | 34 #include "pressure.h" |
35 #include "uartProtocol_O2.h" | 35 #include "uartProtocol_O2.h" |
36 #include "uartProtocol_Co2.h" | 36 #include "uartProtocol_Co2.h" |
37 #include "uartProtocol_Sentinel.h" | |
37 | 38 |
38 extern SGlobal global; | 39 extern SGlobal global; |
39 extern UART_HandleTypeDef huart1; | 40 extern UART_HandleTypeDef huart1; |
40 | 41 |
41 #define ADC_ANSWER_LENGTH (5u) /* 3424 will provide addr + 4 data bytes */ | 42 #define ADC_ANSWER_LENGTH (5u) /* 3424 will provide addr + 4 data bytes */ |
597 break; | 598 break; |
598 } | 599 } |
599 } | 600 } |
600 } | 601 } |
601 } | 602 } |
603 #ifdef ENABLE_SENTINEL_MODE | |
604 if(pMap[EXT_INTERFACE_MUX_OFFSET] == SENSOR_SENTINEL) | |
605 { | |
606 for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++) | |
607 { | |
608 pMap[index2] = SENSOR_SENTINELM; /* store a mirror instance needed for visualization */ | |
609 Mux2ADCMap[index2] = index2 + EXT_INTERFACE_MUX_OFFSET; | |
610 } | |
611 } | |
612 #endif | |
602 } | 613 } |
603 | 614 |
604 uint8_t* externalInterface_GetSensorMapPointer(uint8_t finalMap) | 615 uint8_t* externalInterface_GetSensorMapPointer(uint8_t finalMap) |
605 { | 616 { |
606 uint8_t* pret; | 617 uint8_t* pret; |
787 externalAutoDetect++; | 798 externalAutoDetect++; |
788 uartMuxChannel++; | 799 uartMuxChannel++; |
789 } | 800 } |
790 else | 801 else |
791 { | 802 { |
803 #ifdef ENABLE_SENTINEL_MODE | |
804 externalAutoDetect = DETECTION_SENTINEL; | |
805 #else | |
792 externalAutoDetect = DETECTION_DONE; | 806 externalAutoDetect = DETECTION_DONE; |
807 #endif | |
793 } | 808 } |
794 #endif | 809 #endif |
795 #ifdef ENABLE_SENTINEL_MODE | 810 #ifdef ENABLE_SENTINEL_MODE |
796 if(externalAutoDetect == DETECTION_SENTINEL) | 811 if(externalAutoDetect == DETECTION_SENTINEL) |
797 { | 812 { |
813 externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; | |
814 uartO2_SetChannel(0); | |
815 activeUartChannel = 0; | |
816 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_SENTINEL; | |
798 externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL); | 817 externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL); |
818 externalInterface_CheckBaudrate(SENSOR_SENTINEL); | |
799 UART_StartDMA_Receiption(); | 819 UART_StartDMA_Receiption(); |
800 } | 820 } |
801 break; | 821 break; |
802 | 822 |
803 case DETECTION_SENTINEL: | 823 case DETECTION_SENTINEL: |
804 case DETECTION_SENTINEL2: | 824 case DETECTION_SENTINEL2: |
805 if(UART_isSentinelConnected()) | 825 if(uartSentinel_isSensorConnected()) |
806 { | 826 { |
807 for(index = 0; index < 3; index++) /* Sentinel is occupiing all sensor slots */ | 827 for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_MUX_OFFSET+3; index++) |
808 { | 828 { |
809 tmpSensorMap[index] = SENSOR_SENTINEL; | 829 foundSensorMap[index] = SENSOR_SENTINEL; |
810 } | 830 } |
811 sensorIndex = 3; | |
812 } | 831 } |
813 externalAutoDetect++; | 832 externalAutoDetect++; |
814 #endif | 833 #endif |
815 break; | 834 break; |
816 case DETECTION_DONE: externalAutoDetect = DETECTION_OFF; | 835 case DETECTION_DONE: externalAutoDetect = DETECTION_OFF; |
827 | 846 |
828 if((foundSensorMap[index] == SENSOR_DIGO2) || (foundSensorMap[index] == SENSOR_CO2)) | 847 if((foundSensorMap[index] == SENSOR_DIGO2) || (foundSensorMap[index] == SENSOR_CO2)) |
829 { | 848 { |
830 cntUARTSensor++; | 849 cntUARTSensor++; |
831 } | 850 } |
851 #ifdef ENABLE_SENTINEL_MODE | |
852 if(foundSensorMap[index] == SENSOR_SENTINEL) /* The Sentinel has a fixed setup */ | |
853 { | |
854 cntSensor = 3; | |
855 cntUARTSensor = 1; | |
856 break; | |
857 } | |
858 #endif | |
832 } | 859 } |
833 externalInface_MapUartToLegacyADC(foundSensorMap); | 860 externalInface_MapUartToLegacyADC(foundSensorMap); |
834 externalInterfaceMuxReqIntervall = 0xFFFF; | 861 externalInterfaceMuxReqIntervall = 0xFFFF; |
835 if(cntSensor == 0) /* return default sensor map if no sensor at all has been detected */ | 862 if(cntSensor == 0) /* return default sensor map if no sensor at all has been detected */ |
836 { | 863 { |
939 { | 966 { |
940 uint32_t newBaudrate = 0; | 967 uint32_t newBaudrate = 0; |
941 | 968 |
942 switch(sensorType) | 969 switch(sensorType) |
943 { | 970 { |
971 case SENSOR_SENTINEL: | |
944 case SENSOR_CO2: newBaudrate = 9600; | 972 case SENSOR_CO2: newBaudrate = 9600; |
945 break; | 973 break; |
946 case SENSOR_DIGO2: | 974 case SENSOR_DIGO2: |
947 default: newBaudrate = 19200; | 975 default: newBaudrate = 19200; |
948 break; | 976 break; |
974 activeUartChannel = ExternalInterface_SelectUsedMuxChannel(0); | 1002 activeUartChannel = ExternalInterface_SelectUsedMuxChannel(0); |
975 uartO2_SetChannel(activeUartChannel); | 1003 uartO2_SetChannel(activeUartChannel); |
976 | 1004 |
977 switch(pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET]) | 1005 switch(pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET]) |
978 { | 1006 { |
1007 case SENSOR_SENTINEL: externalInterface_CheckBaudrate(SENSOR_SENTINEL); | |
1008 break; | |
979 case SENSOR_CO2: externalInterface_CheckBaudrate(SENSOR_CO2); | 1009 case SENSOR_CO2: externalInterface_CheckBaudrate(SENSOR_CO2); |
980 break; | 1010 break; |
981 default: | 1011 default: |
982 case SENSOR_DIGO2: externalInterface_CheckBaudrate(SENSOR_DIGO2); | 1012 case SENSOR_DIGO2: externalInterface_CheckBaudrate(SENSOR_DIGO2); |
983 break; | 1013 break; |
1065 break; | 1095 break; |
1066 #ifdef ENABLE_CO2_SUPPORT | 1096 #ifdef ENABLE_CO2_SUPPORT |
1067 case SENSOR_CO2: uartCo2_Control(); | 1097 case SENSOR_CO2: uartCo2_Control(); |
1068 break; | 1098 break; |
1069 #endif | 1099 #endif |
1100 #ifdef ENABLE_SENTINEL_MODE | |
1101 case SENSOR_SENTINEL: uartSentinel_Control(); | |
1102 break; | |
1103 #endif | |
1070 default: | 1104 default: |
1071 break; | 1105 break; |
1072 } | 1106 } |
1073 } | 1107 } |
1074 } | 1108 } |