Explorar o código

HFR 일요일 검수 전 날

1.Self Test 적용
2.Self Test 적용 후 30분 뒤 자동 종료
PYJ %!s(int64=5) %!d(string=hai) anos
pai
achega
438dee3352
Modificáronse 5 ficheiros con 149 adicións e 7 borrados
  1. 4 1
      Bluecell_Inc/Bluecell_operate.h
  2. 124 3
      Bluecell_Src/Bluecell_operate.c
  3. 4 0
      Bluecell_Src/eeprom.c
  4. 1 1
      Inc/main.h
  5. 16 2
      Src/main.c

+ 4 - 1
Bluecell_Inc/Bluecell_operate.h

@@ -488,7 +488,10 @@ ULO_Level_High_Alarm1=0x70,
488 488
 ULO_Level_High_Alarm2,
489 489
 ULO_Level_High_Alarm3,
490 490
 ULO_Level_High_Alarm4,
491
-SERIAL_UL_NULL1,
491
+ULO_SelfTest1,
492
+ULO_SelfTest2,
493
+ULO_SelfTest3,
494
+ULO_SelfTest4,
492 495
 ULO_ALC_ON_OFF=0x80,
493 496
 ULO_ALC_Threshold,
494 497
 ULO_ALC_Threshold_Default,

+ 124 - 3
Bluecell_Src/Bluecell_operate.c

@@ -78,6 +78,9 @@ extern volatile uint32_t Alarm_DL_Level_TimerOnCnt ;
78 78
 extern volatile uint32_t Alarm_UL_Level_TimerOffCnt ;
79 79
 extern volatile uint32_t Alarm_UL_Level_TimerOnCnt ;
80 80
 
81
+extern volatile uint32_t SelfTestLifeCnt[4];
82
+
83
+
81 84
 /***************************************************************************************/
82 85
 /*                                  Function                                           */
83 86
 /***************************************************************************************/
@@ -3487,7 +3490,7 @@ uint32_t MBIC_DataSend(uint8_t* data){
3487 3490
     uint32_t Length = 0;
3488 3491
     uint16_t Crcret = 0;
3489 3492
     int16_t tmpdata = 0;
3490
-     uint32_t HeaderLength = 75;
3493
+     uint32_t HeaderLength = 79;
3491 3494
 	 
3492 3495
 
3493 3496
     
@@ -4182,6 +4185,26 @@ uint32_t MBIC_DataSend(uint8_t* data){
4182 4185
     data[MBIC_PAYLOADSTART + i++] = (tmpdata & 0x00FF); 
4183 4186
 
4184 4187
 
4188
+    data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
4189
+    data[MBIC_PAYLOADSTART + i++] = ULO_SelfTest1;
4190
+    data[MBIC_PAYLOADSTART + i++] = 1; // LENGTH
4191
+    Length += 1 ;
4192
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.Selftest1;
4193
+    data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
4194
+    data[MBIC_PAYLOADSTART + i++] = ULO_SelfTest2;
4195
+    data[MBIC_PAYLOADSTART + i++] = 1; // LENGTH
4196
+    Length += 1 ;
4197
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.Selftest2;
4198
+    data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
4199
+    data[MBIC_PAYLOADSTART + i++] = ULO_SelfTest3;
4200
+    data[MBIC_PAYLOADSTART + i++] = 1; // LENGTH
4201
+    Length += 1 ;
4202
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.Selftest3;
4203
+    data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
4204
+    data[MBIC_PAYLOADSTART + i++] = ULO_SelfTest4;
4205
+    data[MBIC_PAYLOADSTART + i++] = 1; // LENGTH
4206
+    Length += 1 ;
4207
+    data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.Selftest4;    
4185 4208
 
4186 4209
 
4187 4210
     
@@ -5403,6 +5426,50 @@ bool MBIC_Operate(uint8_t* data){
5403 5426
 			    bluecell_Currdatastatus.ULO_Level_High_Threshold_L = ((tempdata & 0x00FF));    				
5404 5427
 //                bluecell_Currdatastatus.ULO_Level_High_Threshold_default = data[MBIC_PAYLOADSTART + 3]; 
5405 5428
                 break;
5429
+            case ULO_SelfTest1:
5430
+                if(data[MBIC_PAYLOADSTART + 3]==0){
5431
+                    HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
5432
+                    HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
5433
+                }
5434
+                else{
5435
+                    HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
5436
+                    HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
5437
+                }
5438
+                bluecell_Currdatastatus.Selftest1 = data[MBIC_PAYLOADSTART + 3];                
5439
+                break;
5440
+            case ULO_SelfTest2:
5441
+                if(data[MBIC_PAYLOADSTART + 3]==0){
5442
+                    HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
5443
+                    HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
5444
+                }
5445
+                else{
5446
+                    HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
5447
+                    HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
5448
+                }
5449
+                bluecell_Currdatastatus.Selftest2 = data[MBIC_PAYLOADSTART + 3];                
5450
+                break;
5451
+            case ULO_SelfTest3:
5452
+                if(data[MBIC_PAYLOADSTART + 3]==0){
5453
+                    HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
5454
+                    HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
5455
+                }
5456
+                else{
5457
+                    HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
5458
+                    HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
5459
+                }
5460
+                bluecell_Currdatastatus.Selftest3 = data[MBIC_PAYLOADSTART + 3];                
5461
+                break;
5462
+            case ULO_SelfTest4:
5463
+                if(data[MBIC_PAYLOADSTART + 3]==0){
5464
+                    HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
5465
+                    HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
5466
+                }
5467
+                else{
5468
+                    HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
5469
+                    HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
5470
+                }
5471
+                bluecell_Currdatastatus.Selftest4 = data[MBIC_PAYLOADSTART + 3];                
5472
+                break;
5406 5473
             case  ULO_ALC_ON_OFF                   :
5407 5474
                 bluecell_Currdatastatus.ULO_ALC_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
5408 5475
                 if(bluecell_Currdatastatus.ULO_ALC_ON_OFF == 0)
@@ -9397,8 +9464,62 @@ void FRBT_Tracking_Package(uint8_t Index, uint8_t* FRBT,uint8_t* DL_MainAtten,ui
9397 9464
     FRBT[FRBT_L] = DL_MainAtten[FRBT_L];        
9398 9465
 
9399 9466
 }
9400
-
9401
-
9467
+typedef enum{
9468
+    SelfTest1 = 0,
9469
+    SelfTest2,
9470
+    SelfTest3,
9471
+    SelfTest4,    
9472
+};
9473
+void SelfTest_TimerOff(uint8_t num,uint8_t* selftest){
9474
+    GPIO_TypeDef *Port = 0;
9475
+    uint16_t Pin = 0;
9476
+    GPIO_TypeDef *_Port = 0;
9477
+    uint16_t _Pin = 0;   
9478
+    if(SelfTestLifeCnt[0] < MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC){
9479
+        return;
9480
+    }
9481
+    switch(num){
9482
+        case SelfTest1:
9483
+        _Port = _PATH_SW1_GPIO_Port;
9484
+        _Pin = _PATH_SW1_Pin;
9485
+        
9486
+        Port = PATH_SW1_GPIO_Port;
9487
+        Pin =  PATH_SW1_Pin;        
9488
+        break;
9489
+        case SelfTest2:
9490
+        _Port = _PATH_SW2_GPIO_Port;
9491
+        _Pin = _PATH_SW2_Pin;
9492
+        
9493
+        Port = PATH_SW2_GPIO_Port;
9494
+        Pin =  PATH_SW2_Pin;        
9495
+        break;
9496
+        case SelfTest3:
9497
+        _Port = _PATH_SW3_GPIO_Port;
9498
+        _Pin = _PATH_SW3_Pin;
9499
+        
9500
+        Port = PATH_SW3_GPIO_Port;
9501
+        Pin =  PATH_SW3_Pin;        
9502
+        break;
9503
+        case SelfTest4:
9504
+        _Port = _PATH_SW4_GPIO_Port;
9505
+        _Pin = _PATH_SW4_Pin;
9506
+        
9507
+        Port = PATH_SW4_GPIO_Port;
9508
+        Pin =  PATH_SW4_Pin;        
9509
+        break;        
9510
+    }
9511
+    *selftest = false;
9512
+    HAL_GPIO_WritePin(_Port,_Pin,GPIO_PIN_RESET);//CLOCK
9513
+    HAL_GPIO_WritePin(Port,Pin,GPIO_PIN_SET);//CLOCK
9514
+    
9515
+}
9516
+void SelfTestTimer_Operate()
9517
+{
9518
+    SelfTest_TimerOff(SelfTest1,&bluecell_Currdatastatus.Selftest1);
9519
+    SelfTest_TimerOff(SelfTest2,&bluecell_Currdatastatus.Selftest2);
9520
+    SelfTest_TimerOff(SelfTest3,&bluecell_Currdatastatus.Selftest3);
9521
+    SelfTest_TimerOff(SelfTest4,&bluecell_Currdatastatus.Selftest4);
9522
+}
9402 9523
 void FRBT_Operate(){
9403 9524
 
9404 9525
     if(bluecell_Currdatastatus.DLI_AGC_ON_OFF == false){    /*AGC ON ONLY*/

+ 4 - 0
Bluecell_Src/eeprom.c

@@ -216,6 +216,10 @@ void EEPROM_M24C08_Init(void){
216 216
     bluecell_Currdatastatus.DLI_FRBT_Atten3_L = 0;    
217 217
     bluecell_Currdatastatus.DLI_FRBT_Atten4_L = 0;
218 218
     bluecell_Currdatastatus.DLI_FRBT_D_Day = 0;
219
+    bluecell_Currdatastatus.Selftest1 = false;
220
+    bluecell_Currdatastatus.Selftest2 = false;
221
+    bluecell_Currdatastatus.Selftest3 = false;
222
+    bluecell_Currdatastatus.Selftest4 = false;    
219 223
 //    bluecell_Currdatastatus.DLI_FRBT_Status = 7;
220 224
     bluecell_Currdatastatus.ALARM_TESTMODE = 0;
221 225
 //    bluecell_Currdatastatus.CPUVERSION1 =  0;

+ 1 - 1
Inc/main.h

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

+ 16 - 2
Src/main.c

@@ -119,7 +119,7 @@ volatile uint32_t Alarm_UL_Level_TimerOffCnt = 0;
119 119
 volatile uint32_t Alarm_UL_Level_TimerOnCnt = 0;
120 120
 
121 121
 
122
-
122
+volatile uint32_t SelfTestLifeCnt[4] = {0,};
123 123
 
124 124
 
125 125
 
@@ -918,7 +918,14 @@ void UL_Shutdown_Timer(uint8_t Table_num){
918 918
           }
919 919
   }
920 920
 }
921
+void UL_SelfTestTimer(uint8_t Table_Num,uint8_t* selftest_status){
922
+    if((*selftest_status) == true){
923
+        SelfTestLifeCnt[Table_Num]++;
924
+    }else{
925
+        SelfTestLifeCnt[Table_Num] = 0;
926
+    }
921 927
 
928
+}
922 929
 /* USER CODE END 4 */
923 930
 
924 931
  /**
@@ -963,7 +970,14 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
963 970
     DL_Shutdown_Timer(DET_Alarm_DL3_Shutdown_Index);
964 971
 //    pdata = &bluecell_Currdatastatus.ATT_DL4_PATH;
965 972
     DL_Shutdown_Timer(DET_Alarm_DL4_Shutdown_Index);
966
-  
973
+
974
+
975
+    UL_SelfTestTimer(0,&bluecell_Currdatastatus.Selftest1);
976
+    UL_SelfTestTimer(1,&bluecell_Currdatastatus.Selftest2);
977
+    UL_SelfTestTimer(2,&bluecell_Currdatastatus.Selftest3);
978
+    UL_SelfTestTimer(3,&bluecell_Currdatastatus.Selftest4);    
979
+        
980
+    
967 981
       /*ALC Alarm timer start*/
968 982
       if(ALC_AlarmSet[ALC_Alarm_UL1_Index] == true){
969 983
           ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;