comparison Small_CPU/Src/externalInterface.c @ 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 9602a7338f28
children c3dd461ca3f9
comparison
equal deleted inserted replaced
838:aed39d19269c 839:061174d88af9
366 366
367 void externalInterface_SwitchUART(uint8_t protocol) 367 void externalInterface_SwitchUART(uint8_t protocol)
368 { 368 {
369 switch(protocol) 369 switch(protocol)
370 { 370 {
371 case 0: 371 case EXT_INTERFACE_UART_OFF:
372 case (EXT_INTERFACE_UART_CO2 >> 8): 372 case EXT_INTERFACE_UART_CO2:
373 case (EXT_INTERFACE_UART_O2 >> 8): 373 case EXT_INTERFACE_UART_O2:
374 case (EXT_INTERFACE_UART_SENTINEL >> 8): 374 case EXT_INTERFACE_UART_SENTINEL:
375 if((externalAutoDetect <= DETECTION_START) 375 if((externalAutoDetect <= DETECTION_START)
376 || ((protocol == EXT_INTERFACE_UART_O2 >> 8) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3)) 376 || ((protocol == EXT_INTERFACE_UART_O2) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3))
377 377
378 #ifdef ENABLE_CO2_SUPPORT 378 #ifdef ENABLE_CO2_SUPPORT
379 || ((externalAutoDetect >= DETECTION_CO2_0) && (externalAutoDetect <= DETECTION_CO2_3)) 379 || ((externalAutoDetect >= DETECTION_CO2_0) && (externalAutoDetect <= DETECTION_CO2_3))
380 #endif 380 #endif
381 #ifdef ENABLE_SENTINEL_MODE 381 #ifdef ENABLE_SENTINEL_MODE
382 || ((protocol == EXT_INTERFACE_UART_SENTINEL >> 8) && (externalAutoDetect == DETECTION_SENTINEL)) 382 || ((protocol == EXT_INTERFACE_UART_SENTINEL) && (externalAutoDetect == DETECTION_SENTINEL))
383 #endif 383 #endif
384 ) 384 )
385 { 385 {
386 lastSensorDataId = 0; 386 lastSensorDataId = 0;
387 externalUART_Protocol = protocol; 387 externalUART_Protocol = protocol;
649 memset(Mux2ADCMap,0, sizeof(Mux2ADCMap)); 649 memset(Mux2ADCMap,0, sizeof(Mux2ADCMap));
650 650
651 if(externalInterfacePresent) 651 if(externalInterfacePresent)
652 { 652 {
653 externalInterface_SwitchPower33(0); 653 externalInterface_SwitchPower33(0);
654 externalInterface_SwitchUART(0); 654 externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF);
655 for(index = 0; index < MAX_ADC_CHANNEL; index++) 655 for(index = 0; index < MAX_ADC_CHANNEL; index++)
656 { 656 {
657 externalChannel_mV[index] = 0; 657 externalChannel_mV[index] = 0;
658 } 658 }
659 externalAutoDetect = DETECTION_START; 659 externalAutoDetect = DETECTION_START;
684 tmpSensorMap[sensorIndex++] = SENSOR_NONE; 684 tmpSensorMap[sensorIndex++] = SENSOR_NONE;
685 } 685 }
686 } 686 }
687 externalInterfaceMuxReqIntervall = 1100; 687 externalInterfaceMuxReqIntervall = 1100;
688 externalAutoDetect = DETECTION_UARTMUX; 688 externalAutoDetect = DETECTION_UARTMUX;
689 externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8); 689 externalInterface_SwitchUART(EXT_INTERFACE_UART_O2);
690 UART_MUX_SelectAddress(MAX_MUX_CHANNEL); 690 UART_MUX_SelectAddress(MAX_MUX_CHANNEL);
691 uartO2_SetChannel(MAX_MUX_CHANNEL); 691 uartO2_SetChannel(MAX_MUX_CHANNEL);
692 activeUartChannel = MAX_MUX_CHANNEL; 692 activeUartChannel = MAX_MUX_CHANNEL;
693 tmpSensorMap[EXT_INTERFACE_SENSOR_CNT-1] = SENSOR_MUX; 693 tmpSensorMap[EXT_INTERFACE_SENSOR_CNT-1] = SENSOR_MUX;
694 break; 694 break;
705 externalAutoDetect = DETECTION_DIGO2_0; 705 externalAutoDetect = DETECTION_DIGO2_0;
706 uartO2_SetChannel(0); 706 uartO2_SetChannel(0);
707 activeUartChannel = 0; 707 activeUartChannel = 0;
708 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_DIGO2; 708 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_DIGO2;
709 externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; 709 externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT;
710 externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8); 710 externalInterface_SwitchUART(EXT_INTERFACE_UART_O2);
711 if(foundSensorMap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) 711 if(foundSensorMap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX)
712 { 712 {
713 UART_MUX_SelectAddress(0); 713 UART_MUX_SelectAddress(0);
714 } 714 }
715 break; 715 break;
722 foundSensorMap[externalAutoDetect - DETECTION_DIGO2_0 + EXT_INTERFACE_MUX_OFFSET] = SENSOR_DIGO2; 722 foundSensorMap[externalAutoDetect - DETECTION_DIGO2_0 + EXT_INTERFACE_MUX_OFFSET] = SENSOR_DIGO2;
723 } 723 }
724 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE; 724 tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE;
725 if(uartMuxChannel) 725 if(uartMuxChannel)
726 { 726 {
727 externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8); 727 externalInterface_SwitchUART(EXT_INTERFACE_UART_O2);
728 UART_MUX_SelectAddress(uartMuxChannel); 728 UART_MUX_SelectAddress(uartMuxChannel);
729 externalInterface_SensorState[uartMuxChannel + EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; 729 externalInterface_SensorState[uartMuxChannel + EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT;
730 uartO2_SetChannel(uartMuxChannel); 730 uartO2_SetChannel(uartMuxChannel);
731 activeUartChannel = uartMuxChannel; 731 activeUartChannel = uartMuxChannel;
732 tmpSensorMap[uartMuxChannel - 1 + EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE; 732 tmpSensorMap[uartMuxChannel - 1 + EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE;
793 } 793 }
794 #endif 794 #endif
795 #ifdef ENABLE_SENTINEL_MODE 795 #ifdef ENABLE_SENTINEL_MODE
796 if(externalAutoDetect == DETECTION_SENTINEL) 796 if(externalAutoDetect == DETECTION_SENTINEL)
797 { 797 {
798 externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL >> 8); 798 externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL);
799 UART_StartDMA_Receiption(); 799 UART_StartDMA_Receiption();
800 } 800 }
801 break; 801 break;
802 802
803 case DETECTION_SENTINEL: 803 case DETECTION_SENTINEL:
812 } 812 }
813 externalAutoDetect++; 813 externalAutoDetect++;
814 #endif 814 #endif
815 break; 815 break;
816 case DETECTION_DONE: externalAutoDetect = DETECTION_OFF; 816 case DETECTION_DONE: externalAutoDetect = DETECTION_OFF;
817 externalInterface_SwitchUART(0); 817 externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF);
818 activeUartChannel = 0xFF; 818 activeUartChannel = 0xFF;
819 cntSensor = 0; 819 cntSensor = 0;
820 cntUARTSensor = 0; 820 cntUARTSensor = 0;
821 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT-1; index++) 821 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT-1; index++)
822 { 822 {
1075 1075
1076 1076
1077 1077
1078 #if 0 1078 #if 0
1079 #ifdef ENABLE_SENTINEL_MODE 1079 #ifdef ENABLE_SENTINEL_MODE
1080 if(externalInterface_GetUARTProtocol() & (EXT_INTERFACE_UART_SENTINEL >> 8)) 1080 if(externalInterface_GetUARTProtocol() & (EXT_INTERFACE_UART_SENTINEL))
1081 { 1081 {
1082 UART_HandleSentinelData(); 1082 UART_HandleSentinelData();
1083 } 1083 }
1084 #endif 1084 #endif
1085 #endif 1085 #endif