Parcourir la source

DL Shutdown / DL Shutdown Alarm / UL ALC 어텐 제어 가능 하도록 수정 / DL Atten AGC ON 할 떄 Shutdown 은 AGC 어텐 동작 후 적용한다. Det Table 수정 /

AGC 동작 하도록 수정 / 첫 부팅시 retry Count 초기화 하도록 수정 Level Alarm 도 초기화 하도록 수정
PYJ il y a 5 ans
Parent
commit
bf0686b1ff
5 fichiers modifiés avec 405 ajouts et 168 suppressions
  1. 326 116
      Bluecell_Src/Bluecell_operate.c
  2. 18 0
      Bluecell_Src/eeprom.c
  3. 1 1
      Inc/main.h
  4. 13 9
      STM32F103ZET_JDASMBIC.elf.launch
  5. 47 42
      Src/main.c

+ 326 - 116
Bluecell_Src/Bluecell_operate.c

@@ -20,7 +20,7 @@
20
 #define ANSI_COLOR_BLUE    "\x1b[34m"
20
 #define ANSI_COLOR_BLUE    "\x1b[34m"
21
 #define ANSI_COLOR_MAGENTA "\x1b[35m"
21
 #define ANSI_COLOR_MAGENTA "\x1b[35m"
22
 #define ANSI_COLOR_CYAN    "\x1b[36m"
22
 #define ANSI_COLOR_CYAN    "\x1b[36m"
23
-#define ANSI_COLOR_RESET   "\x1b[0m"
23
+#define ANSI_COLOR_RESET   "\x1b[0m" "\r\n"    
24
 
24
 
25
 
25
 
26
 
26
 
@@ -143,6 +143,8 @@ TEMP_TABLE_st Temp_UL4;
143
 
143
 
144
 BLUESTATUS_st bluecell_Currdatastatus;
144
 BLUESTATUS_st bluecell_Currdatastatus;
145
 BLUESTATUS_st bluecell_Prevdatastatus;
145
 BLUESTATUS_st bluecell_Prevdatastatus;
146
+int16_t DL_AGC_StartAtten[AGC_Alarm_DL_Index_MAX] = {0,};
147
+int16_t DL_PrevIwillgiveAtten[AGC_Alarm_DL_Index_MAX] = {0,};
146
 
148
 
147
 
149
 
148
 #if 0 // PYJ.2020.05.21_BEGIN -- 
150
 #if 0 // PYJ.2020.05.21_BEGIN -- 
@@ -3646,6 +3648,18 @@ bool MBIC_Operate(uint8_t* data){
3646
             case  DLI_AGC_ON_OFF                   :
3648
             case  DLI_AGC_ON_OFF                   :
3647
                 /*AGC multi apply*/
3649
                 /*AGC multi apply*/
3648
                 bluecell_Currdatastatus.DLI_AGC_ON_OFF = data[MBIC_PAYLOADSTART + 3];
3650
                 bluecell_Currdatastatus.DLI_AGC_ON_OFF = data[MBIC_PAYLOADSTART + 3];
3651
+                DL_AGC_StartAtten[AGC_Alarm_DL1_Index] 
3652
+                    = bluecell_Currdatastatus.ATT_DL1_H << 8 | bluecell_Currdatastatus.ATT_DL1_L;
3653
+                DL_AGC_StartAtten[AGC_Alarm_DL2_Index] 
3654
+                    = bluecell_Currdatastatus.ATT_DL2_H << 8 | bluecell_Currdatastatus.ATT_DL2_L;
3655
+                DL_AGC_StartAtten[AGC_Alarm_DL3_Index] 
3656
+                    = bluecell_Currdatastatus.ATT_DL3_H << 8 | bluecell_Currdatastatus.ATT_DL3_L;
3657
+                DL_AGC_StartAtten[AGC_Alarm_DL4_Index] 
3658
+                    = bluecell_Currdatastatus.ATT_DL4_H << 8 | bluecell_Currdatastatus.ATT_DL4_L;
3659
+
3660
+                for(int i = 0; i < AGC_Alarm_DL_Index_MAX; i++){
3661
+                    DL_PrevIwillgiveAtten[i]= 0;                
3662
+                }
3649
                 break;
3663
                 break;
3650
             case  DLI_AGC_Threshold                       :
3664
             case  DLI_AGC_Threshold                       :
3651
                 bluecell_Currdatastatus.DLI_AGC_Threshold_H = data[MBIC_PAYLOADSTART + 3]; 
3665
                 bluecell_Currdatastatus.DLI_AGC_Threshold_H = data[MBIC_PAYLOADSTART + 3]; 
@@ -3657,7 +3671,15 @@ bool MBIC_Operate(uint8_t* data){
3657
                 break;
3671
                 break;
3658
             case  DLI_Shutdown_ON_OFF                     :
3672
             case  DLI_Shutdown_ON_OFF                     :
3659
                 bluecell_Currdatastatus.DLI_Shutdown_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
3673
                 bluecell_Currdatastatus.DLI_Shutdown_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
3660
-
3674
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 = 0;
3675
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 = 0;
3676
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3 = 0;
3677
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4 = 0;                
3678
+                for(int i = 0; i < DET_Alarm_DL_Index_MAX; i++){
3679
+                    DET_DL_Shutdown_Off_AlarmTimerCnt[i] = 0;
3680
+                    DET_DL_Shutdown_On_AlarmTimerCnt[i] = 0;
3681
+                    DET_DL_Normal_Shutdown_On_AlarmTimerCnt[i] = 0;
3682
+                }
3661
                 break;
3683
                 break;
3662
             case  DLI_Shutdown_Threshold                  :
3684
             case  DLI_Shutdown_Threshold                  :
3663
                 bluecell_Currdatastatus.DLI_Shutdown_Threshold_H = data[MBIC_PAYLOADSTART + 3]; 
3685
                 bluecell_Currdatastatus.DLI_Shutdown_Threshold_H = data[MBIC_PAYLOADSTART + 3]; 
@@ -3794,6 +3816,7 @@ bool MBIC_Operate(uint8_t* data){
3794
             case  ULO_ALC_ON_OFF                   :
3816
             case  ULO_ALC_ON_OFF                   :
3795
                 bluecell_Currdatastatus.ULO_ALC_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
3817
                 bluecell_Currdatastatus.ULO_ALC_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
3796
 
3818
 
3819
+
3797
                 break;
3820
                 break;
3798
             case  ULO_ALC_Threshold                       :
3821
             case  ULO_ALC_Threshold                       :
3799
                 bluecell_Currdatastatus.ULO_ALC_Threshold_H = data[MBIC_PAYLOADSTART + 3];
3822
                 bluecell_Currdatastatus.ULO_ALC_Threshold_H = data[MBIC_PAYLOADSTART + 3];
@@ -3816,7 +3839,18 @@ bool MBIC_Operate(uint8_t* data){
3816
             case  ULO_Shutdown_Threshold_Default          :
3839
             case  ULO_Shutdown_Threshold_Default          :
3817
                 bluecell_Currdatastatus.ULO_Shutdown_Threshold_Default = data[MBIC_PAYLOADSTART + 3]; 
3840
                 bluecell_Currdatastatus.ULO_Shutdown_Threshold_Default = data[MBIC_PAYLOADSTART + 3]; 
3818
 
3841
 
3819
-
3842
+            
3843
+                break;
3844
+            case ULO_ALC_Atten:
3845
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten1_H = data[MBIC_PAYLOADSTART + 3]; 
3846
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten1_L = data[MBIC_PAYLOADSTART + 4]; 
3847
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten2_H = data[MBIC_PAYLOADSTART + 5]; 
3848
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten2_L = data[MBIC_PAYLOADSTART + 6]; 
3849
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten3_H = data[MBIC_PAYLOADSTART + 7]; 
3850
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten3_L = data[MBIC_PAYLOADSTART + 8];                 
3851
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_H = data[MBIC_PAYLOADSTART + 9]; 
3852
+                bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_L = data[MBIC_PAYLOADSTART + 10];  
3853
+                CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
3820
                 break;
3854
                 break;
3821
         }
3855
         }
3822
         if(data[MBIC_PAYLOADSTART + data[MBIC_PAYLOADSTART + 2] + 3 ] == 0xE0 && occurlen > 0){
3856
         if(data[MBIC_PAYLOADSTART + data[MBIC_PAYLOADSTART + 2] + 3 ] == 0xE0 && occurlen > 0){
@@ -4167,6 +4201,7 @@ void DET_LevelAlarmCheck(){
4167
     */
4201
     */
4168
     uint8_t* DL_PathStatus = &bluecell_Currdatastatus.ATT_DL1_PATH ;
4202
     uint8_t* DL_PathStatus = &bluecell_Currdatastatus.ATT_DL1_PATH ;
4169
     uint8_t* DL_RetryCount = &bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 ;
4203
     uint8_t* DL_RetryCount = &bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 ;
4204
+#if 0 // PYJ.2020.06.23_BEGIN -- 
4170
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
4205
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
4171
         if(DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i] == true){
4206
         if(DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i] == true){
4172
             ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
4207
             ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
@@ -4187,7 +4222,45 @@ void DET_LevelAlarmCheck(){
4187
                 ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
4222
                 ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
4188
         }
4223
         }
4189
     }
4224
     }
4225
+#else
4226
+    int16_t DL_Atten[DET_Alarm_DL_Shutdown_Index_MAX] = {0,};
4227
+    
4228
+    DL_Atten[DET_Alarm_DL1_Index] = bluecell_Currdatastatus.ATT_DL1_H << 8 | bluecell_Currdatastatus.ATT_DL1_L;
4229
+    DL_Atten[DET_Alarm_DL2_Index] = bluecell_Currdatastatus.ATT_DL2_H << 8 | bluecell_Currdatastatus.ATT_DL2_L;
4230
+    DL_Atten[DET_Alarm_DL3_Index] = bluecell_Currdatastatus.ATT_DL3_H << 8 | bluecell_Currdatastatus.ATT_DL3_L;
4231
+    DL_Atten[DET_Alarm_DL4_Index] = bluecell_Currdatastatus.ATT_DL4_H << 8 | bluecell_Currdatastatus.ATT_DL4_L;
4232
+
4233
+
4234
+    for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
4235
+        if(DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i] == true
4236
+            && (LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
4237
+            && (MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)){
4238
+            ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
4239
+            if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
4240
+                if(DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){// Nomal Operate
4241
+                    DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] = 0;
4242
+//                    printf("DL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i],bluecell_Currdatastatus.DLO_Shutdown_Retry_Count2);
4243
+                }
4244
+            }
4245
+        }else{
4246
+            ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
4247
+        }
4248
+    }
4249
+    for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
4250
+        if(LimitData_DL_Shutdown <= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
4251
+            if(DL_Atten[DET_Alarm_DL1_Index + i] / 10 <= -15)
4252
+                ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
4253
+        }
4254
+        else{
4255
+//             if(LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
4256
+              if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)
4257
+                ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
4258
+        }
4259
+    }
4260
+
4261
+#endif // PYJ.2020.06.23_END -- 
4190
 //    printf("======================================================\r\n");
4262
 //    printf("======================================================\r\n");
4263
+#if 0 // PYJ.2020.06.23_BEGIN -- 
4191
     for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
4264
     for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
4192
         if(LimitData_DL_Low >= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
4265
         if(LimitData_DL_Low >= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
4193
             ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
4266
             ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
@@ -4197,6 +4270,20 @@ void DET_LevelAlarmCheck(){
4197
                 ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
4270
                 ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
4198
 
4271
 
4199
         }
4272
         }
4273
+#else
4274
+
4275
+        for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
4276
+            if(LimitData_DL_Low >= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
4277
+                    ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
4278
+            }
4279
+            else{
4280
+                if(LimitData_DL_Low + 2 <= Res_DL_dBm[DET_Alarm_DL1_Index + i])
4281
+                    ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
4282
+        
4283
+            }
4284
+
4285
+
4286
+#endif // PYJ.2020.06.23_END -- 
4200
         
4287
         
4201
 #if 0 // PYJ.2020.06.22_BEGIN -- 
4288
 #if 0 // PYJ.2020.06.22_BEGIN -- 
4202
         printf("LimitData_DL_Low: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",
4289
         printf("LimitData_DL_Low: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",
@@ -4243,6 +4330,7 @@ void DET_LevelAlarmCheck(){
4243
     */
4330
     */
4244
     uint8_t* UL_Alarm_Timer_Status = &bluecell_Currdatastatus.ULO_Level_High_Alarm1;
4331
     uint8_t* UL_Alarm_Timer_Status = &bluecell_Currdatastatus.ULO_Level_High_Alarm1;
4245
     uint8_t* UL_ADC = &bluecell_Currdatastatus.ULO_P1_Level1_H;
4332
     uint8_t* UL_ADC = &bluecell_Currdatastatus.ULO_P1_Level1_H;
4333
+    
4246
 //    LimitData_UL_High = -27;
4334
 //    LimitData_UL_High = -27;
4247
 //    printf("==========================================================\r\n");
4335
 //    printf("==========================================================\r\n");
4248
     for(int i = 0 ; i < DET_Alarm_UL_Index_MAX; i++){
4336
     for(int i = 0 ; i < DET_Alarm_UL_Index_MAX; i++){
@@ -4632,6 +4720,7 @@ double AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t siz
4632
     double step = 0;
4720
     double step = 0;
4633
     uint8_t LastIndex = 0;
4721
     uint8_t LastIndex = 0;
4634
     uint8_t dot = 0;
4722
     uint8_t dot = 0;
4723
+    double Lastdata = 0;    
4635
 //   printf("size: %d \r\n",size);
4724
 //   printf("size: %d \r\n",size);
4636
     for(int i =0; i < size / 2; i++){
4725
     for(int i =0; i < size / 2; i++){
4637
         TableAdc = CompareAdc[i * 2] << 8;
4726
         TableAdc = CompareAdc[i * 2] << 8;
@@ -4643,17 +4732,22 @@ double AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t siz
4643
         NextTableAdc = CompareAdc[i * 2 + 2] << 8;
4732
         NextTableAdc = CompareAdc[i * 2 + 2] << 8;
4644
         NextTableAdc += CompareAdc[i * 2 + 3];
4733
         NextTableAdc += CompareAdc[i * 2 + 3];
4645
         NextTableAdc /= 1000;        
4734
         NextTableAdc /= 1000;        
4735
+        Lastdata = TableAdc;
4646
 //        printf("TableAdc[%d] : %f \r\n",i,TableAdc);
4736
 //        printf("TableAdc[%d] : %f \r\n",i,TableAdc);
4647
-        CurrRet = TableAdc - CurrentAdc;
4737
+//        CurrRet = TableAdc - CurrentAdc;
4648
 
4738
 
4649
         step = (TableAdc - NextTableAdc) / 10;
4739
         step = (TableAdc - NextTableAdc) / 10;
4650
         for(int a = 0; a < 10; a++){
4740
         for(int a = 0; a < 10; a++){
4651
             Vitual_array[a] = TableAdc - (step * a);
4741
             Vitual_array[a] = TableAdc - (step * a);
4652
-            CurrRet = (Vitual_array[a]) - (CurrentAdc);
4653
-//            printf("Vitual_array[%d] : %f \r\n",a,Vitual_array[a]);
4654
-            if(CurrRet < 0){
4655
-                CurrRet = (CurrRet * -2) + CurrRet;
4742
+            if(Vitual_array[a] >= CurrentAdc){
4743
+                CurrRet = (Vitual_array[a]) - (CurrentAdc);
4744
+            }else{
4745
+                CurrRet = (CurrentAdc) - (Vitual_array[a]);
4656
             }
4746
             }
4747
+//            printf("Vitual_array[%d] : %f \r\n",a,Vitual_array[a]);
4748
+//            if(CurrRet < 0){
4749
+//                CurrRet = (CurrRet * -2) + CurrRet;
4750
+//            }
4657
             
4751
             
4658
             if(ret > CurrRet){
4752
             if(ret > CurrRet){
4659
                 ret = CurrRet;
4753
                 ret = CurrRet;
@@ -4666,6 +4760,10 @@ double AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t siz
4666
     TableAdc = CompareAdc[0] << 8;
4760
     TableAdc = CompareAdc[0] << 8;
4667
     TableAdc += CompareAdc[1];
4761
     TableAdc += CompareAdc[1];
4668
     TableAdc /= 1000;    
4762
     TableAdc /= 1000;    
4763
+
4764
+    if(Lastdata > CurrentAdc)
4765
+        return RefTable_Data[(size / 2) - 1]; 
4766
+    
4669
     if(CurrentAdc < TableAdc){
4767
     if(CurrentAdc < TableAdc){
4670
         for(int i = 0; i < sizeof(ALC_dBm_t); i++)
4768
         for(int i = 0; i < sizeof(ALC_dBm_t); i++)
4671
 //            printf("ref Tabe: %d \r\n",RefTable_Data[i]);
4769
 //            printf("ref Tabe: %d \r\n",RefTable_Data[i]);
@@ -4679,53 +4777,73 @@ double AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t siz
4679
 }
4777
 }
4680
 
4778
 
4681
 double AGC_AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t size,int8_t* RefTable_Data){
4779
 double AGC_AutoControl_ADC_Compare(double CurrentAdc,uint8_t* CompareAdc,uint8_t size,int8_t* RefTable_Data){
4682
-    double ret = 0xFF,CurrRet = 0,TableAdc,NextTableAdc; 
4780
+    double ret = 3.3,CurrRet = 0,TableAdc,NextTableAdc; 
4683
     double Vitual_array[10] = {0,};
4781
     double Vitual_array[10] = {0,};
4684
     double step = 0;
4782
     double step = 0;
4685
     uint8_t LastIndex = 0;
4783
     uint8_t LastIndex = 0;
4686
     uint8_t dot = 0;
4784
     uint8_t dot = 0;
4687
-    
4785
+    double Lastdata = 0;
4786
+    double Compare_Data = 0;
4787
+    double first_data = CompareAdc[0] << 8 | CompareAdc[1];
4688
     for(int i =0; i < size / 2; i++){
4788
     for(int i =0; i < size / 2; i++){
4689
         TableAdc = CompareAdc[i * 2] << 8;
4789
         TableAdc = CompareAdc[i * 2] << 8;
4690
         TableAdc += CompareAdc[i * 2 + 1];
4790
         TableAdc += CompareAdc[i * 2 + 1];
4691
         TableAdc /= 1000;
4791
         TableAdc /= 1000;
4692
-
4792
+        Lastdata = TableAdc;
4793
+        
4693
         NextTableAdc = CompareAdc[i * 2 + 2] << 8;
4794
         NextTableAdc = CompareAdc[i * 2 + 2] << 8;
4694
         NextTableAdc += CompareAdc[i * 2 + 3];
4795
         NextTableAdc += CompareAdc[i * 2 + 3];
4695
         NextTableAdc /= 1000;        
4796
         NextTableAdc /= 1000;        
4696
 //        printf("TableAdc[%d] : %f \r\n",i,TableAdc);
4797
 //        printf("TableAdc[%d] : %f \r\n",i,TableAdc);
4697
-        CurrRet = TableAdc - CurrentAdc;
4698
-
4699
-        step = (TableAdc - NextTableAdc) / 10;
4798
+//        CurrRet = TableAdc - CurrentAdc;
4799
+        if(TableAdc >= NextTableAdc){
4800
+            step = (TableAdc - NextTableAdc)/10;
4801
+        }else{
4802
+            step = (NextTableAdc - TableAdc) / 10;
4803
+        }
4700
         for(int a = 0; a < 10; a++){
4804
         for(int a = 0; a < 10; a++){
4701
             Vitual_array[a] = TableAdc - (step * a);
4805
             Vitual_array[a] = TableAdc - (step * a);
4702
-            CurrRet = (Vitual_array[a]) - (CurrentAdc);
4703
-//            printf("Vitual_array[%d] : %f \r\n",a,Vitual_array[a]);
4704
-            if(CurrRet < 0){
4705
-                CurrRet = (CurrRet * -2) + CurrRet;
4806
+            if(Vitual_array[a] >= CurrentAdc){
4807
+                CurrRet = Vitual_array[a] - CurrentAdc;
4808
+            }else{
4809
+                CurrRet = CurrentAdc - Vitual_array[a];
4706
             }
4810
             }
4811
+//            CurrRet = (Vitual_array[a]) - (CurrentAdc);
4812
+//            printf("Vitual_array[%d] : %f \r\n",a,Vitual_array[a]);
4813
+//            Compare_Data *= 1000;
4814
+
4815
+//            if(CurrRet < 0){
4816
+//                CurrRet = (CurrRet * -2) + CurrRet;
4817
+//            }
4707
             
4818
             
4708
             if(ret > CurrRet){
4819
             if(ret > CurrRet){
4709
                 ret = CurrRet;
4820
                 ret = CurrRet;
4710
                 LastIndex = i;
4821
                 LastIndex = i;
4822
+//                if(LastIndex == 30 && CurrentAdc != 0 ){
4823
+//                    printf("TableAdc[%d] : %f  step : %f  x a : %d\r\n",i,TableAdc,step,a);
4824
+//                    for(int k = 0; k < 10; k++)
4825
+//                        printf("Vitual_array[%d] : %f \r\n",k,Vitual_array[k]);
4826
+//                }
4827
+//                printf("ret : %f CurrRet  : %f  CurrentAdc : %f  %d.Vitual_array[a] : %f dot : %d\r\n",ret,CurrRet,CurrentAdc,i,Vitual_array[a],dot);
4711
                 dot = a;
4828
                 dot = a;
4712
             }
4829
             }
4713
         }
4830
         }
4714
         
4831
         
4715
     }
4832
     }
4716
-    TableAdc = CompareAdc[0] << 8;
4717
-    TableAdc += CompareAdc[1];
4718
-    TableAdc /= 1000;    
4719
-    if(CurrentAdc < TableAdc){
4720
-//        printf("LastIndex : %d  / dot : %d  TableAdc : %f \r\n",LastIndex,dot,(RefTable_Data[LastIndex] - (dot * 0.1)));
4721
-        return (RefTable_Data[LastIndex] - (dot * 0.1));
4833
+    if(Lastdata > CurrentAdc){
4834
+//        printf("RefTable_Data[(size / 2) - 1] : %d \r\n",RefTable_Data[(size / 2) - 1]);
4835
+        return RefTable_Data[(size / 2) - 1];
4722
     }
4836
     }
4723
-    else{
4724
 //        printf("CurrentAdc : %f     TableAdc : %f \r\n",CurrentAdc,TableAdc);
4837
 //        printf("CurrentAdc : %f     TableAdc : %f \r\n",CurrentAdc,TableAdc);
4725
 //        for(int a = 0; a < sizeof(AGC_dBm_t); a++)
4838
 //        for(int a = 0; a < sizeof(AGC_dBm_t); a++)
4726
 //            printf("AutoControl_Save[%d] : %d \r\n",a,AutoControl_Save[a]);
4839
 //            printf("AutoControl_Save[%d] : %d \r\n",a,AutoControl_Save[a]);
4727
-            
4840
+    if(first_data < CurrentAdc){
4841
+        printf("(RefTable_Data[0]) : %d \r\n",(RefTable_Data[0]));
4728
         return (RefTable_Data[0]);
4842
         return (RefTable_Data[0]);
4843
+    }else{
4844
+        printf("Nomal _Table Data %f",(RefTable_Data[LastIndex] - (dot * 0.1)));
4845
+        printf("LastIndex : %d  / dot : %d  TableAdc : %f \r\n",LastIndex,dot,(RefTable_Data[LastIndex] - (dot * 0.1)));
4846
+        return (RefTable_Data[LastIndex] - (dot * 0.1));
4729
     }
4847
     }
4730
 }
4848
 }
4731
 
4849
 
@@ -4811,24 +4929,24 @@ int16_t ALC_Calc(uint8_t num,double CurrAtten ,int8_t threshold,double CurrDet){
4811
 #endif // PYJ.2020.06.20_END -- 
4929
 #endif // PYJ.2020.06.20_END -- 
4812
     if(threshold < CurrDet){
4930
     if(threshold < CurrDet){
4813
         ret = CurrDet - threshold ;
4931
         ret = CurrDet - threshold ;
4814
-        printf("1. %f : %f - %d\r\n",ret,CurrDet,threshold);
4932
+//        printf("1. %f : %f - %d\r\n",ret,CurrDet,threshold);
4815
 
4933
 
4816
         
4934
         
4817
-        printf("2. %f : %f - %d\r\n",ret,CurrDet,threshold);
4935
+//        printf("2. %f : %f - %d\r\n",ret,CurrDet,threshold);
4818
         ret = Bluecell_TestPro(ret +( CurrAtten * -1));
4936
         ret = Bluecell_TestPro(ret +( CurrAtten * -1));
4819
         ret *= -1;        
4937
         ret *= -1;        
4820
     }
4938
     }
4821
     else if(threshold -2 > CurrDet){
4939
     else if(threshold -2 > CurrDet){
4822
         if(CurrAtten < 0){
4940
         if(CurrAtten < 0){
4823
             ret =  (threshold - 2) - CurrDet ;// -27 ///// - 29
4941
             ret =  (threshold - 2) - CurrDet ;// -27 ///// - 29
4824
-            printf("%f  =  %d - %f\r\n",ret,(threshold - 2),CurrDet);
4825
-            printf("CurrAtten : %f\r\n",CurrAtten);
4942
+//            printf("%f  =  %d - %f\r\n",ret,(threshold - 2),CurrDet);
4943
+//            printf("CurrAtten : %f\r\n",CurrAtten);
4826
             ret = Bluecell_TestPro(ret);
4944
             ret = Bluecell_TestPro(ret);
4827
-            printf("3.ret : %f\r\n",ret);
4945
+//            printf("3.ret : %f\r\n",ret);
4828
             ret += CurrAtten;
4946
             ret += CurrAtten;
4829
 //             ret *= -1;     
4947
 //             ret *= -1;     
4830
              
4948
              
4831
-            printf("4.ret : %f\r\n",ret);
4949
+//            printf("4.ret : %f\r\n",ret);
4832
         }
4950
         }
4833
          
4951
          
4834
     }
4952
     }
@@ -4836,17 +4954,17 @@ int16_t ALC_Calc(uint8_t num,double CurrAtten ,int8_t threshold,double CurrDet){
4836
 
4954
 
4837
     
4955
     
4838
     if(ret < -20){
4956
     if(ret < -20){
4839
-        printf("5. ret1 : %f \r\n",ret);
4957
+//        printf("5. ret1 : %f \r\n",ret);
4840
         ret = -20;
4958
         ret = -20;
4841
         ALC_AlarmSet[num] = true;
4959
         ALC_AlarmSet[num] = true;
4842
     }else{
4960
     }else{
4843
         if(ret > 0){
4961
         if(ret > 0){
4844
-            printf("6. ret1 : %f \r\n",ret);
4962
+//            printf("6. ret1 : %f \r\n",ret);
4845
             ret = 0;
4963
             ret = 0;
4846
         }
4964
         }
4847
         ALC_AlarmSet[num] = false; 
4965
         ALC_AlarmSet[num] = false; 
4848
     }
4966
     }
4849
-    printf("ret7 : %f \r\n",ret);
4967
+//    printf("ret7 : %f \r\n",ret);
4850
     return ret * 10;
4968
     return ret * 10;
4851
 }
4969
 }
4852
 #define UL_DL_DATASEND_MULTIPLE 10
4970
 #define UL_DL_DATASEND_MULTIPLE 10
@@ -5246,6 +5364,7 @@ void AGC_Alarm_Check(uint8_t Path_Index,double AGC_Det,uint8_t* AGC_Table,uint16
5246
 }
5364
 }
5247
 
5365
 
5248
 
5366
 
5367
+
5249
 void AGC_Function(){//DL
5368
 void AGC_Function(){//DL
5250
     double ret = 0;
5369
     double ret = 0;
5251
     int8_t ResdBm = 0;
5370
     int8_t ResdBm = 0;
@@ -5256,16 +5375,30 @@ void AGC_Function(){//DL
5256
     int16_t IwillgiveAtten = 0;
5375
     int16_t IwillgiveAtten = 0;
5257
     int16_t ResultData = 0;
5376
     int16_t ResultData = 0;
5258
     static int8_t* AGC_Table;// = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
5377
     static int8_t* AGC_Table;// = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
5259
-
5378
+    int16_t DL_Curr_Atten[AGC_Alarm_DL_Index_MAX] = {
5379
+        bluecell_Currdatastatus.ATT_DL1_H  << 8 | bluecell_Currdatastatus.ATT_DL1_L,
5380
+        bluecell_Currdatastatus.ATT_DL2_H  << 8 | bluecell_Currdatastatus.ATT_DL2_L,
5381
+        bluecell_Currdatastatus.ATT_DL3_H  << 8 | bluecell_Currdatastatus.ATT_DL3_L,
5382
+        bluecell_Currdatastatus.ATT_DL4_H  << 8 | bluecell_Currdatastatus.ATT_DL4_L,        
5383
+    };
5260
          
5384
          
5261
     if(AGCTimerCnt > 100){
5385
     if(AGCTimerCnt > 100){
5262
         
5386
         
5263
 
5387
 
5264
         if(bluecell_Currdatastatus.DLI_AGC_ON_OFF == true){
5388
         if(bluecell_Currdatastatus.DLI_AGC_ON_OFF == true){
5265
-            
5266
-#if 1 // PYJ.2020.05.25_BEGIN -- 
5389
+            Limitdata = (( bluecell_Currdatastatus.DLI_AGC_Threshold_H << 8) & 0xFF00) ;
5390
+            Limitdata +=  bluecell_Currdatastatus.DLI_AGC_Threshold_L ;
5391
+            Limitdata /= 10; 
5392
+        DL_Curr_Atten[AGC_Alarm_DL1_Index] = 
5393
+            bluecell_Currdatastatus.ATT_DL1_H  << 8 | bluecell_Currdatastatus.ATT_DL1_L;
5394
+        DL_Curr_Atten[AGC_Alarm_DL2_Index] = 
5395
+            bluecell_Currdatastatus.ATT_DL2_H  << 8 | bluecell_Currdatastatus.ATT_DL2_L;
5396
+        DL_Curr_Atten[AGC_Alarm_DL3_Index] = 
5397
+            bluecell_Currdatastatus.ATT_DL3_H  << 8 | bluecell_Currdatastatus.ATT_DL3_L;        
5398
+        DL_Curr_Atten[AGC_Alarm_DL4_Index] = 
5399
+            bluecell_Currdatastatus.ATT_DL4_H  << 8 | bluecell_Currdatastatus.ATT_DL4_L;            
5400
+#if 0 // PYJ.2020.06.23_BEGIN -- 
5267
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
5401
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
5268
-
5269
             ret  = bluecell_Currdatastatus.DLI_P1_Level1_H << 8;
5402
             ret  = bluecell_Currdatastatus.DLI_P1_Level1_H << 8;
5270
             ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
5403
             ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
5271
             ret *= 0.001;
5404
             ret *= 0.001;
@@ -5273,43 +5406,25 @@ void AGC_Function(){//DL
5273
             ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL1.Table_Length * 2,AGC_Table));
5406
             ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL1.Table_Length * 2,AGC_Table));
5274
              bluecell_Currdatastatus.DLI_Level1_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5407
              bluecell_Currdatastatus.DLI_Level1_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5275
              bluecell_Currdatastatus.DLI_Level1_L = ((int16_t)ResdBm & 0x00FF);
5408
              bluecell_Currdatastatus.DLI_Level1_L = ((int16_t)ResdBm & 0x00FF);
5276
-
5277
-                        //ret 현재 Voltage 값 출력
5278
-            //ret 에 따른 현재 DBM 구현
5279
-          
5280
             for(i = 0; i < sizeof(AGC_dBm_t); i++){
5409
             for(i = 0; i < sizeof(AGC_dBm_t); i++){
5281
                 if(AGC_Table[i] == ResdBm)
5410
                 if(AGC_Table[i] == ResdBm)
5282
                     break;
5411
                     break;
5283
             }
5412
             }
5284
-            Limitdata = (( bluecell_Currdatastatus.DLI_AGC_Threshold_H << 8) & 0xFF00) ;
5285
-            Limitdata +=  bluecell_Currdatastatus.DLI_AGC_Threshold_L ;
5286
-            Limitdata /= 10;
5287
-
5288
-#if 0 // PYJ.2020.06.22_BEGIN -- 
5289
-            printf(ANSI_COLOR_YELLOW     "=================AGC ON =================\r\n"ANSI_COLOR_RESET "\n");
5290
-            printf(ANSI_COLOR_YELLOW     "Current DL1 ADC VALUE : %f \r\n"ANSI_COLOR_RESET "\n",ret);
5291
-            printf(ANSI_COLOR_YELLOW     "ResdBm : DL1 : %d \r\n"ANSI_COLOR_RESET "\n",ResdBm);
5292
-            printf(ANSI_COLOR_YELLOW     "AGC_Table[%d] : %d\r\n"ANSI_COLOR_RESET "\n",i,AGC_Table[i]);
5293
-            printf(ANSI_COLOR_YELLOW     "I WILL GIVE YOU ATTEN  : %d\r\n"ANSI_COLOR_RESET "\n",AGC_Calc(Limitdata,ResdBm));            
5294
-            printf(ANSI_COLOR_YELLOW     "AGC  : %d\r\n"ANSI_COLOR_RESET "\n",Limitdata);            
5295
-#endif // PYJ.2020.06.22_END -- 
5296
-//            HAL_Delay(1000);
5297
-
5298
             IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5413
             IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5299
             IwillgiveAtten *= -1; 
5414
             IwillgiveAtten *= -1; 
5300
-
5301
             AGC_Alarm_Check(AGC_Alarm_DL1_Index,ret,&Det_DL1.Table_Det5_dBm_H,IwillgiveAtten);
5415
             AGC_Alarm_Check(AGC_Alarm_DL1_Index,ret,&Det_DL1.Table_Det5_dBm_H,IwillgiveAtten);
5302
             bluecell_Currdatastatus.ATT_DL1_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5416
             bluecell_Currdatastatus.ATT_DL1_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5303
             bluecell_Currdatastatus.ATT_DL1_L = (((IwillgiveAtten * 10) & 0x00FF));     
5417
             bluecell_Currdatastatus.ATT_DL1_L = (((IwillgiveAtten * 10) & 0x00FF));     
5304
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5418
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5419
+#endif // PYJ.2020.06.23_END -- 
5305
 
5420
 
5306
 
5421
 
5307
 
5422
 
5308
 
5423
 
5424
+#if 1 // PYJ.2020.05.25_BEGIN -- 
5309
 #if 1// PYJ.2020.06.22_BEGIN -- 
5425
 #if 1// PYJ.2020.06.22_BEGIN -- 
5310
-        AGC_Table = &AGC_Table_ref[MBIC_Table_DL2_INDEX].DET_DL_0;
5311
-
5312
-
5426
+#if 0 // PYJ.2020.06.23_BEGIN -- 
5427
+       AGC_Table = &AGC_Table_ref[MBIC_Table_DL2_INDEX].DET_DL_0;
5313
        ret  = bluecell_Currdatastatus.DLI_P2_Level2_H << 8;
5428
        ret  = bluecell_Currdatastatus.DLI_P2_Level2_H << 8;
5314
        ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
5429
        ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
5315
        ret *= 0.001;
5430
        ret *= 0.001;
@@ -5321,19 +5436,7 @@ void AGC_Function(){//DL
5321
            if(AGC_Table[i] == ResdBm)
5436
            if(AGC_Table[i] == ResdBm)
5322
                break;
5437
                break;
5323
        }
5438
        }
5324
-       Limitdata = (( bluecell_Currdatastatus.DLI_AGC_Threshold_H << 8) & 0xFF00) ;
5325
-       Limitdata +=  bluecell_Currdatastatus.DLI_AGC_Threshold_L ;
5326
-       Limitdata /= 10;
5327
    
5439
    
5328
-#if 0 // PYJ.2020.06.21_BEGIN -- 
5329
-        printf("========AGC ON==========START================\r\n");
5330
-        printf("Current DL2 ADC VALUE : %f \r\n",ret);
5331
-        printf("ResdBm : DL2 : %d \r\n",ResdBm);
5332
-        printf("AGC_Table[%d] : %d\r\n",i,AGC_Table[i]);
5333
-        printf("I WILL GIVE YOU ATTEN  : %d\r\n",AGC_Calc(Limitdata,ResdBm));            
5334
-        printf("AGC  : %d\r\n",Limitdata);            
5335
-#endif // PYJ.2020.06.21_END -- 
5336
-//        HAL_Delay(1000);
5337
 
5440
 
5338
        IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5441
        IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5339
        AGC_Alarm_Check(AGC_Alarm_DL2_Index,ret,&Det_DL2.Table_Det5_dBm_H,IwillgiveAtten);
5442
        AGC_Alarm_Check(AGC_Alarm_DL2_Index,ret,&Det_DL2.Table_Det5_dBm_H,IwillgiveAtten);
@@ -5341,15 +5444,73 @@ void AGC_Function(){//DL
5341
        bluecell_Currdatastatus.ATT_DL2_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5444
        bluecell_Currdatastatus.ATT_DL2_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5342
        bluecell_Currdatastatus.ATT_DL2_L = (((IwillgiveAtten * 10) & 0x00FF));     
5445
        bluecell_Currdatastatus.ATT_DL2_L = (((IwillgiveAtten * 10) & 0x00FF));     
5343
        CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5446
        CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5447
+#endif // PYJ.2020.06.23_END -- 
5448
+        AGC_Table = &AGC_Table_ref[MBIC_Table_DL1_INDEX].DET_DL_0;
5449
+        ret  = bluecell_Currdatastatus.DLI_P1_Level1_H << 8;
5450
+        ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
5451
+        ret *= 0.001;
5452
+        ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL1.Table_Length * 2,AGC_Table));
5453
+        bluecell_Currdatastatus.DLI_Level1_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5454
+        bluecell_Currdatastatus.DLI_Level1_L = ((int16_t)ResdBm & 0x00FF);
5455
+        for(i = 0; i < sizeof(AGC_dBm_t); i++){
5456
+            if(AGC_Table[i] == ResdBm)
5457
+                break;
5458
+        }
5459
+        IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5460
+        IwillgiveAtten *= -1;
5461
+//        printf("==================================\r\n");
5462
+//        printf("Current DL1 ADC VALUE : %f \r\n",ret);
5463
+//        printf("ResdBm : DL1 : %d \r\n",ResdBm);
5464
+//        printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);            
5465
+//        printf("AGC  : %d\r\n",Limitdata);            
5466
+
5467
+
5468
+        if(ResdBm > Limitdata &&  DL_PrevIwillgiveAtten[AGC_Alarm_DL1_Index] > IwillgiveAtten){
5469
+//            printf("IwillgiveAtten : %d \r\n",IwillgiveAtten);
5470
+            DL_PrevIwillgiveAtten[AGC_Alarm_DL1_Index] = IwillgiveAtten;
5471
+            IwillgiveAtten = (DL_AGC_StartAtten[AGC_Alarm_DL1_Index]/10) + IwillgiveAtten;
5472
+//            printf("WILLATTEN RET : %d \r\n",IwillgiveAtten);
5473
+            AGC_Alarm_Check(AGC_Alarm_DL1_Index,ret,&Det_DL1.Table_Det5_dBm_H,IwillgiveAtten);
5474
+            bluecell_Currdatastatus.ATT_DL1_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5475
+            bluecell_Currdatastatus.ATT_DL1_L = (((IwillgiveAtten * 10) & 0x00FF));     
5476
+            CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5477
+        }
5478
+        AGC_Table = &AGC_Table_ref[MBIC_Table_DL2_INDEX].DET_DL_0;
5479
+        ret  = bluecell_Currdatastatus.DLI_P2_Level2_H << 8;
5480
+        ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
5481
+        ret *= 0.001;
5482
+        ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL2.Table_Det5_dBm_H,Det_DL2.Table_Length * 2,AGC_Table));
5483
+        bluecell_Currdatastatus.DLI_Level2_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5484
+        bluecell_Currdatastatus.DLI_Level2_L = ((int16_t)ResdBm & 0x00FF);
5485
+        for(i = 0; i < sizeof(AGC_dBm_t); i++){
5486
+            if(AGC_Table[i] == ResdBm)
5487
+                break;
5488
+        }
5489
+        IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5490
+        IwillgiveAtten *= -1;
5491
+//        printf("==================================\r\n");
5492
+//        printf("Current DL2 ADC VALUE : %f \r\n",ret);
5493
+//        printf("ResdBm : DL2 : %d \r\n",ResdBm);
5494
+//        printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);            
5495
+//        printf("AGC  : %d\r\n",Limitdata);            
5496
+
5497
+
5498
+        if(ResdBm > Limitdata &&  DL_PrevIwillgiveAtten[AGC_Alarm_DL2_Index] > IwillgiveAtten){
5499
+//            printf("IwillgiveAtten : %d \r\n",IwillgiveAtten);
5500
+            DL_PrevIwillgiveAtten[AGC_Alarm_DL2_Index] = IwillgiveAtten;
5501
+            IwillgiveAtten = (DL_AGC_StartAtten[AGC_Alarm_DL2_Index]/10) + IwillgiveAtten;
5502
+//            printf("WILLATTEN RET : %d \r\n",IwillgiveAtten);
5503
+            AGC_Alarm_Check(AGC_Alarm_DL2_Index,ret,&Det_DL2.Table_Det5_dBm_H,IwillgiveAtten);
5504
+            bluecell_Currdatastatus.ATT_DL2_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5505
+            bluecell_Currdatastatus.ATT_DL2_L = (((IwillgiveAtten * 10) & 0x00FF));     
5506
+            CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5507
+        }
5344
 
5508
 
5345
 
5509
 
5346
         AGC_Table = &AGC_Table_ref[MBIC_Table_DL3_INDEX].DET_DL_0;
5510
         AGC_Table = &AGC_Table_ref[MBIC_Table_DL3_INDEX].DET_DL_0;
5347
-
5348
-
5349
         ret  = bluecell_Currdatastatus.DLI_P3_Level3_H << 8;
5511
         ret  = bluecell_Currdatastatus.DLI_P3_Level3_H << 8;
5350
         ret += bluecell_Currdatastatus.DLI_P3_Level3_L;   
5512
         ret += bluecell_Currdatastatus.DLI_P3_Level3_L;   
5351
         ret *= 0.001;
5513
         ret *= 0.001;
5352
-        
5353
         ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,Det_DL3.Table_Length * 2,AGC_Table));
5514
         ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,Det_DL3.Table_Length * 2,AGC_Table));
5354
         bluecell_Currdatastatus.DLI_Level3_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5515
         bluecell_Currdatastatus.DLI_Level3_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5355
         bluecell_Currdatastatus.DLI_Level3_L = ((int16_t)ResdBm & 0x00FF);
5516
         bluecell_Currdatastatus.DLI_Level3_L = ((int16_t)ResdBm & 0x00FF);
@@ -5357,28 +5518,63 @@ void AGC_Function(){//DL
5357
             if(AGC_Table[i] == ResdBm)
5518
             if(AGC_Table[i] == ResdBm)
5358
                 break;
5519
                 break;
5359
         }
5520
         }
5360
-        Limitdata = (( bluecell_Currdatastatus.DLI_AGC_Threshold_H << 8) & 0xFF00) ;
5361
-        Limitdata +=  bluecell_Currdatastatus.DLI_AGC_Threshold_L ;
5362
-        Limitdata /= 10;
5363
-    
5364
-//            printf("==================================\r\n");
5365
-//            printf("Current DL3 ADC VALUE : %f \r\n",ret);
5366
-//            printf("ResdBm : DL3 : %d \r\n",ResdBm);
5367
-//            printf("AGC_Table[%d] : %d\r\n",i,AGC_Table[i]);
5368
-//            printf("I WILL GIVE YOU ATTEN  : %d\r\n",AGC_Calc(Limitdata,ResdBm));            
5369
-//            printf("AGC  : %d\r\n",Limitdata);            
5370
-//            HAL_Delay(1000);
5371
-
5372
         IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5521
         IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5373
-        AGC_Alarm_Check(AGC_Alarm_DL3_Index,ret,&Det_DL3.Table_Det5_dBm_H,IwillgiveAtten);
5374
-
5375
-        bluecell_Currdatastatus.ATT_DL3_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5376
-        bluecell_Currdatastatus.ATT_DL3_L = (((IwillgiveAtten * 10) & 0x00FF));     
5377
-        CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5522
+        IwillgiveAtten *= -1;
5523
+//        printf("==================================\r\n");
5524
+//        printf("Current DL3 ADC VALUE : %f \r\n",ret);
5525
+//        printf("ResdBm : DL3 : %d \r\n",ResdBm);
5526
+//        printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);            
5527
+//        printf("AGC  : %d\r\n",Limitdata);            
5528
+
5529
+
5530
+        if(ResdBm > Limitdata &&  DL_PrevIwillgiveAtten[AGC_Alarm_DL3_Index] > IwillgiveAtten){
5531
+//            printf("IwillgiveAtten : %d \r\n",IwillgiveAtten);
5532
+            DL_PrevIwillgiveAtten[AGC_Alarm_DL3_Index] = IwillgiveAtten;
5533
+            IwillgiveAtten = (DL_AGC_StartAtten[AGC_Alarm_DL3_Index]/10) + IwillgiveAtten;
5534
+//            printf("WILLATTEN RET : %d \r\n",IwillgiveAtten);
5535
+            AGC_Alarm_Check(AGC_Alarm_DL3_Index,ret,&Det_DL3.Table_Det5_dBm_H,IwillgiveAtten);
5536
+            bluecell_Currdatastatus.ATT_DL3_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5537
+            bluecell_Currdatastatus.ATT_DL3_L = (((IwillgiveAtten * 10) & 0x00FF));     
5538
+            CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5539
+        }
5540
+//        printf("DL_Curr_Atten[AGC_Alarm_DL3_Index] : %d  \r\n",DL_Curr_Atten[AGC_Alarm_DL3_Index]);
5541
+//            IwillgiveAtten < DL_Curr_Atten[AGC_Alarm_DL3_Index];
5542
+        
5543
+        AGC_Table = &AGC_Table_ref[MBIC_Table_DL4_INDEX].DET_DL_0;
5544
+        ret  = bluecell_Currdatastatus.DLI_P4_Level4_H << 8;
5545
+        ret += bluecell_Currdatastatus.DLI_P4_Level4_L;   
5546
+        ret *= 0.001;
5547
+        ResdBm = (int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL4.Table_Det5_dBm_H,Det_DL4.Table_Length * 2,AGC_Table));
5548
+        bluecell_Currdatastatus.DLI_Level4_H = ((int16_t)ResdBm & 0xFF00) >> 8;
5549
+        bluecell_Currdatastatus.DLI_Level4_L = ((int16_t)ResdBm & 0x00FF);
5550
+        for(i = 0; i < sizeof(AGC_dBm_t); i++){
5551
+            if(AGC_Table[i] == ResdBm)
5552
+                break;
5553
+        }
5554
+        IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
5555
+        IwillgiveAtten *= -1;
5556
+//        printf("==================================\r\n");
5557
+//        printf("Current DL4 ADC VALUE : %f \r\n",ret);
5558
+//        printf("ResdBm : DL4 : %d \r\n",ResdBm);
5559
+//        printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);            
5560
+//        printf("AGC  : %d\r\n",Limitdata);            
5561
+
5562
+
5563
+        if(ResdBm > Limitdata &&  DL_PrevIwillgiveAtten[AGC_Alarm_DL4_Index] > IwillgiveAtten){
5564
+//            printf("IwillgiveAtten : %d \r\n",IwillgiveAtten);
5565
+            DL_PrevIwillgiveAtten[AGC_Alarm_DL4_Index] = IwillgiveAtten;
5566
+            IwillgiveAtten = (DL_AGC_StartAtten[AGC_Alarm_DL4_Index]/10) + IwillgiveAtten;
5567
+//            printf("WILLATTEN RET : %d \r\n",IwillgiveAtten);
5568
+            AGC_Alarm_Check(AGC_Alarm_DL4_Index,ret,&Det_DL4.Table_Det5_dBm_H,IwillgiveAtten);
5569
+            bluecell_Currdatastatus.ATT_DL4_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5570
+            bluecell_Currdatastatus.ATT_DL4_L = (((IwillgiveAtten * 10) & 0x00FF));     
5571
+            CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5572
+        }
5378
 
5573
 
5379
 
5574
 
5380
 
5575
 
5381
 
5576
 
5577
+#if 0 // PYJ.2020.06.23_BEGIN -- 
5382
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL4_INDEX].DET_DL_0;
5578
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL4_INDEX].DET_DL_0;
5383
 
5579
 
5384
             ret  = bluecell_Currdatastatus.DLI_P4_Level4_H << 8;
5580
             ret  = bluecell_Currdatastatus.DLI_P4_Level4_H << 8;
@@ -5408,6 +5604,7 @@ void AGC_Function(){//DL
5408
             bluecell_Currdatastatus.ATT_DL4_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5604
             bluecell_Currdatastatus.ATT_DL4_H = (((IwillgiveAtten * 10) & 0xFF00) >> 8) ;
5409
             bluecell_Currdatastatus.ATT_DL4_L = (((IwillgiveAtten * 10) & 0x00FF));     
5605
             bluecell_Currdatastatus.ATT_DL4_L = (((IwillgiveAtten * 10) & 0x00FF));     
5410
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5606
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
5607
+#endif // PYJ.2020.06.23_END -- 
5411
 #endif // PYJ.2020.05.25_END --             
5608
 #endif // PYJ.2020.05.25_END --             
5412
 #endif // PYJ.2020.06.22_END -- 
5609
 #endif // PYJ.2020.06.22_END -- 
5413
         }else{
5610
         }else{
@@ -5420,11 +5617,11 @@ void AGC_Function(){//DL
5420
             Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL2.Table_Length * 2,AGC_Table));
5617
             Levelret = (int16_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,Det_DL2.Table_Length * 2,AGC_Table));
5421
             bluecell_Currdatastatus.DLI_Level1_H = (Levelret & 0xFF00) >> 8;
5618
             bluecell_Currdatastatus.DLI_Level1_H = (Levelret & 0xFF00) >> 8;
5422
             bluecell_Currdatastatus.DLI_Level1_L = (Levelret & 0x00FF);
5619
             bluecell_Currdatastatus.DLI_Level1_L = (Levelret & 0x00FF);
5423
-#if 0 // PYJ.2020.06.20_BEGIN -- 
5620
+#if 1 // PYJ.2020.06.20_BEGIN -- 
5424
             printf("========AGC OFF==========START================\r\n");
5621
             printf("========AGC OFF==========START================\r\n");
5425
-            printf("Current DL1 ADC VALUE : %f \r\n",ret);
5622
+            printf(ANSI_COLOR_YELLOW"Current DL1 ADC VALUE : %f \r\n"ANSI_COLOR_RESET,ret);
5426
             printf("AGC_Table[%d] : %d\r\n",i,AGC_Table[i]);
5623
             printf("AGC_Table[%d] : %d\r\n",i,AGC_Table[i]);
5427
-            printf("Levelret : DL1 : %d \r\n",Levelret);
5624
+            printf(ANSI_COLOR_YELLOW "Levelret : DL1 : %d \r\n"ANSI_COLOR_RESET ,Levelret);
5428
             printf("Levelret  : %x /////  bluecell_Currdatastatus.DLI_Level1_H : %x \r\n",Levelret,bluecell_Currdatastatus.DLI_Level1_H);
5625
             printf("Levelret  : %x /////  bluecell_Currdatastatus.DLI_Level1_H : %x \r\n",Levelret,bluecell_Currdatastatus.DLI_Level1_H);
5429
             printf("Levelret  : %x /////  bluecell_Currdatastatus.DLI_Level1_L : %x \r\n",Levelret,bluecell_Currdatastatus.DLI_Level1_L);            
5626
             printf("Levelret  : %x /////  bluecell_Currdatastatus.DLI_Level1_L : %x \r\n",Levelret,bluecell_Currdatastatus.DLI_Level1_L);            
5430
             printf("==================END================\r\n");        
5627
             printf("==================END================\r\n");        
@@ -5435,6 +5632,7 @@ void AGC_Function(){//DL
5435
 //              printf("ResdBm : DL1 : %d \r\n",ResdBm);
5632
 //              printf("ResdBm : DL1 : %d \r\n",ResdBm);
5436
 //            HAL_Delay(1000);
5633
 //            HAL_Delay(1000);
5437
 
5634
 
5635
+#if 1 // PYJ.2020.06.23_BEGIN -- 
5438
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL2_INDEX].DET_DL_0;
5636
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL2_INDEX].DET_DL_0;
5439
             ret  = bluecell_Currdatastatus.DLI_P2_Level2_H << 8;
5637
             ret  = bluecell_Currdatastatus.DLI_P2_Level2_H << 8;
5440
             ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
5638
             ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
@@ -5464,6 +5662,7 @@ void AGC_Function(){//DL
5464
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL4_INDEX].DET_DL_0;
5662
             AGC_Table = &AGC_Table_ref[MBIC_Table_DL4_INDEX].DET_DL_0;
5465
             bluecell_Currdatastatus.DLI_Level4_H = (Levelret & 0xFF00) >> 8;
5663
             bluecell_Currdatastatus.DLI_Level4_H = (Levelret & 0xFF00) >> 8;
5466
             bluecell_Currdatastatus.DLI_Level4_L = (Levelret & 0x00FF);
5664
             bluecell_Currdatastatus.DLI_Level4_L = (Levelret & 0x00FF);
5665
+#endif // PYJ.2020.06.23_END -- 
5467
 
5666
 
5468
 
5667
 
5469
         }
5668
         }
@@ -5843,20 +6042,21 @@ void DLI_ShutdownAlarmCheck()
5843
 {
6042
 {
5844
 
6043
 
5845
 
6044
 
5846
-        
5847
-    if(bluecell_Currdatastatus.DLI_Shutdown_ON_OFF == true){
5848
 
6045
 
6046
+    
6047
+    if(bluecell_Currdatastatus.DLI_Shutdown_ON_OFF == true){
6048
+         
5849
         /***************************************************************************************************************/
6049
         /***************************************************************************************************************/
5850
         /*                                             SHUTDOWN DL1                                                    */
6050
         /*                                             SHUTDOWN DL1                                                    */
5851
         /***************************************************************************************************************/  
6051
         /***************************************************************************************************************/  
5852
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] < 3
6052
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] < 3
5853
-            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] != MBIC_UL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index])
6053
+            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index])
5854
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6054
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
5855
             HAL_GPIO_WritePin(PATH_EN_DL1_GPIO_Port,PATH_EN_DL1_Pin,GPIO_PIN_SET);//CLOCK
6055
             HAL_GPIO_WritePin(PATH_EN_DL1_GPIO_Port,PATH_EN_DL1_Pin,GPIO_PIN_SET);//CLOCK
5856
             bluecell_Currdatastatus.ATT_DL1_PATH = true;            
6056
             bluecell_Currdatastatus.ATT_DL1_PATH = true;            
5857
             bluecell_Prevdatastatus.ATT_DL1_H = 0xFF;
6057
             bluecell_Prevdatastatus.ATT_DL1_H = 0xFF;
5858
             bluecell_Prevdatastatus.ATT_DL1_L = 0xFF;
6058
             bluecell_Prevdatastatus.ATT_DL1_L = 0xFF;
5859
-            PrevMBIC_UL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] = MBIC_UL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index];
6059
+            PrevMBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] = MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index];
5860
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
6060
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
5861
         }
6061
         }
5862
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] == 3
6062
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index] == 3
@@ -5876,14 +6076,14 @@ void DLI_ShutdownAlarmCheck()
5876
             DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] = 0;
6076
             DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] = 0;
5877
             
6077
             
5878
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 >= RETRYCNT_MAX){
6078
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 >= RETRYCNT_MAX){
6079
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 = RETRYCNT_MAX;
5879
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P1;
6080
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P1;
5880
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm1       = true;
6081
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm1       = true;
5881
-            }else{
5882
             }
6082
             }
5883
-
5884
         }
6083
         }
5885
         else{
6084
         else{
5886
-            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC){
6085
+            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC
6086
+                && bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 != RETRYCNT_MAX){
5887
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P1;
6087
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P1;
5888
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm1       = false;            
6088
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm1       = false;            
5889
             }
6089
             }
@@ -5893,13 +6093,13 @@ void DLI_ShutdownAlarmCheck()
5893
         /*                                             SHUTDOWN DL2                                                    */
6093
         /*                                             SHUTDOWN DL2                                                    */
5894
         /***************************************************************************************************************/  
6094
         /***************************************************************************************************************/  
5895
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] < 3
6095
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] < 3
5896
-            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] != MBIC_UL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index])
6096
+            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index])
5897
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6097
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
5898
             HAL_GPIO_WritePin(PATH_EN_DL2_GPIO_Port,PATH_EN_DL2_Pin,GPIO_PIN_SET);//CLOCK
6098
             HAL_GPIO_WritePin(PATH_EN_DL2_GPIO_Port,PATH_EN_DL2_Pin,GPIO_PIN_SET);//CLOCK
5899
             bluecell_Currdatastatus.ATT_DL2_PATH = true;            
6099
             bluecell_Currdatastatus.ATT_DL2_PATH = true;            
5900
             bluecell_Prevdatastatus.ATT_DL2_H = 0xFF;
6100
             bluecell_Prevdatastatus.ATT_DL2_H = 0xFF;
5901
             bluecell_Prevdatastatus.ATT_DL2_L = 0xFF;
6101
             bluecell_Prevdatastatus.ATT_DL2_L = 0xFF;
5902
-            PrevMBIC_UL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] = MBIC_UL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index];
6102
+            PrevMBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index] = MBIC_DL_ShutdownCount[DET_Alarm_DL2_Shutdown_Index];
5903
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
6103
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
5904
             printf("DL SHUTDOWN RECOVERY OPERATE PATH ON\r\n");
6104
             printf("DL SHUTDOWN RECOVERY OPERATE PATH ON\r\n");
5905
         }
6105
         }
@@ -5924,12 +6124,14 @@ void DLI_ShutdownAlarmCheck()
5924
             printf("Shutdown Operate DL2 ============== bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 : %d \r\n",bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2);
6124
             printf("Shutdown Operate DL2 ============== bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 : %d \r\n",bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2);
5925
             
6125
             
5926
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 >= RETRYCNT_MAX){
6126
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 >= RETRYCNT_MAX){
6127
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 = RETRYCNT_MAX;
5927
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P2;
6128
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P2;
5928
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm2       = true;
6129
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm2       = true;
5929
             }
6130
             }
5930
         }
6131
         }
5931
         else{
6132
         else{
5932
-            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC){
6133
+            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL2_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC
6134
+                && bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 != RETRYCNT_MAX){
5933
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P2;
6135
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P2;
5934
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm2       = false;            
6136
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm2       = false;            
5935
             }
6137
             }
@@ -5938,13 +6140,13 @@ void DLI_ShutdownAlarmCheck()
5938
         /*                                             SHUTDOWN DL3                                                    */
6140
         /*                                             SHUTDOWN DL3                                                    */
5939
         /***************************************************************************************************************/  
6141
         /***************************************************************************************************************/  
5940
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] < 3
6142
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] < 3
5941
-            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] != MBIC_UL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index])
6143
+            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index])
5942
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6144
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
5943
             HAL_GPIO_WritePin(PATH_EN_DL3_GPIO_Port,PATH_EN_DL3_Pin,GPIO_PIN_SET);//CLOCK
6145
             HAL_GPIO_WritePin(PATH_EN_DL3_GPIO_Port,PATH_EN_DL3_Pin,GPIO_PIN_SET);//CLOCK
5944
             bluecell_Currdatastatus.ATT_DL3_PATH = true;            
6146
             bluecell_Currdatastatus.ATT_DL3_PATH = true;            
5945
             bluecell_Prevdatastatus.ATT_DL3_H = 0xFF;
6147
             bluecell_Prevdatastatus.ATT_DL3_H = 0xFF;
5946
             bluecell_Prevdatastatus.ATT_DL3_L = 0xFF;
6148
             bluecell_Prevdatastatus.ATT_DL3_L = 0xFF;
5947
-            PrevMBIC_UL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] = MBIC_UL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index];
6149
+            PrevMBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] = MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index];
5948
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
6150
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
5949
         }
6151
         }
5950
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] == 3
6152
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL3_Shutdown_Index] == 3
@@ -5964,6 +6166,7 @@ void DLI_ShutdownAlarmCheck()
5964
             DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] = 0;
6166
             DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] = 0;
5965
             
6167
             
5966
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3 >= RETRYCNT_MAX){
6168
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3 >= RETRYCNT_MAX){
6169
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3 = RETRYCNT_MAX;
5967
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P3;
6170
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P3;
5968
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm3       = true;
6171
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm3       = true;
5969
             }else{
6172
             }else{
@@ -5971,7 +6174,8 @@ void DLI_ShutdownAlarmCheck()
5971
 
6174
 
5972
         }
6175
         }
5973
         else{
6176
         else{
5974
-            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC){
6177
+            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL3_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC
6178
+                && bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3 != RETRYCNT_MAX){
5975
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P3;
6179
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P3;
5976
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm3       = false;            
6180
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm3       = false;            
5977
             }
6181
             }
@@ -5980,13 +6184,13 @@ void DLI_ShutdownAlarmCheck()
5980
         /*                                             SHUTDOWN DL4                                                    */
6184
         /*                                             SHUTDOWN DL4                                                    */
5981
         /***************************************************************************************************************/  
6185
         /***************************************************************************************************************/  
5982
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] < 3
6186
         if(MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] < 3
5983
-            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] != MBIC_UL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index])
6187
+            && (PrevMBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] != MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index])
5984
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
6188
             && DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC){
5985
             HAL_GPIO_WritePin(PATH_EN_DL4_GPIO_Port,PATH_EN_DL4_Pin,GPIO_PIN_SET);//CLOCK
6189
             HAL_GPIO_WritePin(PATH_EN_DL4_GPIO_Port,PATH_EN_DL4_Pin,GPIO_PIN_SET);//CLOCK
5986
             bluecell_Currdatastatus.ATT_DL4_PATH = true;            
6190
             bluecell_Currdatastatus.ATT_DL4_PATH = true;            
5987
             bluecell_Prevdatastatus.ATT_DL4_H = 0xFF;
6191
             bluecell_Prevdatastatus.ATT_DL4_H = 0xFF;
5988
             bluecell_Prevdatastatus.ATT_DL4_L = 0xFF;
6192
             bluecell_Prevdatastatus.ATT_DL4_L = 0xFF;
5989
-            PrevMBIC_UL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] = MBIC_UL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index];
6193
+            PrevMBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] = MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index];
5990
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
6194
             CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus); 
5991
         }
6195
         }
5992
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] == 3
6196
         else if(MBIC_DL_ShutdownCount[DET_Alarm_DL4_Shutdown_Index] == 3
@@ -6006,6 +6210,7 @@ void DLI_ShutdownAlarmCheck()
6006
             DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] = 0;
6210
             DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] = 0;
6007
             
6211
             
6008
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4 >= RETRYCNT_MAX){
6212
             if(bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4 >= RETRYCNT_MAX){
6213
+                bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4 = RETRYCNT_MAX;
6009
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P4;
6214
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN |= ALARM_DLI_SHUTDOWN_P4;
6010
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm4       = true;
6215
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm4       = true;
6011
             }else{
6216
             }else{
@@ -6013,7 +6218,8 @@ void DLI_ShutdownAlarmCheck()
6013
 
6218
 
6014
         }
6219
         }
6015
         else{
6220
         else{
6016
-            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC){
6221
+            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL4_Shutdown_Index] >= MBIC_OFF_MAINTAIN_SEC
6222
+                && bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4 != RETRYCNT_MAX){
6017
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P4;
6223
                 bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P4;
6018
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm4       = false;            
6224
                 bluecell_Currdatastatus.DLI_Shutdown_Alarm4       = false;            
6019
             }
6225
             }
@@ -6119,6 +6325,7 @@ void ULO_ShutdownAlarmCheck(){
6119
             DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index] = 0;
6325
             DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index] = 0;
6120
             
6326
             
6121
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1 >= RETRYCNT_MAX){
6327
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1 >= RETRYCNT_MAX){
6328
+                bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1 = RETRYCNT_MAX;
6122
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P1;
6329
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P1;
6123
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm1       = true;
6330
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm1       = true;
6124
             }else{
6331
             }else{
@@ -6194,6 +6401,7 @@ void ULO_ShutdownAlarmCheck(){
6194
             printf("Shutdown Operate UL2 ============== bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2 : %d \r\n",bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
6401
             printf("Shutdown Operate UL2 ============== bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2 : %d \r\n",bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2);
6195
             
6402
             
6196
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2 >= RETRYCNT_MAX){
6403
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2 >= RETRYCNT_MAX){
6404
+                bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2 = RETRYCNT_MAX;
6197
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P2;
6405
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P2;
6198
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm2       = true;
6406
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm2       = true;
6199
             }
6407
             }
@@ -6236,6 +6444,7 @@ void ULO_ShutdownAlarmCheck(){
6236
             DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL3_Shutdown_Index] = 0;
6444
             DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL3_Shutdown_Index] = 0;
6237
             
6445
             
6238
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count3 >= RETRYCNT_MAX){
6446
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count3 >= RETRYCNT_MAX){
6447
+                bluecell_Currdatastatus.ULO_Shutdown_Retry_Count3 = RETRYCNT_MAX;
6239
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P3;
6448
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P3;
6240
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm3       = true;
6449
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm3       = true;
6241
             }else{
6450
             }else{
@@ -6281,6 +6490,7 @@ void ULO_ShutdownAlarmCheck(){
6281
             DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL4_Shutdown_Index] = 0;
6490
             DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL4_Shutdown_Index] = 0;
6282
             
6491
             
6283
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count4 >= RETRYCNT_MAX){
6492
             if(bluecell_Currdatastatus.ULO_Shutdown_Retry_Count4 >= RETRYCNT_MAX){
6493
+                bluecell_Currdatastatus.ULO_Shutdown_Retry_Count4 = RETRYCNT_MAX;
6284
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P4;
6494
                 bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN |= ALARM_ULO_SHUTDOWN_P4;
6285
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm4       = true;
6495
                 bluecell_Currdatastatus.ULO_Shutdown_Alarm4       = true;
6286
             }
6496
             }
@@ -6391,7 +6601,7 @@ void ULO_ALCAlarmCheck(){
6391
     if(bluecell_Currdatastatus.ULO_ALC_ON_OFF == true){
6601
     if(bluecell_Currdatastatus.ULO_ALC_ON_OFF == true){
6392
         if(ALC_AlarmSet[ALC_Alarm_UL1_Index] == true
6602
         if(ALC_AlarmSet[ALC_Alarm_UL1_Index] == true
6393
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] >= MBIC_ON_MAINTAIN_SEC){
6603
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] >= MBIC_ON_MAINTAIN_SEC){
6394
-            printf("ALARM_ALC_P1 OCCUR\r\n");
6604
+//            printf("ALARM_ALC_P1 OCCUR\r\n");
6395
 
6605
 
6396
                 bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P1;
6606
                 bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P1;
6397
                 bluecell_Currdatastatus.ULO_ALC_Alarm1       = true;
6607
                 bluecell_Currdatastatus.ULO_ALC_Alarm1       = true;
@@ -6403,7 +6613,7 @@ void ULO_ALCAlarmCheck(){
6403
         }
6613
         }
6404
         if(ALC_AlarmSet[ALC_Alarm_UL2_Index] == true
6614
         if(ALC_AlarmSet[ALC_Alarm_UL2_Index] == true
6405
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL2_Index] >= MBIC_ON_MAINTAIN_SEC){
6615
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL2_Index] >= MBIC_ON_MAINTAIN_SEC){
6406
-            printf("ALARM_ALC_P2 OCCUR\r\n");
6616
+//            printf("ALARM_ALC_P2 OCCUR\r\n");
6407
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P2;
6617
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P2;
6408
             bluecell_Currdatastatus.ULO_ALC_Alarm2       = true;
6618
             bluecell_Currdatastatus.ULO_ALC_Alarm2       = true;
6409
         }else{
6619
         }else{
@@ -6414,7 +6624,7 @@ void ULO_ALCAlarmCheck(){
6414
         }
6624
         }
6415
         if(ALC_AlarmSet[ALC_Alarm_UL3_Index] == true
6625
         if(ALC_AlarmSet[ALC_Alarm_UL3_Index] == true
6416
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index] >= MBIC_ON_MAINTAIN_SEC){
6626
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index] >= MBIC_ON_MAINTAIN_SEC){
6417
-            printf("ALARM_ALC_P3 OCCUR\r\n");
6627
+//            printf("ALARM_ALC_P3 OCCUR\r\n");
6418
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P3;
6628
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P3;
6419
             bluecell_Currdatastatus.ULO_ALC_Alarm3       = true;
6629
             bluecell_Currdatastatus.ULO_ALC_Alarm3       = true;
6420
         }else{
6630
         }else{
@@ -6425,7 +6635,7 @@ void ULO_ALCAlarmCheck(){
6425
         }
6635
         }
6426
         if(ALC_AlarmSet[ALC_Alarm_UL3_Index] == true
6636
         if(ALC_AlarmSet[ALC_Alarm_UL3_Index] == true
6427
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index] >= MBIC_ON_MAINTAIN_SEC){
6637
          &&ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index] >= MBIC_ON_MAINTAIN_SEC){
6428
-            printf("ALARM_ALC_P4 OCCUR\r\n");
6638
+//            printf("ALARM_ALC_P4 OCCUR\r\n");
6429
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P4;
6639
             bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm |= ALARM_ALC_P4;
6430
             bluecell_Currdatastatus.ULO_ALC_Alarm4       = true;
6640
             bluecell_Currdatastatus.ULO_ALC_Alarm4       = true;
6431
         }else{
6641
         }else{

+ 18 - 0
Bluecell_Src/eeprom.c

@@ -72,11 +72,29 @@ void EEPROM_M24C08_Init(void){
72
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_TEMP_UL3_TABLE_ADDRESDS,&Temp_UL4.Table_1_Temp,sizeof(TEMP_TABLE_st) );
72
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_TEMP_UL3_TABLE_ADDRESDS,&Temp_UL4.Table_1_Temp,sizeof(TEMP_TABLE_st) );
73
     
73
     
74
     /*Table Initial Length Setting */
74
     /*Table Initial Length Setting */
75
+#if 0 // PYJ.2020.06.23_BEGIN -- 
75
         printf("Init Temp_UL3 Length : %d \r\n",Temp_UL3.Table_Length);
76
         printf("Init Temp_UL3 Length : %d \r\n",Temp_UL3.Table_Length);
76
         Bluecell_DataCopy(testdata, &Temp_UL3.Table_1_Temp,sizeof(TEMP_TABLE_st) );
77
         Bluecell_DataCopy(testdata, &Temp_UL3.Table_1_Temp,sizeof(TEMP_TABLE_st) );
77
         for(int i = 0; i < sizeof(TEMP_TABLE_st); i++){
78
         for(int i = 0; i < sizeof(TEMP_TABLE_st); i++){
78
             printf("\r\n testdata[%d] : %x ",i,testdata[i]);
79
             printf("\r\n testdata[%d] : %x ",i,testdata[i]);
79
         }
80
         }
81
+#endif // PYJ.2020.06.23_END -- 
82
+    bluecell_Currdatastatus.ALARM_TEMP_HIGH = 0; //bit
83
+    bluecell_Currdatastatus.ALARM_DLI_Level = 0;
84
+    bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN = 0;
85
+    bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm = 0;
86
+    bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm = 0;    
87
+    bluecell_Currdatastatus.ALARM_ULO_Level = 0;
88
+    bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN = 0;
89
+    bluecell_Currdatastatus.DLI_Shutdown_Retry_Count1 = 0;    
90
+    bluecell_Currdatastatus.DLI_Shutdown_Retry_Count2 = 0;    
91
+    bluecell_Currdatastatus.DLI_Shutdown_Retry_Count3 = 0;    
92
+    bluecell_Currdatastatus.DLI_Shutdown_Retry_Count4 = 0;    
93
+    bluecell_Currdatastatus.ULO_Shutdown_Retry_Count1 = 0;        
94
+    bluecell_Currdatastatus.ULO_Shutdown_Retry_Count2 = 0;        
95
+    bluecell_Currdatastatus.ULO_Shutdown_Retry_Count3 = 0;            
96
+    bluecell_Currdatastatus.ULO_Shutdown_Retry_Count4 = 0;        
97
+
80
     Att_DL1.Table_Length  = ATTENTABLEDLUL_LENGTH;
98
     Att_DL1.Table_Length  = ATTENTABLEDLUL_LENGTH;
81
     Att_DL2.Table_Length  = ATTENTABLEDLUL_LENGTH;
99
     Att_DL2.Table_Length  = ATTENTABLEDLUL_LENGTH;
82
     Att_DL3.Table_Length  = ATTENTABLEDLUL_LENGTH;
100
     Att_DL3.Table_Length  = ATTENTABLEDLUL_LENGTH;

+ 1 - 1
Inc/main.h

@@ -185,7 +185,7 @@ extern I2C_HandleTypeDef hi2c2;
185
 #define MBIC_ON_MAINTAIN_SEC 3000
185
 #define MBIC_ON_MAINTAIN_SEC 3000
186
 #define MBIC_ON_SHUTDOWN_MAINTAIN_SEC 5000//5
186
 #define MBIC_ON_SHUTDOWN_MAINTAIN_SEC 5000//5
187
 #define MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC 30000//30
187
 #define MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC 30000//30
188
-#define MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC 60000 * 5 //5min
188
+#define MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC 60000//60000 * 5 //5min
189
 
189
 
190
 
190
 
191
 #define MBIC_OFF_MAINTAIN_SEC 10000
191
 #define MBIC_OFF_MAINTAIN_SEC 10000

Fichier diff supprimé car celui-ci est trop grand
+ 13 - 9
STM32F103ZET_JDASMBIC.elf.launch


+ 47 - 42
Src/main.c

@@ -430,7 +430,7 @@ int main(void)  {
430
 //  Bluecell_AttenInitialize();
430
 //  Bluecell_AttenInitialize();
431
 #if 1 // PYJ.2020.05.06_BEGIN -- 
431
 #if 1 // PYJ.2020.05.06_BEGIN -- 
432
       printf("****************************************\r\n");
432
       printf("****************************************\r\n");
433
-      printf("MBIC Project\r\n");
433
+      printf("MBIC Project _ COPY _\r\n");
434
       printf("Build at %s %s\r\n", __DATE__, __TIME__);
434
       printf("Build at %s %s\r\n", __DATE__, __TIME__);
435
       printf("Copyright (c) 2020. BLUECELL\r\n");
435
       printf("Copyright (c) 2020. BLUECELL\r\n");
436
       printf("****************************************\r\n");
436
       printf("****************************************\r\n");
@@ -948,53 +948,58 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
948
       LDTimerCnt++;
948
       LDTimerCnt++;
949
       ALCTimerCnt++;
949
       ALCTimerCnt++;
950
       AGCTimerCnt++;
950
       AGCTimerCnt++;
951
-
952
-    for(int i = 0; i < DET_Alarm_UL_Shutdown_Index_MAX; i++){
953
-        if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] == true){
954
-            DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0; // OFF CNT = 0;
955
-            DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
956
-            if(DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
957
-                DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_ON_MAINTAIN_SEC;
951
+    if(bluecell_Currdatastatus.ULO_Shutdown_ON_OFF == true){
952
+        for(int i = 0; i < DET_Alarm_UL_Shutdown_Index_MAX; i++){
953
+            if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] == true){
954
+                DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0; // OFF CNT = 0;
955
+                DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
956
+                if(DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
957
+                    DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_ON_SHUTDOWN_MAINTAIN_SEC;
958
+                }
959
+            }else{
960
+                DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0;
961
+                DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
962
+                if(DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
963
+                    DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
964
+                }
958
             }
965
             }
959
-        }else{
960
-            DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0;
961
-            DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
962
-            if(DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
963
-                DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
966
+            if(ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] == true){
967
+                DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
968
+                if(DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
969
+                    DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_OFF_MAINTAIN_SEC;
970
+                }                
971
+            }else{
972
+                DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0;
964
             }
973
             }
965
         }
974
         }
966
-        if(ADC_Alarm_UL_Normal_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] == true){
967
-            DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i]++;
968
-            if(DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] == 0xFFFFFFFF){
969
-                DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = MBIC_OFF_MAINTAIN_SEC;
970
-            }                
971
-        }else{
972
-            DET_UL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL1_Shutdown_Index + i] = 0;
973
-        }
974
     }
975
     }
975
-    for(int i = 0; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
976
-        if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] == true){
977
-            DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0; // OFF CNT = 0;
978
-            DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
979
-            if(DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
980
-                DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_ON_MAINTAIN_SEC;
976
+
977
+
978
+    if(bluecell_Currdatastatus.DLI_Shutdown_ON_OFF == true){
979
+        for(int i = 0; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
980
+            if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] == true){
981
+                DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0; // OFF CNT = 0;
982
+                DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
983
+                if(DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
984
+                    DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_ON_SHUTDOWN_MAINTAIN_SEC;
985
+                }
986
+            }else{
987
+                DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0;
988
+                DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
989
+                if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
990
+                    DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
991
+                }
981
             }
992
             }
982
-        }else{
983
-            DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0;
984
-            DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
985
-            if(DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
986
-                DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC;
993
+            if(ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] == true){
994
+                DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
995
+                if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
996
+                    DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_OFF_MAINTAIN_SEC;
997
+                }                
998
+            }else{
999
+                DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0;
987
             }
1000
             }
988
-        }
989
-        if(ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] == true){
990
-            DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i]++;
991
-            if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] == 0xFFFFFFFF){
992
-                DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = MBIC_OFF_MAINTAIN_SEC;
993
-            }                
994
-        }else{
995
-            DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] = 0;
996
-        }
997
-    }    
1001
+        }  
1002
+    }
998
       /*ALC Alarm timer start*/
1003
       /*ALC Alarm timer start*/
999
       if(ALC_AlarmSet[ALC_Alarm_UL1_Index] == true){
1004
       if(ALC_AlarmSet[ALC_Alarm_UL1_Index] == true){
1000
           ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;
1005
           ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;