瀏覽代碼

LED Alarm Test 기능 추가

PYJ 5 年之前
父節點
當前提交
d9f1502787
共有 2 個文件被更改,包括 57 次插入23 次删除
  1. 50 16
      Bluecell_Src/Bluecell_operate.c
  2. 7 7
      Src/main.c

+ 50 - 16
Bluecell_Src/Bluecell_operate.c

@@ -144,19 +144,45 @@ void Booting_LED_Check(void){
144 144
     }
145 145
 }
146 146
 
147
-
147
+uint8_t LED_TestCnt = 0;
148 148
 void Boot_LED_Toggle(void){
149
-  if(LedTimerCnt > 1000){
150
-    HAL_GPIO_TogglePin(BOOT_LED_GPIO_Port,BOOT_LED_Pin);
151
-    HAL_GPIO_TogglePin(LED_FAIL_GPIO_Port,LED_FAIL_Pin);
152
-//    if(AlarmTimerOnCnt > 3000){
153
-    if(Alarm_LED_OnSet == true){
154
-        HAL_GPIO_WritePin(LED_ACT_GPIO_Port,LED_ACT_Pin,GPIO_PIN_SET);
155
-    }else{
156
-        HAL_GPIO_WritePin(LED_ACT_GPIO_Port,LED_ACT_Pin,GPIO_PIN_RESET);
157
-    }
158
-    printf("Alarm_LED_OnSet : %d\r\n",Alarm_LED_OnSet);
159
-    LedTimerCnt = 0;
149
+  if(bluecell_Currdatastatus.LED_TEST == false){
150
+      if(LedTimerCnt > 1000){
151
+        HAL_GPIO_TogglePin(BOOT_LED_GPIO_Port,BOOT_LED_Pin);
152
+        HAL_GPIO_TogglePin(LED_ACT_GPIO_Port,LED_ACT_Pin);
153
+    //    if(AlarmTimerOnCnt > 3000){
154
+        if(Alarm_LED_OnSet == true){
155
+            HAL_GPIO_WritePin(LED_FAIL_GPIO_Port,LED_FAIL_Pin,GPIO_PIN_SET);
156
+        }else{
157
+            HAL_GPIO_WritePin(LED_FAIL_GPIO_Port,LED_FAIL_Pin,GPIO_PIN_RESET);
158
+        }
159
+    //    printf("Alarm_LED_OnSet : %d\r\n",Alarm_LED_OnSet);
160
+        LedTimerCnt = 0;
161
+      }
162
+  }else{
163
+        if(LedTimerCnt > 500){
164
+            if(LED_TestCnt % 2){
165
+                HAL_GPIO_WritePin(BOOT_LED_GPIO_Port,BOOT_LED_Pin,GPIO_PIN_SET);
166
+                HAL_GPIO_WritePin(LED_FAIL_GPIO_Port,LED_FAIL_Pin,GPIO_PIN_RESET);
167
+                HAL_GPIO_WritePin(LED_ACT_GPIO_Port,LED_ACT_Pin,GPIO_PIN_RESET);
168
+            }else{
169
+                HAL_GPIO_WritePin(BOOT_LED_GPIO_Port,BOOT_LED_Pin,GPIO_PIN_RESET);
170
+                HAL_GPIO_WritePin(LED_FAIL_GPIO_Port,LED_FAIL_Pin,GPIO_PIN_SET);
171
+                HAL_GPIO_WritePin(LED_ACT_GPIO_Port,LED_ACT_Pin,GPIO_PIN_SET);
172
+
173
+            }
174
+            LED_TestCnt++;
175
+            LedTimerCnt = 0;
176
+
177
+          /*Set LED TEST variable False after 12 flashes*/
178
+          if(LED_TestCnt >= 10){
179
+            bluecell_Currdatastatus.LED_TEST = false;
180
+            LED_TestCnt = 0;
181
+
182
+          }
183
+        }
184
+
185
+
160 186
   }
161 187
   
162 188
 }
@@ -1621,7 +1647,7 @@ bool Bluecell_Operate(uint8_t* data){
1621 1647
         break;
1622 1648
     case Bluecell_LED_TEST  :                                 
1623 1649
         bluecell_Currdatastatus.LED_TEST = data[BLUECELL_DATA + i++];
1624
-        printf("%s : %d \r\n",__func__,__LINE__);
1650
+        printf("%s : %d Value : %d \r\n",__func__,__LINE__,bluecell_Currdatastatus.LED_TEST);
1625 1651
         break;
1626 1652
     case Bluecell_Temperature_Offset                      :   
1627 1653
         bluecell_Currdatastatus.bluecell_User_TEMP_OFFSET = data[BLUECELL_DATA + i++];
@@ -1710,7 +1736,10 @@ bool Bluecell_Operate(uint8_t* data){
1710 1736
          printf("%s : %d   ALARM_MASK1 : %d \r\n",__func__,__LINE__,bluecell_Currdatastatus.ALARM_MASK1);
1711 1737
         break;
1712 1738
   }
1713
-  if(datatype != Bluecell_StatusReq){
1739
+  
1740
+  if(datatype != Bluecell_StatusReq
1741
+  || datatype != Bluecell_LED_TEST)
1742
+  {
1714 1743
       Bluecell_StructCpy(&DataWrite[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
1715 1744
       EEPROM_M24C08_write(EEPROM_M24C08_ID ,(EEPROM_WINDOW_STATUS_ADDRESDS),&DataWrite[0],sizeof(BLUESTATUS_st));
1716 1745
 //      EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_WINDOW_STATUS_ADDRESDS,&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st) );
@@ -3045,7 +3074,10 @@ void ADC_Check(void){
3045 3074
         adc1cnt = 0;
3046 3075
 
3047 3076
     }
3048
-
3077
+    /*
3078
+        After ADC calculation is completed, start Det Alarm check.
3079
+    */
3080
+    DET_LevelAlarmCheck();/*DL UL Alarm Check*/
3049 3081
 }
3050 3082
 
3051 3083
 
@@ -3811,8 +3843,10 @@ void Alarm_Check(){
3811 3843
     double temp = 0;
3812 3844
     double ret = 0;
3813 3845
     int8_t ResdBm[4] = {0,};
3814
-    if(bluecell_Currdatastatus.ALARM_MASK1 == false)
3846
+    if(bluecell_Currdatastatus.ALARM_MASK1 == false){
3847
+        Alarm_LED_OnSet = false;
3815 3848
         return;
3849
+    }
3816 3850
 
3817 3851
     if(bluecell_Currdatastatus.ALARM_TEMP_HIGH             > 0 
3818 3852
     || bluecell_Currdatastatus.ALARM_DLI_Level             > 0

+ 7 - 7
Src/main.c

@@ -370,13 +370,13 @@ int main(void)
370 370
 //	  HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_14);
371 371
   //   printf("data %d\r\n",LedTimerCnt);
372 372
 
373
-    Boot_LED_Toggle();
374
-    Uart_Check();
375
-    ADC_Check();
376
-    ALC_Function();
377
-    AGC_Function();
378
-    Alarm_Check();
379
-    DET_LevelAlarmCheck();
373
+    Boot_LED_Toggle(); /*LED Check*/
374
+    Uart_Check();      /*Usart Rx*/
375
+    ADC_Check();       /*Det Calc + DL/UL Alarm Check Function*/
376
+    ALC_Function();    /*ALC Function*/
377
+    AGC_Function();    /*AGC Function*/
378
+    Alarm_Check();     /*Function to check all alarm status variables*/
379
+
380 380
     /* USER CODE END WHILE */
381 381
 
382 382
     /* USER CODE BEGIN 3 */