Pārlūkot izejas kodu

DL High Low 둘다 Alarm 울리도록 수정 ,Req Data 320Byte 전송 하도록 수정

PYJ 5 gadi atpakaļ
vecāks
revīzija
d33259ede3

+ 18 - 4
Bluecell_Inc/Bluecell_operate.h

@@ -705,11 +705,11 @@ typedef struct{
705 705
     uint8_t DLI_Level_High_Low_Threshold_default;
706 706
     uint8_t ALARM_TEMP_HIGH; //bit
707 707
     uint8_t ALARM_DLI_Level;
708
-    uint8_t ALARM_DLI_AGC_SHTUTDOWN;
708
+    uint8_t ALARM_DLI_SHTUTDOWN;
709 709
     uint8_t ALARM_DLI_AGC_Alarm;
710 710
     uint8_t ALARM_ULO_ALC_Alarm;    
711 711
     uint8_t ALARM_ULO_Level;
712
-    uint8_t ALARM_ULO_ALC_SHTUTDOWN;
712
+    uint8_t ALARM_ULO_SHTUTDOWN;
713 713
     uint8_t ALARM_MASK1;
714 714
     uint8_t ALARM_TESTMODE;
715 715
     uint8_t ALARM_Test_Dummy1;
@@ -836,8 +836,8 @@ typedef struct{
836 836
     uint8_t Reserve3;
837 837
     uint8_t Reserve4;
838 838
     uint8_t Reserve5;
839
-    uint8_t Reserve6;
840
-    uint8_t bluecell_crc;
839
+    uint8_t bluecell_crc_H;
840
+    uint8_t bluecell_crc_L;
841 841
     uint8_t bluecell_etx;
842 842
 
843 843
 }BLUESTATUS_st;
@@ -1118,6 +1118,20 @@ typedef enum{
1118 1118
     DET_Alarm_UL4_Index,
1119 1119
     DET_Alarm_UL_Index_MAX,
1120 1120
 };
1121
+typedef enum{
1122
+    DET_Alarm_DL1_Shutdown_Index = 0,
1123
+    DET_Alarm_DL2_Shutdown_Index,
1124
+    DET_Alarm_DL3_Shutdown_Index,
1125
+    DET_Alarm_DL4_Shutdown_Index,
1126
+    DET_Alarm_DL_Shutdown_Index_MAX,
1127
+};
1128
+typedef enum{
1129
+    DET_Alarm_UL1_Shutdown_Index = 0,
1130
+    DET_Alarm_UL2_Shutdown_Index,
1131
+    DET_Alarm_UL3_Shutdown_Index,
1132
+    DET_Alarm_UL4_Shutdown_Index,
1133
+    DET_Alarm_UL_Shutdown_Index_MAX,
1134
+};
1121 1135
 #define ADC1_EA Bluecell_ADC1_MaxLength /2
1122 1136
 #define ADC3_EA Bluecell_ADC3_MaxLength /2
1123 1137
 

+ 3 - 2
Bluecell_Inc/CRC.h

@@ -16,8 +16,9 @@ typedef enum{
16 16
 }etError;
17 17
 
18 18
 
19
-uint16_t CRC16_Generate(uint8_t *buf_ptr, int32_t len);
20
-etError CRC16_Check(uint8_t *buf_ptr, int32_t len,uint16_t checksum);
19
+uint16_t CRC16_Generate(uint8_t* buf_ptr, int len);
20
+etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum);
21
+
21 22
 
22 23
 uint8_t STH30_CreateCrc(uint8_t *data, uint8_t nbrOfBytes);
23 24
 etError STH30_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum);

+ 1 - 1
Bluecell_Inc/uart.h

@@ -35,7 +35,7 @@ void InitUartQueue(pUARTQUEUE pQueue);
35 35
 void GetDataFromUartQueue(UART_HandleTypeDef *huart);
36 36
 bool Get_UartRcv(void);
37 37
 void Set_UartRcv(bool);
38
-void Uart1_Data_Send(uint8_t* data,uint8_t size);
38
+void Uart1_Data_Send(uint8_t* data,uint16_t size);
39 39
 void Uart_Check(void);
40 40
 
41 41
 #endif /* UART_H_ */

+ 208 - 28
Bluecell_Src/Bluecell_operate.c

@@ -13,7 +13,7 @@
13 13
 /***************************************************************************************/
14 14
 
15 15
 extern void PE43711_atten_ctrl(PE43711_st ATT ,uint8_t data);
16
-extern void Uart1_Data_Send(uint8_t* data,uint8_t size);
16
+extern void Uart1_Data_Send(uint8_t* data,uint16_t size);
17 17
 extern HAL_StatusTypeDef EEPROM_M24C08_Zerowrite(uint8_t devid,uint16_t Address);
18 18
 /***************************************************************************************/
19 19
 /*                                  Extern Valuable                                    */
@@ -1469,9 +1469,13 @@ bool Bluecell_Operate(uint8_t* data){
1469 1469
     case ATT_TableGet:
1470 1470
         Bluecell_TableLoad(data, data[BLUECELL_DATA]);
1471 1471
         data[BLUECELL_TYPE] = ATT_TableGet;
1472
-        data[data[BLUECELL_LENGTH] + 1] = STH30_CreateCrc(&data[BLUECELL_TYPE], data[BLUECELL_LENGTH]);
1473
-        Bluecell_StructCpy(&Txdata[0],&data[0],data[BLUECELL_LENGTH] + 3);
1474
-        Uart1_Data_Send(&Txdata[0], Txdata[BLUECELL_LENGTH] + 3);
1472
+
1473
+        data[data[BLUECELL_LENGTH] + 1] = ((CRC16_Generate(&data[BLUECELL_TYPE], data[BLUECELL_LENGTH]) & 0xFF00) >> 8);
1474
+        data[data[BLUECELL_LENGTH] + 2] = CRC16_Generate(&data[BLUECELL_TYPE], data[BLUECELL_LENGTH]) & 0x00FF;        
1475
+        data[data[BLUECELL_LENGTH] + 3] = 0xEB;
1476
+        
1477
+        Bluecell_StructCpy(&Txdata[0],&data[0],data[BLUECELL_LENGTH] + 4);
1478
+        Uart1_Data_Send(&Txdata[0], Txdata[BLUECELL_LENGTH] + 4);
1475 1479
 #if 0 // PYJ.2020.04.22_BEGIN -- 
1476 1480
         for(int i = 0 ; i < data[BLUECELL_LENGTH] + 3; i++ ){
1477 1481
 //            printf("%x ",data[i]);
@@ -1482,16 +1486,25 @@ bool Bluecell_Operate(uint8_t* data){
1482 1486
         break;
1483 1487
     case Bluecell_StatusReq:
1484 1488
         DataStatusSet();
1489
+#if 0 // PYJ.2020.05.28_BEGIN -- 
1485 1490
         Bluecell_StructCpy(&Txdata[0],&bluecell_Currdatastatus.bluecell_header,94);
1486 1491
         Txdata[BLUECELL_LENGTH] = 94 - 3;//sizeof(BLUESTATUS_st) - 3;
1487 1492
         Txdata[94 - 2] = STH30_CreateCrc(&Txdata[BLUECELL_TYPE], Txdata[BLUECELL_LENGTH]);
1493
+#else        
1494
+        Bluecell_StructCpy(&Txdata[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
1495
+        Txdata[BLUECELL_LENGTH] = sizeof(BLUESTATUS_st) - 3;//sizeof(BLUESTATUS_st) - 3;
1496
+//        Txdata[sizeof(BLUESTATUS_st) - 2] = STH30_CreateCrc(&Txdata[BLUECELL_TYPE], Txdata[BLUECELL_LENGTH]);
1497
+        Txdata[sizeof(BLUESTATUS_st) - 3] = ((CRC16_Generate(&data[BLUECELL_TYPE], data[BLUECELL_LENGTH]) & 0xFF00) >> 8);
1498
+        Txdata[sizeof(BLUESTATUS_st) - 2] = CRC16_Generate(&data[BLUECELL_TYPE], data[BLUECELL_LENGTH]) & 0x00FF;        
1499
+        
1500
+#endif // PYJ.2020.05.28_END -- 
1488 1501
 #if 0 // PYJ.2020.04.22_BEGIN -- 
1489 1502
         for(int i = 0 ; i < sizeof(BLUESTATUS_st); i++ ){
1490 1503
             printf("%x ",Txdata[i]);
1491 1504
         }
1492 1505
         printf("\r\n");
1493 1506
 #endif // PYJ.2020.04.22_END --    
1494
-        Uart1_Data_Send(&Txdata[0], 94);
1507
+        Uart1_Data_Send(&Txdata[0], sizeof(BLUESTATUS_st));
1495 1508
         break;
1496 1509
     case Bluecell_StatusSave:
1497 1510
 //        printf("Copy Complete");
@@ -1596,8 +1609,8 @@ bool Bluecell_Operate(uint8_t* data){
1596 1609
         bluecell_Currdatastatus.DLI_Shutdown_Threshold_L = data[BLUECELL_DATA + i++];
1597 1610
         tempdata = (( bluecell_Currdatastatus.DLI_Shutdown_Threshold_H << 8) & 0xFF00) ;
1598 1611
         tempdata +=  bluecell_Currdatastatus.DLI_Shutdown_Threshold_L ;
1599
-//        tempdata /= 10;
1600
-//        printf("tempdata : %d\r\n",tempdata);
1612
+        tempdata /= 10;
1613
+        printf("tempdata : %d\r\n",tempdata);
1601 1614
 //        bluecell_Currdatastatus.DLI_Shutdown_Threshold_H = ((tempdata & 0xFF00) >> 8);
1602 1615
 //        bluecell_Currdatastatus.DLI_Shutdown_Threshold_L = (tempdata & 0x00FF);
1603 1616
 //        printf("tempdata %d \r\n",tempdata);
@@ -1656,7 +1669,11 @@ bool Bluecell_Operate(uint8_t* data){
1656 1669
         break;
1657 1670
     case Bluecell_Temp_High_Threshold                     :   
1658 1671
         bluecell_Currdatastatus.Temp_High_Threshold = data[BLUECELL_DATA + i++];
1659
-        printf("%s : %d \r\n",__func__,__LINE__);
1672
+        printf("%s : %d Temps_High_Threshold :  %d\r\n",__func__,__LINE__,bluecell_Currdatastatus.Temp_High_Threshold);
1673
+        printf("Temp_High_Threshold : %d :   Det %d \r\n",bluecell_Currdatastatus.Temp_High_Threshold,bluecell_Currdatastatus.DET_TEMP);
1674
+        printf("Temp_High_Alarm : %d \r\n",bluecell_Currdatastatus.Temp_High_Alarm);
1675
+        printf("Txdata : %d \r\n",Txdata[201]);
1676
+    
1660 1677
         break;
1661 1678
     case Bluecell_Temp_High_Threshold_Default             :   
1662 1679
         bluecell_Currdatastatus.Temp_High_Threshold_Default = data[BLUECELL_DATA + i++];
@@ -1715,8 +1732,8 @@ bool Bluecell_Operate(uint8_t* data){
1715 1732
         bluecell_Currdatastatus.ULO_Shutdown_Threshold_L = data[BLUECELL_DATA + i++];
1716 1733
         tempdata = (( bluecell_Currdatastatus.ULO_Shutdown_Threshold_H << 8) & 0xFF00) ;
1717 1734
         tempdata +=  bluecell_Currdatastatus.ULO_Shutdown_Threshold_L ;
1718
-//        tempdata /= 10;
1719
-//        printf("tempdata : %d\r\n",tempdata);
1735
+        tempdata /= 10;
1736
+        printf("tempdata : %d\r\n",tempdata);
1720 1737
 //        bluecell_Currdatastatus.ULO_Shutdown_Threshold_H = ((tempdata & 0xFF00) >> 8);
1721 1738
 //        bluecell_Currdatastatus.ULO_Shutdown_Threshold_L = (tempdata & 0x00FF);     
1722 1739
 
@@ -1732,7 +1749,7 @@ bool Bluecell_Operate(uint8_t* data){
1732 1749
     case Bluecell_ULO_Shutdown_Retry_Count                :   
1733 1750
         break;
1734 1751
     case Bluecell_Alarm_Mask:
1735
-        bluecell_Currdatastatus.ALARM_MASK1 = data[BLUECELL_DATA + i+ 1];
1752
+        bluecell_Currdatastatus.ALARM_MASK1 = (data[BLUECELL_DATA + i+ 1] / 10);
1736 1753
          printf("%s : %d   ALARM_MASK1 : %d \r\n",__func__,__LINE__,bluecell_Currdatastatus.ALARM_MASK1);
1737 1754
         break;
1738 1755
   }
@@ -1901,9 +1918,9 @@ bool MBIC_Operate(uint8_t* data){
1901 1918
         /*ALARM BIT LIST*/
1902 1919
         data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_TEMP_HIGH;
1903 1920
         data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_DLI_Level;
1904
-        data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_DLI_AGC_SHTUTDOWN;
1921
+        data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN;
1905 1922
         data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_ULO_Level;
1906
-        data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_ULO_ALC_SHTUTDOWN;
1923
+        data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN;
1907 1924
         /*ALARM BIT LIST*/
1908 1925
 
1909 1926
         data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_MASK1;
@@ -2790,8 +2807,13 @@ uint32_t SumFunc(uint16_t* data,uint16_t size){
2790 2807
 
2791 2808
 
2792 2809
 
2793
-bool ADC_Alarm_DL_Set[DET_Alarm_DL_Index_MAX] = {false,} ;
2810
+bool ADC_Alarm_DL_High_Set[DET_Alarm_DL_Index_MAX] = {false,} ;
2811
+bool ADC_Alarm_DL_Low_Set[DET_Alarm_DL_Index_MAX] = {false,} ;
2812
+
2794 2813
 bool ADC_Alarm_UL_Set[DET_Alarm_UL_Index_MAX] = {false,} ;
2814
+bool ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL_Shutdown_Index_MAX] = {false,} ;
2815
+bool ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL_Shutdown_Index_MAX] = {false,} ;
2816
+
2795 2817
 void DET_LevelAlarmCheck(){
2796 2818
     int16_t DL[DET_Alarm_DL_Index_MAX] = {0,};
2797 2819
     int16_t UL[DET_Alarm_UL_Index_MAX] = {0,};
@@ -2799,14 +2821,24 @@ void DET_LevelAlarmCheck(){
2799 2821
     
2800 2822
     int16_t LimitData_DL_High = 0;    
2801 2823
     int16_t LimitData_DL_Low = 0;    
2824
+
2825
+
2826
+    int16_t LimitData_DL_Shutdown = 0;    
2827
+    int16_t LimitData_UL_Shutdown = 0;    
2828
+    
2802 2829
     double ret = 0;
2803 2830
     int8_t Res_DL_dBm[DET_Alarm_DL_Index_MAX] = {0,};
2804 2831
     int8_t Res_UL_dBm[DET_Alarm_UL_Index_MAX] = {0,};    
2805 2832
     
2806 2833
 
2807 2834
     LimitData_UL_High = ConvertTo2byte(bluecell_Currdatastatus.ULO_Level_High_Threshold_H,bluecell_Currdatastatus.ULO_Level_High_Threshold_L) / 10;
2835
+
2808 2836
     LimitData_DL_High = ConvertTo2byte(bluecell_Currdatastatus.DLI_Level_High_Threshold_H,bluecell_Currdatastatus.DLI_Level_High_Threshold_L)/ 10;
2809 2837
     LimitData_DL_Low = ConvertTo2byte(bluecell_Currdatastatus.DLI_Level_Low_Threshold_H,bluecell_Currdatastatus.DLI_Level_Low_Threshold_L)/ 10;
2838
+
2839
+    LimitData_DL_Shutdown = ConvertTo2byte(bluecell_Currdatastatus.DLI_Shutdown_Threshold_H,bluecell_Currdatastatus.DLI_Shutdown_Threshold_L)/ 10;
2840
+    LimitData_UL_Shutdown = ConvertTo2byte(bluecell_Currdatastatus.ULO_Shutdown_Threshold_H,bluecell_Currdatastatus.ULO_Shutdown_Threshold_L)/ 10;
2841
+    
2810 2842
     DL[DET_Alarm_DL1_Index] = ConvertTo2byte(bluecell_Currdatastatus.DLI_Level1_H,bluecell_Currdatastatus.DLI_Level1_L);
2811 2843
     DL[DET_Alarm_DL2_Index] = ConvertTo2byte(bluecell_Currdatastatus.DLI_Level2_H,bluecell_Currdatastatus.DLI_Level2_L);
2812 2844
     DL[DET_Alarm_DL3_Index] = ConvertTo2byte(bluecell_Currdatastatus.DLI_Level3_H,bluecell_Currdatastatus.DLI_Level3_L);
@@ -2879,6 +2911,9 @@ void DET_LevelAlarmCheck(){
2879 2911
 
2880 2912
 //    printf("LimitData_DL_High : %d \r\n",LimitData_DL_High);    
2881 2913
 //    printf("LimitData_DL_Low : %d \r\n",LimitData_DL_Low);   
2914
+    /*
2915
+        UL Level Alarm Check Part
2916
+    */
2882 2917
     for(int i = 0 ; i < DET_Alarm_UL_Index_MAX; i++){
2883 2918
         if(LimitData_UL_High > Res_UL_dBm[DET_Alarm_UL1_Index + i]){
2884 2919
             ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = true;
@@ -2889,16 +2924,45 @@ void DET_LevelAlarmCheck(){
2889 2924
 //            printf("ADC_Alarm_UL_Set %d ,Value : %d\r\n",DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] );            
2890 2925
         }
2891 2926
     }
2892
-#if 1 // PYJ.2020.05.27_BEGIN -- 
2927
+    /*
2928
+        DL Level Alarm Check Part
2929
+    */
2893 2930
     for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
2894
-        if(LimitData_DL_High > Res_DL_dBm[DET_Alarm_DL1_Index + i]
2895
-         &&LimitData_DL_Low < Res_DL_dBm[DET_Alarm_DL1_Index + i])
2896
-            ADC_Alarm_DL_Set[DET_Alarm_DL1_Index + i] = true;
2931
+        if(LimitData_DL_High > Res_DL_dBm[DET_Alarm_DL1_Index + i])
2932
+            ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = true;
2897 2933
         else
2898
-            ADC_Alarm_DL_Set[DET_Alarm_DL1_Index + i] = false;
2934
+            ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
2899 2935
     }    
2900
-//    HAL_Delay(1000);
2901
-#endif // PYJ.2020.05.27_END -- 
2936
+    
2937
+    for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
2938
+        if(LimitData_DL_Low < Res_DL_dBm[DET_Alarm_DL1_Index + i])
2939
+            ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
2940
+        else
2941
+            ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
2942
+    }       
2943
+    /*
2944
+        DL Shutdown Alarm Check Part
2945
+    */
2946
+
2947
+    for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
2948
+        if(LimitData_DL_Shutdown < Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
2949
+            ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
2950
+        else
2951
+            ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
2952
+    }  
2953
+    
2954
+    /*
2955
+        UL Shutdown Alarm Check Part
2956
+    */
2957
+    for(int i = 0 ; i < DET_Alarm_UL_Shutdown_Index_MAX; i++){
2958
+        if(LimitData_UL_Shutdown < Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i]){
2959
+            ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = true;
2960
+        }
2961
+        else{
2962
+            ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
2963
+        }
2964
+    }
2965
+
2902 2966
 }
2903 2967
 void ADC_Check(void){
2904 2968
     //static uint8_t Cnt = 0;
@@ -3850,11 +3914,12 @@ void Alarm_Check(){
3850 3914
 
3851 3915
     if(bluecell_Currdatastatus.ALARM_TEMP_HIGH             > 0 
3852 3916
     || bluecell_Currdatastatus.ALARM_DLI_Level             > 0
3853
-    || bluecell_Currdatastatus.ALARM_DLI_AGC_SHTUTDOWN     > 0
3917
+    || bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN         > 0
3854 3918
     || bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm         > 0
3855 3919
     || bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm         > 0
3856 3920
     || bluecell_Currdatastatus.ALARM_ULO_Level             > 0
3857
-    || bluecell_Currdatastatus.ALARM_ULO_ALC_SHTUTDOWN     > 0){
3921
+    || bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN         > 0)
3922
+    {
3858 3923
         AlarmTimerOnSet = true;
3859 3924
         AlarmTimerOffSet = false;
3860 3925
         if(AlarmTimerOnCnt > 3000){
@@ -3872,10 +3937,12 @@ void Alarm_Check(){
3872 3937
     /******************************TEMP START*******************************************/ 
3873 3938
     if(bluecell_Currdatastatus.Temp_High_Threshold < (bluecell_Currdatastatus.DET_TEMP )){
3874 3939
         bluecell_Currdatastatus.ALARM_TEMP_HIGH |= ENVIRONMENT_TEMPHIGH;
3940
+        bluecell_Currdatastatus.Temp_High_Alarm = true;
3941
+
3875 3942
         
3876 3943
     }else{
3877 3944
         bluecell_Currdatastatus.ALARM_TEMP_HIGH &= ~ENVIRONMENT_TEMPHIGH;
3878
-        
3945
+        bluecell_Currdatastatus.Temp_High_Alarm = false;        
3879 3946
     }
3880 3947
     /******************************TEMP END*******************************************/ 
3881 3948
 
@@ -4035,8 +4102,44 @@ void Alarm_Check(){
4035 4102
     /******************************ULO LEVEL END*******************************************/ 
4036 4103
     
4037 4104
     /******************************DLI LEVEL START*******************************************/ 
4105
+    if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index] == true){
4106
+        bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P1_LEVEL_LOW;
4107
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm1 = true;
4108
+
4109
+    }else{
4110
+        bluecell_Currdatastatus.ALARM_DLI_Level &= ~ALARM_DLI_P1_LEVEL_LOW;
4111
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm1 = false;
4112
+    }
4038 4113
 
4039
-    if(ADC_Alarm_DL_Set[DET_Alarm_DL1_Index] == true){
4114
+    if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL2_Index] == true){
4115
+        bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P2_LEVEL_LOW;
4116
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm2 = true;
4117
+
4118
+    }else{
4119
+        bluecell_Currdatastatus.ALARM_DLI_Level &= ~ALARM_DLI_P2_LEVEL_LOW;
4120
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm2 = false;
4121
+    }
4122
+
4123
+    if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL3_Index] == true){
4124
+        bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P3_LEVEL_LOW;
4125
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm3 = true;
4126
+
4127
+    }else{
4128
+        bluecell_Currdatastatus.ALARM_DLI_Level &= ~ALARM_DLI_P3_LEVEL_LOW;
4129
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm3 = false;
4130
+    }
4131
+
4132
+    if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL4_Index] == true){
4133
+        bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P4_LEVEL_LOW;
4134
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm4 = true;
4135
+
4136
+    }else{
4137
+        bluecell_Currdatastatus.ALARM_DLI_Level &= ~ALARM_DLI_P4_LEVEL_LOW;
4138
+        bluecell_Currdatastatus.DLI_Level_Low_Alarm4 = false;
4139
+    }     
4140
+    
4141
+
4142
+    if(ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index] == true){
4040 4143
         bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P1_LEVEL_HIGH;
4041 4144
         bluecell_Currdatastatus.DLI_Level_High_Alarm1 = true;
4042 4145
 
@@ -4045,7 +4148,7 @@ void Alarm_Check(){
4045 4148
         bluecell_Currdatastatus.DLI_Level_High_Alarm1 = false;
4046 4149
     }
4047 4150
 
4048
-    if(ADC_Alarm_DL_Set[DET_Alarm_DL2_Index] == true){
4151
+    if(ADC_Alarm_DL_High_Set[DET_Alarm_DL2_Index] == true){
4049 4152
         bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P2_LEVEL_HIGH;
4050 4153
         bluecell_Currdatastatus.DLI_Level_High_Alarm2 = true;
4051 4154
 
@@ -4054,7 +4157,7 @@ void Alarm_Check(){
4054 4157
         bluecell_Currdatastatus.DLI_Level_High_Alarm2 = false;
4055 4158
     }
4056 4159
 
4057
-    if(ADC_Alarm_DL_Set[DET_Alarm_DL3_Index] == true){
4160
+    if(ADC_Alarm_DL_High_Set[DET_Alarm_DL3_Index] == true){
4058 4161
         bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P3_LEVEL_HIGH;
4059 4162
         bluecell_Currdatastatus.DLI_Level_High_Alarm3 = true;
4060 4163
 
@@ -4063,7 +4166,7 @@ void Alarm_Check(){
4063 4166
         bluecell_Currdatastatus.DLI_Level_High_Alarm3 = false;
4064 4167
     }
4065 4168
 
4066
-    if(ADC_Alarm_DL_Set[DET_Alarm_DL4_Index] == true){
4169
+    if(ADC_Alarm_DL_High_Set[DET_Alarm_DL4_Index] == true){
4067 4170
         bluecell_Currdatastatus.ALARM_DLI_Level |= ALARM_DLI_P4_LEVEL_HIGH;
4068 4171
         bluecell_Currdatastatus.DLI_Level_High_Alarm4 = true;
4069 4172
 
@@ -4072,8 +4175,85 @@ void Alarm_Check(){
4072 4175
         bluecell_Currdatastatus.DLI_Level_High_Alarm4 = false;
4073 4176
     }     
4074 4177
     /******************************DLI LEVEL END*******************************************/     
4178
+    /******************************ULO ShutDown Start******************************************/     
4179
+    if(bluecell_Currdatastatus.ULO_Shutdown_ON_OFF == true){
4180
+        if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index] == true){
4181
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P1;
4182
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm1 = true;
4183
+
4184
+        }else{
4185
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P1;
4186
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm1 = false;
4187
+        }
4188
+
4189
+        if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL2_Shutdown_Index] == true){
4190
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P2;
4191
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm2 = true;
4192
+
4193
+        }else{
4194
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P2;
4195
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm2 = false;
4196
+        }
4197
+
4198
+        if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL3_Shutdown_Index] == true){
4199
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P3;
4200
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm3 = true;
4201
+
4202
+        }else{
4203
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P3;
4204
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm3 = false;
4205
+        }
4206
+
4207
+        if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL4_Shutdown_Index] == true){
4208
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P4;
4209
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm4 = true;
4210
+
4211
+        }else{
4212
+            bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P4;
4213
+            bluecell_Currdatastatus.ULO_Shutdown_Alarm4 = false;
4214
+        } 
4215
+    }
4216
+
4217
+    /******************************ULO ShutDown END******************************************/     
4075 4218
     
4076 4219
     /******************************DLI ShutDown Start******************************************/     
4220
+    if(bluecell_Currdatastatus.DLI_Shutdown_ON_OFF == true){    
4221
+        if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index] == true){
4222
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P1;
4223
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm1 = true;
4224
+
4225
+        }else{
4226
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P1;
4227
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm1 = false;
4228
+        }
4229
+
4230
+        if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL2_Shutdown_Index] == true){
4231
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P2;
4232
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm2 = true;
4233
+
4234
+        }else{
4235
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P2;
4236
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm2 = false;
4237
+        }
4238
+
4239
+        if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL3_Shutdown_Index] == true){
4240
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P3;
4241
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm3 = true;
4242
+
4243
+        }else{
4244
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P3;
4245
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm3 = false;
4246
+        }
4247
+
4248
+        if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL4_Shutdown_Index] == true){
4249
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P4;
4250
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm4 = true;
4251
+
4252
+        }else{
4253
+            bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P4;
4254
+            bluecell_Currdatastatus.DLI_Shutdown_Alarm4 = false;
4255
+        }    
4256
+    }
4077 4257
     /******************************DLI ShutDown END******************************************/     
4078 4258
 
4079 4259
     

+ 19 - 35
Bluecell_Src/CRC.c

@@ -149,43 +149,27 @@ uint8_t Chksum_Create(uint8_t *data, uint32_t leng)
149 149
 }
150 150
 
151 151
 
152
-static
153
-const uint16_t crc16_tab[256] = {
154
-    0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
155
-    0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
156
-    0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
157
-    0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
158
-    0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
159
-    0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
160
-    0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
161
-    0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
162
-    0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
163
-    0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
164
-    0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
165
-    0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
166
-    0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
167
-    0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
168
-    0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
169
-    0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
170
-    0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
171
-    0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
172
-    0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
173
-    0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
174
-    0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
175
-    0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
176
-    0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
177
-    0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
178
-    0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
179
-    0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
180
-    0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
181
-    0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
182
-    0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
183
-    0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
184
-    0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
185
-    0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
186
-};
187 152
 
153
+etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum)
154
+{
155
+    uint16_t crc = 0;
156
+    for (uint32_t counter = 0; counter < len; counter++)
157
+        crc = (uint16_t)((crc << 8) ^ Table_CRC16[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
158
+
159
+    return (crc == checksum ? CHECKSUM_ERROR : NO_ERROR);
160
+}
161
+uint16_t CRC16_Generate(uint8_t* buf_ptr, int len)
162
+{
163
+    uint16_t crc = 0;
164
+    for (uint32_t counter = 0; counter < len; counter++)
165
+        crc = (uint16_t)((crc << 8) ^ Table_CRC16[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
166
+
167
+    return crc;
168
+}   
169
+
170
+#if 0 // PYJ.2020.05.28_BEGIN -- 
188 171
 uint16_t crc16(uint16_t crc, uint8_t data)
189 172
 {
190 173
     return (uint16_t)((crc << 8) ^ crc16_tab[((crc >> 8) ^ data) & 0xff]);
191 174
 }
175
+#endif // PYJ.2020.05.28_END -- 

+ 2 - 2
Bluecell_Src/eeprom.c

@@ -63,11 +63,11 @@ void EEPROM_M24C08_Init(void){
63 63
 
64 64
     bluecell_Currdatastatus.ALARM_TEMP_HIGH          = 0;
65 65
     bluecell_Currdatastatus.ALARM_DLI_Level          = 0;
66
-    bluecell_Currdatastatus.ALARM_DLI_AGC_SHTUTDOWN  = 0;
66
+    bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN  = 0;
67 67
     bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm      = 0;
68 68
     bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm      = 0;
69 69
     bluecell_Currdatastatus.ALARM_ULO_Level          = 0;
70
-    bluecell_Currdatastatus.ALARM_ULO_ALC_SHTUTDOWN  = 0;
70
+    bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN  = 0;
71 71
 
72 72
 //    printf("bluecell_Currdatastatus.ATT_DL1_H : %x\r\n",bluecell_Currdatastatus.ATT_DL1_H);
73 73
 //    printf("bluecell_Currdatastatus.ATT_DL1_L : %x\r\n",bluecell_Currdatastatus.ATT_DL1_L);        

+ 1 - 1
Bluecell_Src/uart.c

@@ -115,7 +115,7 @@ void Uart_Check(void){
115 115
   while (TerminalQueue.data > 0 && UartRxTimerCnt > 50) GetDataFromUartQueue(&hTerminal);
116 116
 }
117 117
 
118
-void Uart1_Data_Send(uint8_t* data,uint8_t size){
118
+void Uart1_Data_Send(uint8_t* data,uint16_t size){
119 119
     HAL_UART_Transmit_DMA(&hTerminal, data,size); 
120 120
 }
121 121
 

+ 3 - 1
Src/main.c

@@ -89,7 +89,9 @@ volatile uint32_t AlarmTimerOnCnt = 0;
89 89
 
90 90
 
91 91
 extern bool AGC_AlarmTimerSet[AGC_Alarm_DL_Index_MAX];
92
-extern bool ADC_Alarm_DL_Set[DET_Alarm_DL_Index_MAX];
92
+extern bool ADC_Alarm_DL_High_Set[DET_Alarm_DL_Index_MAX];
93
+extern bool ADC_Alarm_DL_Low_Set[DET_Alarm_DL_Index_MAX];
94
+
93 95
 extern bool ADC_Alarm_UL_Set[DET_Alarm_UL_Index_MAX];
94 96
 
95 97