瀏覽代碼

HFR 7월 1일 검수 직전

1.Shutdown 기능 AGC -15db 먹은 후 동작 -> Shutdown 기능 HFR 요청 사항 적용 ( AGC와 Shutdown 따로따로 각각 동작하도록 수정)
2.EEPROM INIT 에서 Table Initialize 하도록 수정
3. UL 4 번 Atten printf 주석
4. Bluecell Data Request 시 Data 전송 시 Txdata 변수 사용
5.MBIC SW Reset 에서 Table LengSet 하도록 수정
6.Shutdown 종료시 Retry cont 무조건 0으로 Clear 하도록 수정
7.Check Sum 에서 No Error 시 Data 적용하도록 수정
8.Timer 기능 UL DL Package 로 변경
PYJ 5 年之前
父節點
當前提交
15b6c018bd
共有 5 個文件被更改,包括 215 次插入123 次删除
  1. 118 48
      Bluecell_Src/Bluecell_operate.c
  2. 5 1
      Bluecell_Src/CRC.c
  3. 19 19
      Bluecell_Src/eeprom.c
  4. 2 2
      Bluecell_Src/uart.c
  5. 71 53
      Src/main.c

+ 118 - 48
Bluecell_Src/Bluecell_operate.c

@@ -431,16 +431,21 @@ ATT_TABLE_st Atten_Table_ref[Table_ATT_Ref_Index_MAX] = {
431 431
 #define TableDataSetting_ATT_UL_LEVEL_STEP -1 
432 432
 #define TableDataSetting_ATT_DL_TEMP_STEP -5 
433 433
 #define TableDataSetting_ATT_UL_TEMP_STEP -5 
434
+void Table_LengthSetting(){
435
+
436
+
437
+}
434 438
 
435 439
 void Table_DataSetting(int8_t* pdata,int8_t RefData,double step,uint8_t size){
436 440
 //    step /= 10;
437 441
     for(int i =0; i < size; i++){
438 442
         pdata[i] = RefData;
439
-        printf("pdata[%d] %d \r\n",i,pdata[i]);
443
+//        printf("pdata[%d] %d \r\n",i,pdata[i]);
440 444
         RefData += step; 
441 445
     }
442 446
 }
443 447
 void Table_Init(){
448
+    printf("Table Initialize\r\n");
444 449
     Table_DataSetting(&DL_DET_Table_ref[AGC_Table_DL1_Ref_Index][TABLE_MAX_VALUE],Det_DL1.Table_Ref,TableDataSetting_ATT_DL_LEVEL_STEP,Det_DL1.Table_Length);
445 450
     Table_DataSetting(&DL_DET_Table_ref[AGC_Table_DL2_Ref_Index][TABLE_MAX_VALUE],Det_DL2.Table_Ref,TableDataSetting_ATT_DL_LEVEL_STEP,Det_DL2.Table_Length);
446 451
     Table_DataSetting(&DL_DET_Table_ref[AGC_Table_DL3_Ref_Index][TABLE_MAX_VALUE],Det_DL3.Table_Ref,TableDataSetting_ATT_DL_LEVEL_STEP,Det_DL3.Table_Length);
@@ -451,11 +456,24 @@ void Table_Init(){
451 456
     Table_DataSetting(&UL_DET_Table_ref[ALC_Table_UL4_Ref_Index][TABLE_MAX_VALUE],Det_UL4.Table_Ref,TableDataSetting_ATT_UL_LEVEL_STEP,Det_UL4.Table_Length);
452 457
 
453 458
 
459
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_ATT_UL4_TABLE_ADDRESDS,&Det_DL1.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st) );
460
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_DET_DL1_TABLE_ADDRESDS,&Det_DL2.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st) );
461
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_DET_DL2_TABLE_ADDRESDS,&Det_DL3.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st) );
462
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_DET_DL3_TABLE_ADDRESDS,&Det_DL4.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st) );
463
+//
464
+//
465
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_DET_DL4_TABLE_ADDRESDS,&Det_UL1.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
466
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_DET_UL1_TABLE_ADDRESDS,&Det_UL2.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
467
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_DET_UL2_TABLE_ADDRESDS,&Det_UL3.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
468
+//    EEPROM_M24C08_write(EEPROM_M24C08_ID,EEPROM_DET_UL3_TABLE_ADDRESDS,&Det_UL4.Table_Det_15_dBm_H,sizeof(DET_TABLEUL_st) );
469
+
470
+
471
+
454 472
 }
455 473
 void Bluecell_AttenInitialize(){
456 474
     uint8_t val = 0;
457 475
     int16_t MBIC_ALC_Val = 0,MBIC_Val = 0,MBIC_UserVal = 0;
458
-    Table_Init();
476
+
459 477
 //    Bluecell_StructCpy(&AutoControl_Save[MBIC_Table_DL1_INDEX],&DL_DET_Table_ref[AGC_Table_DL1_Ref_Index][TABLE_MAX_VALUE],sizeof(AGC_dBm_t));
460 478
 //    Bluecell_StructCpy(&AutoControl_Save[MBIC_Table_DL2_INDEX],&DL_DET_Table_ref[AGC_Table_DL2_Ref_Index][TABLE_MAX_VALUE],sizeof(AGC_dBm_t));
461 479
 //    Bluecell_StructCpy(&AutoControl_Save[MBIC_Table_DL3_INDEX],&DL_DET_Table_ref[AGC_Table_DL3_Ref_Index][TABLE_MAX_VALUE],sizeof(AGC_dBm_t));
@@ -683,13 +701,42 @@ void Atten_UL_Ctrl_Function(uint8_t index,ATT_TABLE_st* Table,uint8_t* CurrAtten
683 701
     }
684 702
 
685 703
 }
704
+typedef enum{
705
+    DL_ATTEN_H,
706
+    DL_ATTEN_L,        
707
+};
708
+void DL_AttenOperate(uint8_t* Atten,uint8_t* PrevAtten,uint8_t* UserAtten,uint8_t* PrevUserAtten,PE43711_st ATT){
709
+     uint8_t val = 0;
710
+     uint16_t MBIC_Val = 0;
711
+     uint16_t MBIC_ALC_Val = 0;
712
+     uint16_t MBIC_UserVal = 0;    
713
+        if((Atten[DL_ATTEN_H] != PrevAtten[DL_ATTEN_H])
714
+         ||(Atten[DL_ATTEN_L] != PrevAtten[DL_ATTEN_L])
715
+         ||(UserAtten[DL_ATTEN_H] != PrevUserAtten[DL_ATTEN_H])
716
+         ||(UserAtten[DL_ATTEN_L] != PrevUserAtten[DL_ATTEN_L])){
717
+    //         printf("%s : %d \r\n",__func__,__LINE__);   
718
+                Atten[DL_ATTEN_H] = PrevAtten[DL_ATTEN_H];
719
+                Atten[DL_ATTEN_L] = PrevAtten[DL_ATTEN_L];
720
+                UserAtten[DL_ATTEN_H] = PrevUserAtten[DL_ATTEN_H];
721
+                UserAtten[DL_ATTEN_L] = PrevUserAtten[DL_ATTEN_L];
722
+                MBIC_Val =Atten[DL_ATTEN_H] << 8 |Atten[DL_ATTEN_L];
723
+                MBIC_UserVal = UserAtten[DL_ATTEN_H] << 8 | UserAtten[DL_ATTEN_L];
724
+                val = MBIC_DL_PE43711_Calc(&Att_DL1.Table_0_0_dBm, // Table Offset
725
+                                    MBIC_Val,
726
+                                   MBIC_UserVal);// User Atten Low Bit
727
+                printf("%s : %d \r\n",__func__,__LINE__);   
728
+                printf("%d val = %x \r\n",__LINE__,val);
729
+                PE43711_atten_ctrl(ATT,val);
730
+        }
731
+
686 732
 
733
+}
687 734
 void CompareAttenData(BLUESTATUS_st Curr,BLUESTATUS_st Prev){
688 735
      uint8_t val = 0;
689 736
      uint16_t MBIC_Val = 0;
690 737
      uint16_t MBIC_ALC_Val = 0;
691 738
      uint16_t MBIC_UserVal = 0;
692
-
739
+#if 1 // PYJ.2020.07.01_BEGIN -- 
693 740
     if((Curr.ATT_DL1_H != Prev.ATT_DL1_H)
694 741
      ||(Curr.ATT_DL1_L != Prev.ATT_DL1_L)
695 742
      ||(Curr.bluecell_User_DL1_H != Prev.bluecell_User_DL1_H)
@@ -766,6 +813,17 @@ void CompareAttenData(BLUESTATUS_st Curr,BLUESTATUS_st Prev){
766 813
             printf("%d val = %x \r\n",__LINE__,val);
767 814
             PE43711_atten_ctrl(ALL_ATT.ATT_DL4,val);
768 815
     }
816
+#else
817
+    DL_AttenOperate(&bluecell_Currdatastatus.ATT_DL1_H,&bluecell_Prevdatastatus.ATT_DL1_L,
818
+                    &bluecell_Currdatastatus.bluecell_User_DL1_H,&bluecell_Prevdatastatus.bluecell_User_DL1_L,ALL_ATT.ATT_DL1);
819
+    DL_AttenOperate(&bluecell_Currdatastatus.ATT_DL2_H,&bluecell_Prevdatastatus.ATT_DL2_L,
820
+                    &bluecell_Currdatastatus.bluecell_User_DL2_H,&bluecell_Prevdatastatus.bluecell_User_DL2_L,ALL_ATT.ATT_DL2);
821
+    DL_AttenOperate(&bluecell_Currdatastatus.ATT_DL3_H,&bluecell_Prevdatastatus.ATT_DL3_L,
822
+                    &bluecell_Currdatastatus.bluecell_User_DL3_H,&bluecell_Prevdatastatus.bluecell_User_DL3_L,ALL_ATT.ATT_DL3);    
823
+    DL_AttenOperate(&bluecell_Currdatastatus.ATT_DL4_H,&bluecell_Prevdatastatus.ATT_DL4_L,
824
+                    &bluecell_Currdatastatus.bluecell_User_DL4_H,&bluecell_Prevdatastatus.bluecell_User_DL4_L,ALL_ATT.ATT_DL4);
825
+
826
+#endif // PYJ.2020.07.01_END -- 
769 827
 
770 828
     if(bluecell_Prevdatastatus.bluecell_User_UL1_H != 0xFF)
771 829
         bluecell_Prevdatastatus.bluecell_User_UL1_H =0xFF;
@@ -874,19 +932,19 @@ void CompareAttenData(BLUESTATUS_st Curr,BLUESTATUS_st Prev){
874 932
      ||(Curr.MBIC_ULO_ALC_Atten4_H != Prev.MBIC_ULO_ALC_Atten4_H)
875 933
      ||(Curr.MBIC_ULO_ALC_Atten4_L != Prev.MBIC_ULO_ALC_Atten4_L))
876 934
      {
877
-            printf("bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_H : %02x \r\n",bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_H);
878
-            printf("bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_L : %02x \r\n",bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_L);
879
-            printf("bluecell_Prevdatastatus.ATT_UL4_H : %02x \r\n",bluecell_Prevdatastatus.ATT_UL4_H);
880
-            printf("bluecell_Prevdatastatus.ATT_UL4_L : %02x \r\n",bluecell_Prevdatastatus.ATT_UL4_L);
881
-            printf("bluecell_Prevdatastatus.bluecell_User_UL4_H : %02x \r\n",bluecell_Prevdatastatus.bluecell_User_UL4_H);
882
-            printf("bluecell_Prevdatastatus.bluecell_User_UL4_L : %02x \r\n",bluecell_Prevdatastatus.bluecell_User_UL4_L);        
883
-            printf("============================================================\r\n");
884
-            printf("bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_H : %02x \r\n",bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_H);
885
-            printf("bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_L : %02x \r\n",bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_L);
886
-            printf("bluecell_Currdatastatus.ATT_UL4_H : %02x \r\n",bluecell_Currdatastatus.ATT_UL4_H);
887
-            printf("bluecell_Currdatastatus.ATT_UL4_L : %02x \r\n",bluecell_Currdatastatus.ATT_UL4_L);
888
-            printf("bluecell_Currdatastatus.bluecell_User_UL4_H : %02x \r\n",bluecell_Currdatastatus.bluecell_User_UL4_H);
889
-            printf("bluecell_Currdatastatus.bluecell_User_UL4_L : %02x \r\n",bluecell_Currdatastatus.bluecell_User_UL4_L);        
935
+//            printf("bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_H : %02x \r\n",bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_H);
936
+//            printf("bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_L : %02x \r\n",bluecell_Prevdatastatus.MBIC_ULO_ALC_Atten4_L);
937
+//            printf("bluecell_Prevdatastatus.ATT_UL4_H : %02x \r\n",bluecell_Prevdatastatus.ATT_UL4_H);
938
+//            printf("bluecell_Prevdatastatus.ATT_UL4_L : %02x \r\n",bluecell_Prevdatastatus.ATT_UL4_L);
939
+//            printf("bluecell_Prevdatastatus.bluecell_User_UL4_H : %02x \r\n",bluecell_Prevdatastatus.bluecell_User_UL4_H);
940
+//            printf("bluecell_Prevdatastatus.bluecell_User_UL4_L : %02x \r\n",bluecell_Prevdatastatus.bluecell_User_UL4_L);        
941
+//            printf("============================================================\r\n");
942
+//            printf("bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_H : %02x \r\n",bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_H);
943
+//            printf("bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_L : %02x \r\n",bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_L);
944
+//            printf("bluecell_Currdatastatus.ATT_UL4_H : %02x \r\n",bluecell_Currdatastatus.ATT_UL4_H);
945
+//            printf("bluecell_Currdatastatus.ATT_UL4_L : %02x \r\n",bluecell_Currdatastatus.ATT_UL4_L);
946
+//            printf("bluecell_Currdatastatus.bluecell_User_UL4_H : %02x \r\n",bluecell_Currdatastatus.bluecell_User_UL4_H);
947
+//            printf("bluecell_Currdatastatus.bluecell_User_UL4_L : %02x \r\n",bluecell_Currdatastatus.bluecell_User_UL4_L);        
890 948
             bluecell_Prevdatastatus.ATT_UL4_H = bluecell_Currdatastatus.ATT_UL4_H;
891 949
             bluecell_Prevdatastatus.ATT_UL4_L = bluecell_Currdatastatus.ATT_UL4_L;
892 950
             bluecell_Prevdatastatus.bluecell_User_UL4_H = bluecell_Currdatastatus.bluecell_User_UL4_H;
@@ -2195,12 +2253,16 @@ bool Bluecell_Operate(uint8_t* data){
2195 2253
   int16_t CurrAtten = 0;
2196 2254
   int16_t ALC_TEMP[4] ={0,};
2197 2255
   int16_t Tmpdata = 0 ,Tmpdata2 = 0;
2256
+  double tmpedata2 = 0;
2198 2257
   uint8_t i = 0;
2199 2258
   uint16_t Crcret = 0;
2259
+  uint16_t Length = 0;
2200 2260
   switch(datatype){
2201 2261
     case BLUECELL_SOFTWARERESET:
2202 2262
         printf("Bluecell Reset \r\n");
2263
+//        Table_Init();
2203 2264
         Table_LengSet();
2265
+//        Table_LengSet();
2204 2266
         NVIC_SystemReset();
2205 2267
         break;
2206 2268
 	case Bluecell_ATT_DL1 				 :
@@ -2641,8 +2703,12 @@ bool Bluecell_Operate(uint8_t* data){
2641 2703
         Bluecell_StructCpy(&Txdata[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
2642 2704
         Txdata[BLUECELL_LENGTH_L] = sizeof(BLUESTATUS_st) - 3;//sizeof(BLUESTATUS_st) - 3;
2643 2705
 //        Txdata[sizeof(BLUESTATUS_st) - 2] = STH30_CreateCrc(&Txdata[BLUECELL_TYPE], Txdata[BLUECELL_LENGTH_L]);
2644
-        Txdata[sizeof(BLUESTATUS_st) - 3] = ((CRC16_Generate(&data[BLUECELL_TYPE], data[BLUECELL_LENGTH_L]) & 0xFF00) >> 8);
2645
-        Txdata[sizeof(BLUESTATUS_st) - 2] = CRC16_Generate(&data[BLUECELL_TYPE], data[BLUECELL_LENGTH_L]) & 0x00FF;        
2706
+        Length = sizeof(BLUESTATUS_st) - 4;
2707
+        Txdata[BLUECELL_LENGTH_H] = ((Length & 0xFF00) >> 8);
2708
+        Txdata[BLUECELL_LENGTH_L] = ((Length & 0x00FF));
2709
+        Crcret = ((CRC16_Generate(&Txdata[BLUECELL_TYPE], Length) ));
2710
+        Txdata[sizeof(BLUESTATUS_st) - 3] = ((Crcret & 0xFF00) >> 8 );
2711
+        Txdata[sizeof(BLUESTATUS_st) - 2] = ((Crcret & 0x00FF));
2646 2712
         
2647 2713
 #endif // PYJ.2020.05.28_END -- 
2648 2714
 #if 0 // PYJ.2020.04.22_BEGIN -- 
@@ -2651,24 +2717,18 @@ bool Bluecell_Operate(uint8_t* data){
2651 2717
         }
2652 2718
         printf("\r\n");
2653 2719
 #endif // PYJ.2020.04.22_END --   
2654
-#if 0 // PYJ.2020.07.01_BEGIN -- 
2720
+#if 1 // PYJ.2020.07.01_BEGIN -- 
2655 2721
         printf("===================START=======================\r\n");
2656
-        printf("ALC ON %d  \r\n",bluecell_Currdatastatus.ULO_ALC_ON_OFF);
2657
-        printf("AGC ON %d  \r\n",bluecell_Currdatastatus.DLI_AGC_ON_OFF);
2658
-        printf("Shutdown DL ON OFF %d  \r\n",bluecell_Currdatastatus.DLI_Shutdown_ON_OFF);
2659
-        printf("Shutdown UL ON OFF %d  \r\n",bluecell_Currdatastatus.ULO_Shutdown_ON_OFF);
2660
-
2661
-
2662
-        printf("Shutdown DL1 CNT %d  \r\n",bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1);
2663
-        printf("Shutdown DL2 CNT %d  \r\n",bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2);
2664
-        printf("Shutdown DL3 CNT %d  \r\n",bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3);
2665
-        printf("Shutdown DL4 CNT %d  \r\n",bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4);
2666
-        
2667
-        printf("Shutdown UL1 CNT %d  \r\n",bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1);
2668
-        printf("Shutdown UL2 CNT %d  \r\n",bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
2669
-        printf("Shutdown UL3 CNT %d  \r\n",bluecell_Currdatastatus.ULO_Shutdown_Retry_Count3);
2670
-        printf("Shutdown UL4 CNT %d  \r\n",bluecell_Currdatastatus.ULO_Shutdown_Retry_Count4);
2671
-
2722
+        printf("ALC ON %d                     | AGC ON %d\r\n",bluecell_Currdatastatus.ULO_ALC_ON_OFF,bluecell_Currdatastatus.DLI_AGC_ON_OFF);
2723
+        printf("Shutdown DL ON OFF %d         | Shutdown UL ON OFF %d \r\n",bluecell_Currdatastatus.DLI_Shutdown_ON_OFF,bluecell_Currdatastatus.ULO_Shutdown_ON_OFF);
2724
+        printf("PATH1 %d|Shutdown DL1 CNT %d  | PATH1 %d|Shutdown UL1 CNT %d\r\n",bluecell_Currdatastatus.ATT_DL1_PATH,bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1,bluecell_Currdatastatus.ATT_DL1_PATH,bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1);
2725
+        printf("PATH2 %d|Shutdown DL2 CNT %d  | PATH2 %d|Shutdown UL2 CNT %d\r\n",bluecell_Currdatastatus.ATT_DL2_PATH,bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2,bluecell_Currdatastatus.ATT_UL2_PATH,bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
2726
+        printf("PATH3 %d|Shutdown DL3 CNT %d  | PATH3 %d|Shutdown UL3 CNT %d\r\n",bluecell_Currdatastatus.ATT_DL3_PATH,bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3,bluecell_Currdatastatus.ATT_UL3_PATH,bluecell_Currdatastatus.ULO_Shutdown_Retry_Count3);
2727
+        printf("PATH4 %d|Shutdown DL4 CNT %d  | PATH4 %d|Shutdown UL4 CNT %d\r\n",bluecell_Currdatastatus.ATT_DL4_PATH,bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4,bluecell_Currdatastatus.ATT_UL4_PATH,bluecell_Currdatastatus.ULO_Shutdown_Retry_Count4);
2728
+        tempdata = (( bluecell_Currdatastatus.DLI_Shutdown_Threshold_H << 8) & 0xFF00) ;
2729
+        tempdata +=  bluecell_Currdatastatus.DLI_Shutdown_Threshold_L ;
2730
+        tempdata /= 10;
2731
+        printf("DL Shutdown Threas : %d \r\n",tempdata);
2672 2732
 //        printf("Temp Alarm %d \r\n");
2673 2733
         printf("ALC  Alarm 1: %d 2:  %d 3: %d 4: %d\r\n",
2674 2734
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm & ALARM_ALC_P1,
@@ -2739,6 +2799,7 @@ bool Bluecell_Operate(uint8_t* data){
2739 2799
 //        Uart1_Data_Send(&Txdata[0], sizeof(BLUESTATUS_st));        
2740 2800
         EEPROM_M24C08_Zerowrite(EEPROM_M24C08_ID ,(EEPROM_ATT_BASE));
2741 2801
 //        printf("ZERO WRITE COMPLETE");
2802
+
2742 2803
          NVIC_SystemReset();
2743 2804
 
2744 2805
         break;
@@ -2838,12 +2899,12 @@ bool Bluecell_Operate(uint8_t* data){
2838 2899
 //        bluecell_Currdatastatus.bluecell_User_TEMP_OFFSET_L = data[BLUECELL_DATA + i++];
2839 2900
         break;
2840 2901
     case Bluecell_DLI_AGC_ON_OFF:                             
2841
-        bluecell_Currdatastatus.DLI_AGC_ON_OFF = data[BLUECELL_DATA + i];
2842 2902
         printf("AGC ON OFF SET : %d \r\n",bluecell_Currdatastatus.DLI_AGC_ON_OFF);
2903
+        bluecell_Currdatastatus.DLI_AGC_ON_OFF = data[BLUECELL_DATA + i];
2843 2904
         break;
2844 2905
     case Bluecell_ULO_ALC_ON_OFF:                             
2906
+        printf("ALC ON OFF SET : %d \r\n",bluecell_Currdatastatus.ULO_ALC_ON_OFF);
2845 2907
         bluecell_Currdatastatus.ULO_ALC_ON_OFF = data[BLUECELL_DATA + i];
2846
-        printf("ALC ON OFF SET : %d \r\n",bluecell_Currdatastatus.DLI_AGC_ON_OFF);
2847 2908
         break;
2848 2909
     case Bluecell_DLI_AGC_Threshold:                          
2849 2910
         bluecell_Currdatastatus.DLI_AGC_Threshold_H = data[BLUECELL_DATA + i++];
@@ -2866,8 +2927,8 @@ bool Bluecell_Operate(uint8_t* data){
2866 2927
         }
2867 2928
         break;
2868 2929
     case Bluecell_DLI_Shutdown_ON_OFF:                        
2869
-        bluecell_Currdatastatus.DLI_Shutdown_ON_OFF = data[BLUECELL_DATA + i++];
2870 2930
         printf("%s : %d  DLI_Shutdown_ON_OFF : %d \r\n",__func__,__LINE__,bluecell_Currdatastatus.DLI_Shutdown_ON_OFF);
2931
+        bluecell_Currdatastatus.DLI_Shutdown_ON_OFF = data[BLUECELL_DATA + i++];
2871 2932
         
2872 2933
         break;
2873 2934
     case Bluecell_DLI_Shutdown_Threshold:                     
@@ -2991,8 +3052,8 @@ bool Bluecell_Operate(uint8_t* data){
2991 3052
 
2992 3053
         break;
2993 3054
     case Bluecell_ULO_Shutdown_ON_OFF                     :   
3055
+        printf("%s Bluecell_ULO_Shutdown_ON_OFF : %d \r\n",__func__,bluecell_Currdatastatus.ULO_Shutdown_ON_OFF );
2994 3056
         bluecell_Currdatastatus.ULO_Shutdown_ON_OFF = data[BLUECELL_DATA + i++];
2995
-         printf("%s Bluecell_ULO_Shutdown_ON_OFF : %d \r\n",__func__,bluecell_Currdatastatus.ULO_Shutdown_ON_OFF );
2996 3057
 
2997 3058
         break;
2998 3059
     case Bluecell_ULO_Shutdown_Threshold                  :   
@@ -4117,7 +4178,7 @@ bool MBIC_Operate(uint8_t* data){
4117 4178
                 NVIC_SystemReset();
4118 4179
                 break;
4119 4180
             case  SW_Reset                                :
4120
-                Table_LengSet();
4181
+//                Table_LengSet();
4121 4182
                 printf("SoftWare Reset Start \r\n");
4122 4183
                 bluecell_Currdatastatus.S_W_Reset = data[MBIC_PAYLOADSTART + 3]; 
4123 4184
                 NVIC_SystemReset();
@@ -6552,7 +6613,7 @@ typedef enum{
6552 6613
 void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tableindex,uint8_t* DLI_ADC_Level,uint8_t* DLI_Level,DET_TABLEDL_st* DL_Table){
6553 6614
         double ret = 0;
6554 6615
         int8_t ResdBm = 0;
6555
-        
6616
+        int16_t CurrAtten = 0;
6556 6617
         int16_t Levelret = 0;
6557 6618
         int i = 0;
6558 6619
         int16_t Limitdata = 0;
@@ -6567,7 +6628,9 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
6567 6628
         ret  = DLI_ADC_Level[DLI_AGC_H] << 8;
6568 6629
         ret += DLI_ADC_Level[DLI_AGC_L];
6569 6630
         ret *= 0.001;
6570
-        ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&DL_Table->Table_Det5_dBm_H,DL_Table->Table_Length * 2,AGC_Table));
6631
+
6632
+        CurrAtten = (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]);
6633
+        ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&DL_Table->Table_Det5_dBm_H,DL_Table->Table_Length,AGC_Table));
6571 6634
         DLI_Level[DLI_AGC_H] = ((int16_t)ResdBm & 0xFF00) >> 8;
6572 6635
         DLI_Level[DLI_AGC_L] = ((int16_t)ResdBm & 0x00FF);
6573 6636
         for(i = 0; i < sizeof(AGC_dBm_t); i++){
@@ -6577,18 +6640,20 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
6577 6640
         IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
6578 6641
         IwillgiveAtten *= -1;
6579 6642
 //        printf("==================================\r\n");
6643
+//        printf("Curr ATTEN %d \r\n",CurrAtten );
6580 6644
 //        printf("Current DL% ADC VALUE : %f \r\n",Tableindex+1,ret);
6581 6645
 //        printf("ResdBm : DL% : %d \r\n",Tableindex+1,ResdBm);
6582 6646
 //        printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
6583 6647
 //        printf("AGC  : %d\r\n",Limitdata);
6584
-
6648
+        if((CurrAtten / 10) < IwillgiveAtten)
6649
+            IwillgiveAtten = (CurrAtten / 10);
6585 6650
 
6586 6651
         if(ResdBm > Limitdata &&  DL_PrevIwillgiveAtten[Tableindex] > IwillgiveAtten){
6587 6652
 //            printf("IwillgiveAtten : %d \r\n",IwillgiveAtten);
6588 6653
             DL_PrevIwillgiveAtten[Tableindex] = IwillgiveAtten;
6589 6654
             IwillgiveAtten = (DL_AGC_StartAtten[Tableindex]*0.1) + IwillgiveAtten;
6590 6655
 //            printf("WILLATTEN RET : %d \r\n",IwillgiveAtten);
6591
-            AGC_Alarm_Check(AGC_Alarm_DL1_Index,ret,&DL_Table->Table_Det5_dBm_H,IwillgiveAtten);
6656
+            AGC_Alarm_Check(AGC_Alarm_DL1_Index + Tableindex,ret,&DL_Table->Table_Det5_dBm_H,IwillgiveAtten);
6592 6657
             DL_MainAtten[DLI_AGC_H] = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
6593 6658
             DL_MainAtten[DLI_AGC_L] = (((IwillgiveAtten * 10) & 0x00FF));     
6594 6659
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
@@ -6606,7 +6671,7 @@ void DL_Det_Function(uint8_t Table_Num,uint8_t* CurrADC_Level,DET_TABLEDL_st* DL
6606 6671
     int16_t Levelret = 0;    
6607 6672
     AGC_Table = &DL_DET_Table_ref[Table_Num][TABLE_MAX_VALUE];
6608 6673
     ret = (((CurrADC_Level[DL_Level_H] << 8) | CurrADC_Level[DL_Level_L]) * 0.001);
6609
-                
6674
+//    printf("DL_Table->Table_Length : %d \r\n",DL_Table->Table_Length);                
6610 6675
     Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&DL_Table->Table_Det5_dBm_H,DL_Table->Table_Length,AGC_Table));
6611 6676
     Level[DL_Level_H] = (Levelret & 0xFF00) >> 8;
6612 6677
     Level[DL_Level_L] = (Levelret & 0x00FF);
@@ -7374,11 +7439,12 @@ void DL_Shutdown_Operate(uint8_t index,uint8_t* path,uint8_t* retrycnt,uint8_t*
7374 7439
     if(MBIC_DL_ShutdownCount[index] < 3
7375 7440
         && (PrevMBIC_DL_ShutdownCount[index] != MBIC_DL_ShutdownCount[index])
7376 7441
         && DET_DL_Shutdown_Off_AlarmTimerCnt[index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC
7377
-        && DL_PathUserHandl[index] == false){
7442
+        && DL_PathUserHandl[index] == false
7443
+        && (*retrycnt) > 0){
7378 7444
         HAL_GPIO_WritePin(Port,Pin,GPIO_PIN_SET);//CLOCK
7379 7445
         *path = true;            
7380
-        bluecell_Prevdatastatus.ATT_DL1_H = 0xFF;
7381
-        bluecell_Prevdatastatus.ATT_DL1_L = 0xFF;
7446
+        MainAtten[DL_Shutdown_H] = 0xFF;
7447
+        MainAtten[DL_Shutdown_L] = 0xFF;
7382 7448
         PrevMBIC_DL_ShutdownCount[index] = MBIC_DL_ShutdownCount[index];
7383 7449
         CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
7384 7450
     }
@@ -8082,6 +8148,10 @@ void ULO_ShutdownAlarmCheck(){
8082 8148
     }
8083 8149
     else{
8084 8150
             bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN = 0;
8151
+            bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1 = 0;
8152
+            bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2 = 0;
8153
+            bluecell_Currdatastatus.ULO_Shutdown_Retry_Count3 = 0;
8154
+            bluecell_Currdatastatus.ULO_Shutdown_Retry_Count4 = 0;            
8085 8155
             bluecell_Currdatastatus.ULO_Shutdown_Alarm1 = false;            
8086 8156
             bluecell_Currdatastatus.ULO_Shutdown_Alarm2 = false;            
8087 8157
             bluecell_Currdatastatus.ULO_Shutdown_Alarm3 = false;            

+ 5 - 1
Bluecell_Src/CRC.c

@@ -203,10 +203,14 @@ uint8_t Chksum_Create(uint8_t *data)
203 203
 etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum)
204 204
 {
205 205
     uint16_t crc = 0;
206
+    etError ret = CHECKSUM_ERROR;
206 207
     for (uint32_t counter = 0; counter < len; counter++)
207 208
         crc = (uint16_t)((crc << 8) ^ crc16_tab[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
208 209
     printf("REAL CRC %x / IN CRC : %x \r\n",crc,checksum);
209
-    return (crc == checksum ? CHECKSUM_ERROR : NO_ERROR);
210
+    if(crc == checksum)
211
+        ret = NO_ERROR;
212
+        
213
+    return ret;
210 214
 }
211 215
 
212 216
 

+ 19 - 19
Bluecell_Src/eeprom.c

@@ -14,7 +14,7 @@
14 14
 
15 15
 /* Includes ------------------------------------------------------------------*/   
16 16
 HAL_StatusTypeDef EEPROM_M24C08_ByteRead(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size);
17
-
17
+extern void Table_Init();
18 18
 
19 19
 extern BLUESTATUS_st bluecell_Currdatastatus;
20 20
 
@@ -117,24 +117,24 @@ void EEPROM_M24C08_Init(void){
117 117
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_TEMP_UL1_TABLE_ADDRESDS,&Temp_UL2.Table_1_Temp,sizeof(TEMP_TABLE_st) );
118 118
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_TEMP_UL2_TABLE_ADDRESDS,&Temp_UL3.Table_1_Temp,sizeof(TEMP_TABLE_st) );
119 119
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_TEMP_UL3_TABLE_ADDRESDS,&Temp_UL4.Table_1_Temp,sizeof(TEMP_TABLE_st) );
120
-
121
-//    printf("TableDL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL1.Table_Length,Att_DL1.Table_Ref);
122
-//    printf("TableDL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL2.Table_Length,Att_DL2.Table_Ref);
123
-//    printf("TableDL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL3.Table_Length,Att_DL3.Table_Ref);    
124
-//    printf("TableDL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL4.Table_Length,Att_DL4.Table_Ref);
125
-//    printf("TableUL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL1.Table_Length,Att_UL1.Table_Ref);
126
-//    printf("TableUL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL2.Table_Length,Att_UL2.Table_Ref);
127
-//    printf("TableUL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL3.Table_Length,Att_UL3.Table_Ref);    
128
-//    printf("TableUL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL4.Table_Length,Att_UL4.Table_Ref);    
129
-//
130
-//    printf("TableDL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL1.Table_Length,Det_DL1.Table_Ref);
131
-//    printf("TableDL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL2.Table_Length,Det_DL2.Table_Ref);
132
-//    printf("TableDL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL3.Table_Length,Det_DL3.Table_Ref);    
133
-//    printf("TableDL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL4.Table_Length,Det_DL4.Table_Ref);
134
-//    printf("TableUL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL1.Table_Length,Det_DL1.Table_Ref);
135
-//    printf("TableUL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL2.Table_Length,Det_DL2.Table_Ref);
136
-//    printf("TableUL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL3.Table_Length,Det_DL3.Table_Ref);    
137
-//    printf("TableUL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL4.Table_Length,Det_DL4.Table_Ref);    
120
+    Table_Init();
121
+    printf("ATT TableDL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL1.Table_Length,Att_DL1.Table_Ref);
122
+    printf("ATT TableDL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL2.Table_Length,Att_DL2.Table_Ref);
123
+    printf("ATT TableDL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL3.Table_Length,Att_DL3.Table_Ref);    
124
+    printf("ATT TableDL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_DL4.Table_Length,Att_DL4.Table_Ref);
125
+    printf("ATT TableUL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL1.Table_Length,Att_UL1.Table_Ref);
126
+    printf("ATT TableUL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL2.Table_Length,Att_UL2.Table_Ref);
127
+    printf("ATT TableUL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL3.Table_Length,Att_UL3.Table_Ref);    
128
+    printf("ATT TableUL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Att_UL4.Table_Length,Att_UL4.Table_Ref);    
129
+
130
+    printf("DET TableDL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL1.Table_Length,Det_DL1.Table_Ref);
131
+    printf("DET TableDL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL2.Table_Length,Det_DL2.Table_Ref);
132
+    printf("DET TableDL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL3.Table_Length,Det_DL3.Table_Ref);    
133
+    printf("DET TableDL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_DL4.Table_Length,Det_DL4.Table_Ref);
134
+    printf("DET TableUL 1_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_UL1.Table_Length,Det_UL1.Table_Ref);
135
+    printf("DET TableUL 2_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_UL2.Table_Length,Det_UL2.Table_Ref);
136
+    printf("DET TableUL 3_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_UL3.Table_Length,Det_UL3.Table_Ref);    
137
+    printf("DET TableUL 4_Init START ORIGIN TABLE LENGTH  %d / Ref : %d \r\n",Det_UL4.Table_Length,Det_UL4.Table_Ref);    
138 138
 //    printf("DL1\r\n");    Table_DET_DataSetting(&DL_Table_ref[AGC_Table_DL1_Ref_Index][DLUL_TABLE_MAX_VALUE],Det_DL1.Table_Ref ,TableDataSetting_ATT_DET_STEP,Det_DL1.Table_Length);
139 139
 //    printf("DL2\r\n");    Table_DET_DataSetting(&DL_Table_ref[AGC_Table_DL2_Ref_Index][DLUL_TABLE_MAX_VALUE],Det_DL2.Table_Ref ,TableDataSetting_ATT_DET_STEP,Det_DL2.Table_Length);
140 140
 //    printf("DL3\r\n");    Table_DET_DataSetting(&DL_Table_ref[AGC_Table_DL3_Ref_Index][DLUL_TABLE_MAX_VALUE],Det_DL3.Table_Ref ,TableDataSetting_ATT_DET_STEP,Det_DL3.Table_Length);

+ 2 - 2
Bluecell_Src/uart.c

@@ -100,7 +100,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
100 100
 //        printf("data cnt zero !!!  \r\n");
101 101
         //RF_Ctrl_Main(&uart_buf[Header]);
102 102
 //        HAL_UART_Transmit(dst, &temp_buf[BLUECELL_HEADER00], 11, 3000);
103
-#if 0// PYJ.2019.07.15_BEGIN --
103
+#if 1// PYJ.2019.07.15_BEGIN --
104 104
             printf("\r\n[RX]");
105 105
             for(int i = 0; i < cnt; i++){
106 106
                 printf("%02x ",uart_buf[i]);
@@ -110,7 +110,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
110 110
             if(uart_buf[0] == 0xbe){
111 111
                 Length = uart_buf[BLUECELL_LENGTH_H] << 8  |  uart_buf[BLUECELL_LENGTH_L] ;
112 112
                 CrcChk = uart_buf[Length + 1] << 8 | uart_buf[Length  + 2] ;
113
-                if(CRC16_Check(&uart_buf[BLUECELL_TYPE], Length,CrcChk))
113
+         //       if(CRC16_Check(&uart_buf[BLUECELL_TYPE], Length,CrcChk))
114 114
             	Bluecell_Operate(uart_buf);
115 115
             }else if(uart_buf[0] == MBIC_PREAMBLE0
116 116
                    &&uart_buf[1] == MBIC_PREAMBLE1

+ 71 - 53
Src/main.c

@@ -237,6 +237,7 @@ uint8_t MBICTest_Firmdata[8]  = {1,2,3,4,5,6,7,8};
237 237
 extern const uint16_t crc16_tab[256];
238 238
 
239 239
 
240
+
240 241
 main(void)  {
241 242
   /* USER CODE BEGIN 1 */
242 243
 
@@ -865,6 +866,56 @@ static void MX_GPIO_Init(void)
865 866
 }
866 867
 
867 868
 /* USER CODE BEGIN 4 */
869
+void DL_Shutdown_Timer(uint8_t* pdata,uint8_t Table_num){
870
+    if(bluecell_Currdatastatus.DLI_Shutdown_ON_OFF == true){
871
+          if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + Table_num] == true){
872
+              DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] = 0; // OFF CNT = 0;
873
+              DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num]++;
874
+              if(DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] == 0xFFFFFFFF){
875
+                  DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] = MBIC_ON_SHUTDOWN_MAINTAIN_SEC;
876
+              }
877
+          }else{
878
+              DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] = 0;
879
+              DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num]++;
880
+              if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] == 0xFFFFFFFF){
881
+                  DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
882
+              }
883
+          }
884
+          if(ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + Table_num] == true){
885
+              DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num]++;
886
+              if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] == 0xFFFFFFFF){
887
+                  DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] = MBIC_OFF_MAINTAIN_SEC;
888
+              }                
889
+          }else{
890
+              DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + Table_num] = 0;
891
+          }
892
+  }
893
+}
894
+void UL_Shutdown_Timer(uint8_t* pdata,uint8_t Table_num){
895
+    if(bluecell_Currdatastatus.ULO_Shutdown_ON_OFF == true){
896
+          if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + Table_num] == true){
897
+              DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] = 0; // OFF CNT = 0;
898
+              DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num]++;
899
+              if(DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] == 0xFFFFFFFF){
900
+                  DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] = MBIC_ON_SHUTDOWN_MAINTAIN_SEC;
901
+              }
902
+          }else{
903
+              DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] = 0;
904
+              DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num]++;
905
+              if(DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] == 0xFFFFFFFF){
906
+                  DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
907
+              }
908
+          }
909
+          if(ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + Table_num] == true){
910
+              DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num]++;
911
+              if(DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] == 0xFFFFFFFF){
912
+                  DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] = MBIC_OFF_MAINTAIN_SEC;
913
+              }                
914
+          }else{
915
+              DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + Table_num] = 0;
916
+          }
917
+  }
918
+}
868 919
 
869 920
 /* USER CODE END 4 */
870 921
 
@@ -879,7 +930,7 @@ static void MX_GPIO_Init(void)
879 930
 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
880 931
 {
881 932
   /* USER CODE BEGIN Callback 0 */
882
-
933
+    uint8_t* pdata;
883 934
   /* USER CODE END Callback 0 */
884 935
   if (htim->Instance == TIM2) {
885 936
     HAL_IncTick();
@@ -892,58 +943,25 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
892 943
       LDTimerCnt++;
893 944
       ALCTimerCnt++;
894 945
       AGCTimerCnt++;
895
-    if(bluecell_Currdatastatus.ULO_Shutdown_ON_OFF == true){
896
-        for(int i = 0; i < DET_Alarm_UL_Shutdown_Index_MAX; i++){
897
-            if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] == true){
898
-                DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0; // OFF CNT = 0;
899
-                DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
900
-                if(DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
901
-                    DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_ON_SHUTDOWN_MAINTAIN_SEC;
902
-                }
903
-            }else{
904
-                DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0;
905
-                DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
906
-                if(DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
907
-                    DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
908
-                }
909
-            }
910
-            if(ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] == true){
911
-                DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
912
-                if(DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
913
-                    DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_OFF_MAINTAIN_SEC;
914
-                }                
915
-            }else{
916
-                DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0;
917
-            }
918
-        }
919
-    }
920
-
921
-
922
-    if(bluecell_Currdatastatus.DLI_Shutdown_ON_OFF == true){
923
-        for(int i = 0; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
924
-            if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] == true){
925
-                DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0; // OFF CNT = 0;
926
-                DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
927
-                if(DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
928
-                    DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_ON_SHUTDOWN_MAINTAIN_SEC;
929
-                }
930
-            }else{
931
-                DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0;
932
-                DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
933
-                if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
934
-                    DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
935
-                }
936
-            }
937
-            if(ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] == true){
938
-                DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
939
-                if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
940
-                    DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_OFF_MAINTAIN_SEC;
941
-                }                
942
-            }else{
943
-                DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0;
944
-            }
945
-        }  
946
-    }
946
+      
947
+//    pdata = &bluecell_Currdatastatus.ATT_UL1_PATH;
948
+    UL_Shutdown_Timer(pdata,DET_Alarm_UL1_Shutdown_Index);
949
+//    pdata = &bluecell_Currdatastatus.ATT_UL2_PATH;
950
+    UL_Shutdown_Timer(pdata,DET_Alarm_UL2_Shutdown_Index);
951
+//    pdata = &bluecell_Currdatastatus.ATT_UL3_PATH;
952
+    UL_Shutdown_Timer(pdata,DET_Alarm_UL3_Shutdown_Index);
953
+//    pdata = &bluecell_Currdatastatus.ATT_UL4_PATH;
954
+    UL_Shutdown_Timer(pdata,DET_Alarm_UL4_Shutdown_Index);
955
+
956
+//    pdata = &bluecell_Currdatastatus.ATT_DL1_PATH;
957
+    DL_Shutdown_Timer(pdata,DET_Alarm_DL1_Shutdown_Index);
958
+//    pdata = &bluecell_Currdatastatus.ATT_DL2_PATH;
959
+    DL_Shutdown_Timer(pdata,DET_Alarm_DL2_Shutdown_Index);
960
+//    pdata = &bluecell_Currdatastatus.ATT_DL3_PATH;
961
+    DL_Shutdown_Timer(pdata,DET_Alarm_DL3_Shutdown_Index);
962
+//    pdata = &bluecell_Currdatastatus.ATT_DL4_PATH;
963
+    DL_Shutdown_Timer(pdata,DET_Alarm_DL4_Shutdown_Index);
964
+  
947 965
       /*ALC Alarm timer start*/
948 966
       if(ALC_AlarmSet[ALC_Alarm_UL1_Index] == true){
949 967
           ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;