main.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. /* Private includes ----------------------------------------------------------*/
  23. /* USER CODE BEGIN Includes */
  24. #include <stdio.h>
  25. #include "PE43711.h"
  26. #include "uart.h"
  27. #include "Bluecell_operate.h"
  28. #include "eeprom.h"
  29. /* USER CODE END Includes */
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* USER CODE BEGIN PTD */
  32. /* USER CODE END PTD */
  33. /* Private define ------------------------------------------------------------*/
  34. /* USER CODE BEGIN PD */
  35. /* USER CODE END PD */
  36. /* Private macro -------------------------------------------------------------*/
  37. /* USER CODE BEGIN PM */
  38. /* USER CODE END PM */
  39. /* Private variables ---------------------------------------------------------*/
  40. ADC_HandleTypeDef hadc1;
  41. ADC_HandleTypeDef hadc3;
  42. DMA_HandleTypeDef hdma_adc1;
  43. DMA_HandleTypeDef hdma_adc3;
  44. I2C_HandleTypeDef hi2c2;
  45. TIM_HandleTypeDef htim6;
  46. UART_HandleTypeDef huart1;
  47. UART_HandleTypeDef huart2;
  48. DMA_HandleTypeDef hdma_usart1_rx;
  49. DMA_HandleTypeDef hdma_usart1_tx;
  50. DMA_HandleTypeDef hdma_usart2_rx;
  51. DMA_HandleTypeDef hdma_usart2_tx;
  52. /* USER CODE BEGIN PV */
  53. volatile uint16_t ADC1value[ADC1_CNT];
  54. volatile uint16_t ADC3value[ADC3_CNT];
  55. volatile uint16_t ADC1valuearray[ADC1_CNT][ADC_AVERAGECNT];
  56. volatile uint16_t ADC3valuearray[ADC3_CNT][ADC_AVERAGECNT];
  57. volatile uint32_t AdcTimerCnt = 0;
  58. volatile uint32_t LedTimerCnt = 0;
  59. volatile uint32_t UartRxTimerCnt = 0;
  60. volatile uint32_t LDTimerCnt = 0;
  61. volatile uint32_t ALCTimerCnt = 0;
  62. volatile uint32_t AGCTimerCnt = 0;
  63. volatile uint32_t MBIC_ShutdownCnt[MBIC_Shutdown_MaxIndex] ={ 0,};
  64. volatile uint32_t AGC_On_AlarmTimerCnt[AGC_Alarm_DL_Index_MAX] = {0,};
  65. volatile uint32_t AGC_Off_AlarmTimerCnt[AGC_Alarm_DL_Index_MAX] = {0,};
  66. volatile uint32_t ALC_On_AlarmTimerCnt[ALC_Alarm_UL_Index_MAX] = {0,};
  67. volatile uint32_t ALC_Off_AlarmTimerCnt[ALC_Alarm_UL_Index_MAX] = {0,};
  68. volatile uint32_t DET_UL_On_AlarmTimerCnt[DET_Alarm_UL_Index_MAX] = {0,};
  69. volatile uint32_t DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL_Index_MAX] = {0,};
  70. volatile uint32_t DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL_Index_MAX] = {0,};
  71. volatile uint32_t DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL_Index_MAX] = {0,};
  72. volatile uint32_t DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL_Index_MAX] = {0,};
  73. volatile uint32_t DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL_Index_MAX] = {0,};
  74. volatile uint32_t DET_UL_Shutdown_On_AlarmTimerCnt[DET_Alarm_UL_Index_MAX] = {0,};
  75. volatile uint32_t DET_UL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_UL_Index_MAX] = {0,};
  76. volatile uint32_t DET_DL_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL_Index_MAX] = {0,};
  77. volatile uint32_t DET_DL_Shutdown_Off_AlarmTimerCnt[DET_Alarm_DL_Index_MAX] = {0,};
  78. volatile uint32_t AlarmTimerOffCnt = 0;
  79. volatile uint32_t AlarmTimerOnCnt = 0;
  80. volatile bool AlarmTimerOnSet = 0;
  81. volatile bool AlarmTimerOffSet = 0;
  82. //extern bool AGC_AlarmTimerSet[AGC_Alarm_DL_Index_MAX];
  83. extern bool ADC_Alarm_DL_High_Set[DET_Alarm_DL_Index_MAX];
  84. extern bool ADC_Alarm_DL_Low_Set[DET_Alarm_DL_Index_MAX];
  85. extern bool ADC_Alarm_UL_Set[DET_Alarm_UL_Index_MAX];
  86. extern uint8_t ALC_AlarmSet[ALC_Alarm_UL_Index_MAX];
  87. extern bool AGC_AlarmSet[AGC_Alarm_DL_Index_MAX];
  88. extern bool ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL_Shutdown_Index_MAX];
  89. extern bool ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL_Shutdown_Index_MAX];
  90. /* USER CODE END PV */
  91. /* Private function prototypes -----------------------------------------------*/
  92. void SystemClock_Config(void);
  93. static void MX_GPIO_Init(void);
  94. static void MX_DMA_Init(void);
  95. static void MX_USART1_UART_Init(void);
  96. static void MX_ADC1_Init(void);
  97. static void MX_ADC3_Init(void);
  98. static void MX_USART2_UART_Init(void);
  99. static void MX_TIM6_Init(void);
  100. static void MX_I2C2_Init(void);
  101. static void MX_NVIC_Init(void);
  102. /* USER CODE BEGIN PFP */
  103. extern void Booting_LedInit(void);
  104. extern void Bluecell_AttenInitialize();
  105. extern void DET_LevelAlarmCheck();
  106. extern void Alarm_Check();
  107. /* USER CODE END PFP */
  108. /* Private user code ---------------------------------------------------------*/
  109. /* USER CODE BEGIN 0 */
  110. uint32_t ShutdownCnt_Get(uint8_t index){
  111. return MBIC_ShutdownCnt[index];
  112. }
  113. void ShutdownCnt_Set(uint8_t index,uint8_t val){
  114. MBIC_ShutdownCnt[index] = val;
  115. }
  116. void Pol_Delay_us(volatile uint32_t microseconds)
  117. {
  118. /* Go to number of cycles for system */
  119. microseconds *= (SystemCoreClock / 1000000);
  120. /* Delay till end */
  121. while (microseconds--);
  122. }
  123. int _write (int file, uint8_t *ptr, uint16_t len)
  124. {
  125. #if 1 // PYJ.2020.06.03_BEGIN --
  126. HAL_UART_Transmit(&hTest, ptr, len,10);
  127. #else
  128. HAL_UART_Transmit(&hTerminal, ptr, len,10);
  129. #endif // PYJ.2020.06.03_END --
  130. return len;
  131. }
  132. uint16_t adc1cnt = 0 ;
  133. uint16_t adc3cnt = 0 ;
  134. void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
  135. {
  136. //?��?��?�� 코드 ?��?��
  137. //만약 ?��?�� adc?���????????????? �??????????????��?�� ?�� ?��?���????????????? ?��?���????????????? ?��?��?? 같이 조건�????????????? ?��?��
  138. if(hadc->Instance == hadc1.Instance)
  139. {
  140. if(adc1cnt < ADC_AVERAGECNT){
  141. for(int i = 0; i < 4; i++){
  142. ADC1valuearray[i][adc1cnt] = ADC1value[i];
  143. }
  144. adc1cnt++;
  145. }
  146. }
  147. if(hadc->Instance == hadc3.Instance)
  148. {
  149. if(adc3cnt < ADC_AVERAGECNT){
  150. for(int i = 0; i < 5; i++){
  151. ADC3valuearray[i][adc3cnt] = ADC3value[i];
  152. }
  153. adc3cnt++;
  154. }
  155. }
  156. }
  157. #if 0 // PYJ.2020.04.24_BEGIN --
  158. void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
  159. {
  160. GPIO_InitTypeDef GPIO_InitStruct;
  161. if(i2cHandle->Instance==I2C1)
  162. {
  163. /* USER CODE BEGIN I2C1_MspInit 0 */
  164. __HAL_RCC_I2C1_CLK_ENABLE();
  165. /* USER CODE END I2C1_MspInit 0 */
  166. /**I2C1 GPIO Configuration
  167. PB6 ------> I2C1_SCL
  168. PB7 ------> I2C1_SDA
  169. */
  170. GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
  171. GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
  172. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  173. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  174. /* Peripheral clock enable */
  175. __HAL_RCC_I2C1_CLK_ENABLE();
  176. /* USER CODE BEGIN I2C1_MspInit 1 */
  177. /* USER CODE END I2C1_MspInit 1 */
  178. }
  179. else if(i2cHandle->Instance==I2C2)
  180. {
  181. /* USER CODE BEGIN I2C2_MspInit 0 */
  182. __HAL_RCC_I2C2_CLK_ENABLE();
  183. /* USER CODE END I2C2_MspInit 0 */
  184. /**I2C2 GPIO Configuration
  185. PB10 ------> I2C2_SCL
  186. PB11 ------> I2C2_SDA
  187. */
  188. GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
  189. GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
  190. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  191. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  192. /* Peripheral clock enable */
  193. __HAL_RCC_I2C2_CLK_ENABLE();
  194. /* USER CODE BEGIN I2C2_MspInit 1 */
  195. /* USER CODE END I2C2_MspInit 1 */
  196. }
  197. #endif // PYJ.2020.04.24_END --
  198. #if 0 // PYJ.2020.04.23_BEGIN --
  199. uint8_t eepdata[100];
  200. void eepromtest(){
  201. memset(&eepdata[0],0x33,100);
  202. for(int i = 0; i < 100; i ++ ){
  203. printf("data[%d] : %x \r\n",i,eepdata[i]);
  204. EEPROM_M24C08_Bytewrite(EEPROM_M24C08_ID,EEPROM_ATT_BASE + i,&eepdata[i],1);
  205. }
  206. for(int i = 0; i < 100; i ++ ){
  207. EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_BASE + i,&eepdata[i],1);
  208. printf("data[%d] : %x \r\n",i,eepdata[i]);
  209. }
  210. // EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_ATT_BASE,&eepdata[0],100);
  211. // for(int i = 0; i < 100; i ++ ){
  212. // printf("data[%d] : %x \r\n",i,eepdata[i]);
  213. // }
  214. }
  215. uint8_t i2ctest[10] = {22,};
  216. uint8_t i2cTestData[1] = {44};
  217. #endif // PYJ.2020.04.23_END --
  218. #if 0
  219. uint8_t eepromtestarray[1024 * 4];
  220. uint8_t eepromtestarray1[EEPROM_WINDOW_STATUS_ADDRESDS];
  221. uint8_t eepromtestReadarray1[EEPROM_WINDOW_STATUS_ADDRESDS];
  222. #define TESTINDEX sizeof(TEMP_TABLE_st)
  223. #endif
  224. #if 0 // PYJ.2020.04.25_BEGIN --
  225. void EEPROMTEST_J(){
  226. for(int i = 0; i< TESTINDEX; i++)
  227. eepromtestarray[i] = i;
  228. printf("Value %x\r\n",eepromtestarray[1]);
  229. // EEPROM_M24C08_write(EEPROM_M24C08_ID ,(EEPROM_TEMP_DL2_TABLE_ADDRESDS),&eepromtestarray[0],TESTINDEX);
  230. EEPROM_M24C08_write(EEPROM_M24C08_ID ,(EEPROM_TEMP_DL4_TABLE_ADDRESDS),&eepromtestarray[0],sizeof(TEMP_TABLE_st));
  231. EEPROM_M24C08_Read(EEPROM_M24C08_ID ,(EEPROM_TEMP_DL4_TABLE_ADDRESDS),&eepromtestReadarray[0],sizeof(TEMP_TABLE_st));
  232. // EEPROM_M24C08_Read(EEPROM_M24C08_ID ,(EEPROM_TEMP_DL2_TABLE_ADDRESDS),&eepromtestReadarray[0],TESTINDEX);
  233. for(int i = 0; i< TESTINDEX; i++)
  234. printf("%d ",eepromtestReadarray[i]);
  235. printf("\r\n");
  236. EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_ATT_BASE,&eepromtestReadarray[0],sizeof(BLUESTATUS_st) );
  237. for(int i = 0; i< sizeof(BLUESTATUS_st); i++)
  238. printf("%d ",eepromtestReadarray[i]);
  239. }
  240. #endif // PYJ.2020.04.25_END --
  241. #if 1 // PYJ.2020.04.23_BEGIN --
  242. void eepromtest_j1(){
  243. uint8_t eepromtestReadarray[1024 * 4];
  244. //uint8_t ret = 0;
  245. EEPROM_M24C08_Read(EEPROM_M24C08_ID ,EEPROM_ATT_BASE + 96,eepromtestReadarray,128 );
  246. for(int i = 0; i< 128 ; i++){
  247. printf("%x ",eepromtestReadarray[i]);
  248. }
  249. printf("\r\n");
  250. }
  251. extern void DET_LevelAlarmCheck();
  252. #endif // PYJ.2020.04.23_END --
  253. extern void ALC_Function();
  254. extern void Boot_LED_Toggle(void);
  255. extern void ADC_Check(void);
  256. extern void Booting_LED_Check(void);
  257. /* USER CODE END 0 */
  258. /**
  259. * @brief The application entry point.
  260. * @retval int
  261. */
  262. int main(void)
  263. {
  264. /* USER CODE BEGIN 1 */
  265. /* USER CODE END 1 */
  266. /* MCU Configuration--------------------------------------------------------*/
  267. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  268. HAL_Init();
  269. /* USER CODE BEGIN Init */
  270. /* USER CODE END Init */
  271. /* Configure the system clock */
  272. SystemClock_Config();
  273. /* USER CODE BEGIN SysInit */
  274. /* USER CODE END SysInit */
  275. /* Initialize all configured peripherals */
  276. MX_GPIO_Init();
  277. MX_DMA_Init();
  278. MX_USART1_UART_Init();
  279. MX_ADC1_Init();
  280. MX_ADC3_Init();
  281. MX_USART2_UART_Init();
  282. MX_TIM6_Init();
  283. MX_I2C2_Init();
  284. /* Initialize interrupts */
  285. MX_NVIC_Init();
  286. /* USER CODE BEGIN 2 */
  287. while(!(HAL_ADCEx_Calibration_Start(&hadc3)==HAL_OK));
  288. while(!(HAL_ADCEx_Calibration_Start(&hadc1)==HAL_OK));
  289. HAL_ADC_Start_DMA(&hadc3, (uint16_t*)ADC3value, 5);
  290. HAL_ADC_Start_DMA(&hadc1, (uint16_t*)ADC1value, 4);
  291. HAL_TIM_Base_Start_IT(&htim6);
  292. setbuf(stdout, NULL);
  293. PE43711_PinInit();
  294. EEPROM_M24C08_Init();
  295. // MBIC_APIFLASH_test();
  296. //Flash_InitRead();
  297. Booting_LedInit();
  298. Booting_LED_Check();
  299. InitUartQueue(&TerminalQueue);
  300. #if 0 // PYJ.2020.04.22_BEGIN --
  301. EEPROM_M24C08_write(0xA0,0,i2cTestData,1);
  302. printf("i2c Test Data1 %d\r\n",i2ctest[0]);
  303. EEPROM_M24C08_Read(0xA0,0x00,i2ctest,2);
  304. printf("i2c Test Data2 %d\r\n",i2ctest[0]);
  305. printf("i2c Test Data2 %d\r\n",i2ctest[1]);
  306. #endif // PYJ.2020.04.22_END --
  307. /* USER CODE END 2 */
  308. /* Infinite loop */
  309. /* USER CODE BEGIN WHILE */
  310. // uint16_t ret = 0;
  311. // EEPROMTEST_J();
  312. // eepromtest_j1();
  313. // eepromtest_j1();
  314. // uint8_t retdate[10] = {0,1,2,3,4,5,6,7,8,9};
  315. // uint16_t rrrrrr = 0;
  316. // rrrrrr = ((CRC16_Generate(&retdate[0], 10)));
  317. // printf("CRC : %x \r\n",rrrrrr);
  318. // Bluecell_DataInit();
  319. // Bluecell_AttenInitialize();
  320. #if 1 // PYJ.2020.05.06_BEGIN --
  321. printf("****************************************\r\n");
  322. printf("MBIC Project\r\n");
  323. printf("Build at %s %s\r\n", __DATE__, __TIME__);
  324. printf("Copyright (c) 2020. BLUECELL\r\n");
  325. printf("****************************************\r\n");
  326. #endif // PYJ.2020.05.06_END --
  327. while (1)
  328. {
  329. // HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_14);
  330. // printf("data %d\r\n",LedTimerCnt);
  331. Boot_LED_Toggle(); /*LED Check*/
  332. Uart_Check(); /*Usart Rx*/
  333. ADC_Check(); /*Det Calc + DL/UL Alarm Check Function*/
  334. ALC_Function(); /*ALC Function*/
  335. AGC_Function(); /*AGC Function*/
  336. Alarm_Check(); /*Function to check all alarm status variables*/
  337. // Uart1_Data_Send("A",1);
  338. // HAL_Delay(1);
  339. /* USER CODE END WHILE */
  340. /* USER CODE BEGIN 3 */
  341. }
  342. /* USER CODE END 3 */
  343. }
  344. /**
  345. * @brief System Clock Configuration
  346. * @retval None
  347. */
  348. void SystemClock_Config(void)
  349. {
  350. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  351. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  352. RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  353. /** Initializes the CPU, AHB and APB busses clocks
  354. */
  355. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  356. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  357. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  358. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  359. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  360. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL14;
  361. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  362. {
  363. Error_Handler();
  364. }
  365. /** Initializes the CPU, AHB and APB busses clocks
  366. */
  367. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  368. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  369. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  370. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  371. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  372. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  373. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  374. {
  375. Error_Handler();
  376. }
  377. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
  378. PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV4;
  379. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  380. {
  381. Error_Handler();
  382. }
  383. }
  384. /**
  385. * @brief NVIC Configuration.
  386. * @retval None
  387. */
  388. static void MX_NVIC_Init(void)
  389. {
  390. /* DMA1_Channel1_IRQn interrupt configuration */
  391. HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
  392. HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
  393. /* USART1_IRQn interrupt configuration */
  394. HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
  395. HAL_NVIC_EnableIRQ(USART1_IRQn);
  396. /* USART2_IRQn interrupt configuration */
  397. HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
  398. HAL_NVIC_EnableIRQ(USART2_IRQn);
  399. /* DMA2_Channel4_5_IRQn interrupt configuration */
  400. HAL_NVIC_SetPriority(DMA2_Channel4_5_IRQn, 0, 0);
  401. HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn);
  402. /* TIM6_IRQn interrupt configuration */
  403. HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0);
  404. HAL_NVIC_EnableIRQ(TIM6_IRQn);
  405. /* ADC3_IRQn interrupt configuration */
  406. HAL_NVIC_SetPriority(ADC3_IRQn, 0, 0);
  407. HAL_NVIC_EnableIRQ(ADC3_IRQn);
  408. /* DMA1_Channel6_IRQn interrupt configuration */
  409. HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0);
  410. HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
  411. /* DMA1_Channel7_IRQn interrupt configuration */
  412. HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0);
  413. HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
  414. /* DMA1_Channel4_IRQn interrupt configuration */
  415. HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0, 0);
  416. HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);
  417. /* DMA1_Channel5_IRQn interrupt configuration */
  418. HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
  419. HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
  420. }
  421. /**
  422. * @brief ADC1 Initialization Function
  423. * @param None
  424. * @retval None
  425. */
  426. static void MX_ADC1_Init(void)
  427. {
  428. /* USER CODE BEGIN ADC1_Init 0 */
  429. /* USER CODE END ADC1_Init 0 */
  430. ADC_ChannelConfTypeDef sConfig = {0};
  431. /* USER CODE BEGIN ADC1_Init 1 */
  432. /* USER CODE END ADC1_Init 1 */
  433. /** Common config
  434. */
  435. hadc1.Instance = ADC1;
  436. hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
  437. hadc1.Init.ContinuousConvMode = ENABLE;
  438. hadc1.Init.DiscontinuousConvMode = DISABLE;
  439. hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  440. hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  441. hadc1.Init.NbrOfConversion = 4;
  442. if (HAL_ADC_Init(&hadc1) != HAL_OK)
  443. {
  444. Error_Handler();
  445. }
  446. /** Configure Regular Channel
  447. */
  448. sConfig.Channel = ADC_CHANNEL_4;
  449. sConfig.Rank = ADC_REGULAR_RANK_1;
  450. sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
  451. if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  452. {
  453. Error_Handler();
  454. }
  455. /** Configure Regular Channel
  456. */
  457. sConfig.Channel = ADC_CHANNEL_5;
  458. sConfig.Rank = ADC_REGULAR_RANK_2;
  459. if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  460. {
  461. Error_Handler();
  462. }
  463. /** Configure Regular Channel
  464. */
  465. sConfig.Channel = ADC_CHANNEL_6;
  466. sConfig.Rank = ADC_REGULAR_RANK_3;
  467. if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  468. {
  469. Error_Handler();
  470. }
  471. /** Configure Regular Channel
  472. */
  473. sConfig.Channel = ADC_CHANNEL_12;
  474. sConfig.Rank = ADC_REGULAR_RANK_4;
  475. if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  476. {
  477. Error_Handler();
  478. }
  479. /* USER CODE BEGIN ADC1_Init 2 */
  480. /* USER CODE END ADC1_Init 2 */
  481. }
  482. /**
  483. * @brief ADC3 Initialization Function
  484. * @param None
  485. * @retval None
  486. */
  487. static void MX_ADC3_Init(void)
  488. {
  489. /* USER CODE BEGIN ADC3_Init 0 */
  490. /* USER CODE END ADC3_Init 0 */
  491. ADC_ChannelConfTypeDef sConfig = {0};
  492. /* USER CODE BEGIN ADC3_Init 1 */
  493. /* USER CODE END ADC3_Init 1 */
  494. /** Common config
  495. */
  496. hadc3.Instance = ADC3;
  497. hadc3.Init.ScanConvMode = ADC_SCAN_ENABLE;
  498. hadc3.Init.ContinuousConvMode = ENABLE;
  499. hadc3.Init.DiscontinuousConvMode = DISABLE;
  500. hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  501. hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  502. hadc3.Init.NbrOfConversion = 5;
  503. if (HAL_ADC_Init(&hadc3) != HAL_OK)
  504. {
  505. Error_Handler();
  506. }
  507. /** Configure Regular Channel
  508. */
  509. sConfig.Channel = ADC_CHANNEL_4;
  510. sConfig.Rank = ADC_REGULAR_RANK_1;
  511. sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
  512. if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  513. {
  514. Error_Handler();
  515. }
  516. /** Configure Regular Channel
  517. */
  518. sConfig.Channel = ADC_CHANNEL_5;
  519. sConfig.Rank = ADC_REGULAR_RANK_2;
  520. if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  521. {
  522. Error_Handler();
  523. }
  524. /** Configure Regular Channel
  525. */
  526. sConfig.Channel = ADC_CHANNEL_6;
  527. sConfig.Rank = ADC_REGULAR_RANK_3;
  528. if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  529. {
  530. Error_Handler();
  531. }
  532. /** Configure Regular Channel
  533. */
  534. sConfig.Channel = ADC_CHANNEL_7;
  535. sConfig.Rank = ADC_REGULAR_RANK_4;
  536. if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  537. {
  538. Error_Handler();
  539. }
  540. /** Configure Regular Channel
  541. */
  542. sConfig.Channel = ADC_CHANNEL_8;
  543. sConfig.Rank = ADC_REGULAR_RANK_5;
  544. if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  545. {
  546. Error_Handler();
  547. }
  548. /* USER CODE BEGIN ADC3_Init 2 */
  549. /* USER CODE END ADC3_Init 2 */
  550. }
  551. /**
  552. * @brief I2C2 Initialization Function
  553. * @param None
  554. * @retval None
  555. */
  556. static void MX_I2C2_Init(void)
  557. {
  558. /* USER CODE BEGIN I2C2_Init 0 */
  559. /* USER CODE END I2C2_Init 0 */
  560. /* USER CODE BEGIN I2C2_Init 1 */
  561. /* USER CODE END I2C2_Init 1 */
  562. hi2c2.Instance = I2C2;
  563. hi2c2.Init.ClockSpeed = 400000;
  564. hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
  565. hi2c2.Init.OwnAddress1 = 0;
  566. hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  567. hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  568. hi2c2.Init.OwnAddress2 = 0;
  569. hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  570. hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  571. if (HAL_I2C_Init(&hi2c2) != HAL_OK)
  572. {
  573. Error_Handler();
  574. }
  575. /* USER CODE BEGIN I2C2_Init 2 */
  576. /* USER CODE END I2C2_Init 2 */
  577. }
  578. /**
  579. * @brief TIM6 Initialization Function
  580. * @param None
  581. * @retval None
  582. */
  583. static void MX_TIM6_Init(void)
  584. {
  585. /* USER CODE BEGIN TIM6_Init 0 */
  586. /* USER CODE END TIM6_Init 0 */
  587. TIM_MasterConfigTypeDef sMasterConfig = {0};
  588. /* USER CODE BEGIN TIM6_Init 1 */
  589. /* USER CODE END TIM6_Init 1 */
  590. htim6.Instance = TIM6;
  591. htim6.Init.Prescaler = 5600 - 1;
  592. htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
  593. htim6.Init.Period = 10;
  594. htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  595. if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
  596. {
  597. Error_Handler();
  598. }
  599. sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  600. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  601. if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
  602. {
  603. Error_Handler();
  604. }
  605. /* USER CODE BEGIN TIM6_Init 2 */
  606. /* USER CODE END TIM6_Init 2 */
  607. }
  608. /**
  609. * @brief USART1 Initialization Function
  610. * @param None
  611. * @retval None
  612. */
  613. static void MX_USART1_UART_Init(void)
  614. {
  615. /* USER CODE BEGIN USART1_Init 0 */
  616. /* USER CODE END USART1_Init 0 */
  617. /* USER CODE BEGIN USART1_Init 1 */
  618. /* USER CODE END USART1_Init 1 */
  619. huart1.Instance = USART1;
  620. huart1.Init.BaudRate = 115200;
  621. huart1.Init.WordLength = UART_WORDLENGTH_8B;
  622. huart1.Init.StopBits = UART_STOPBITS_1;
  623. huart1.Init.Parity = UART_PARITY_NONE;
  624. huart1.Init.Mode = UART_MODE_TX_RX;
  625. huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  626. huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  627. if (HAL_UART_Init(&huart1) != HAL_OK)
  628. {
  629. Error_Handler();
  630. }
  631. /* USER CODE BEGIN USART1_Init 2 */
  632. /* USER CODE END USART1_Init 2 */
  633. }
  634. /**
  635. * @brief USART2 Initialization Function
  636. * @param None
  637. * @retval None
  638. */
  639. static void MX_USART2_UART_Init(void)
  640. {
  641. /* USER CODE BEGIN USART2_Init 0 */
  642. /* USER CODE END USART2_Init 0 */
  643. /* USER CODE BEGIN USART2_Init 1 */
  644. /* USER CODE END USART2_Init 1 */
  645. huart2.Instance = USART2;
  646. huart2.Init.BaudRate = 115200;
  647. huart2.Init.WordLength = UART_WORDLENGTH_8B;
  648. huart2.Init.StopBits = UART_STOPBITS_1;
  649. huart2.Init.Parity = UART_PARITY_NONE;
  650. huart2.Init.Mode = UART_MODE_TX_RX;
  651. huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  652. huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  653. if (HAL_UART_Init(&huart2) != HAL_OK)
  654. {
  655. Error_Handler();
  656. }
  657. /* USER CODE BEGIN USART2_Init 2 */
  658. /* USER CODE END USART2_Init 2 */
  659. }
  660. /**
  661. * Enable DMA controller clock
  662. */
  663. static void MX_DMA_Init(void)
  664. {
  665. /* DMA controller clock enable */
  666. __HAL_RCC_DMA1_CLK_ENABLE();
  667. __HAL_RCC_DMA2_CLK_ENABLE();
  668. }
  669. /**
  670. * @brief GPIO Initialization Function
  671. * @param None
  672. * @retval None
  673. */
  674. static void MX_GPIO_Init(void)
  675. {
  676. GPIO_InitTypeDef GPIO_InitStruct = {0};
  677. /* GPIO Ports Clock Enable */
  678. __HAL_RCC_GPIOE_CLK_ENABLE();
  679. __HAL_RCC_GPIOC_CLK_ENABLE();
  680. __HAL_RCC_GPIOF_CLK_ENABLE();
  681. __HAL_RCC_GPIOA_CLK_ENABLE();
  682. __HAL_RCC_GPIOG_CLK_ENABLE();
  683. __HAL_RCC_GPIOB_CLK_ENABLE();
  684. __HAL_RCC_GPIOD_CLK_ENABLE();
  685. /*Configure GPIO pin Output Level */
  686. HAL_GPIO_WritePin(GPIOE, LED_FAIL2_Pin|FAIL_MBIC_Pin|ATT_CLOCK4_Pin|ATT_DATA4_Pin
  687. |ATT_EN_DL4_Pin|ATT_EN_UL4_Pin|PATH_EN_DL4_Pin|PATH_EN_UL4_Pin, GPIO_PIN_RESET);
  688. /*Configure GPIO pin Output Level */
  689. HAL_GPIO_WritePin(GPIOC, BOOT_LED_Pin|PATH_EN_UL1_Pin, GPIO_PIN_RESET);
  690. /*Configure GPIO pin Output Level */
  691. HAL_GPIO_WritePin(GPIOG, ATT_CLOCK3_Pin|ATT_DATA3_Pin|ATT_EN_DL3_Pin|ATT_EN_UL3_Pin
  692. |PATH_EN_DL3_Pin|PATH_EN_UL3_Pin|_PATH_SW1_Pin|PATH_SW1_Pin
  693. |_PATH_SW2_Pin|PATH_SW2_Pin|_PATH_SW3_Pin|PATH_SW3_Pin
  694. |_PATH_SW4_Pin|PATH_SW4_Pin, GPIO_PIN_RESET);
  695. /*Configure GPIO pin Output Level */
  696. HAL_GPIO_WritePin(GPIOB, ATT_EN_UL1_Pin|PATH_EN_DL1_Pin|ATT_CLOCK1_Pin|ATT_DATA1_Pin
  697. |ATT_EN_DL1_Pin, GPIO_PIN_RESET);
  698. /*Configure GPIO pin Output Level */
  699. HAL_GPIO_WritePin(GPIOD, PATH_EN_DL2_Pin|PATH_EN_UL2_Pin|LED_ACT_Pin|LED_FAIL_Pin
  700. |ATT_CLOCK2_Pin|ATT_DATA2_Pin|ATT_EN_DL2_Pin|ATT_EN_UL2_Pin, GPIO_PIN_RESET);
  701. /*Configure GPIO pins : LED_FAIL2_Pin FAIL_MBIC_Pin ATT_CLOCK4_Pin ATT_DATA4_Pin
  702. ATT_EN_DL4_Pin ATT_EN_UL4_Pin PATH_EN_DL4_Pin PATH_EN_UL4_Pin */
  703. GPIO_InitStruct.Pin = LED_FAIL2_Pin|FAIL_MBIC_Pin|ATT_CLOCK4_Pin|ATT_DATA4_Pin
  704. |ATT_EN_DL4_Pin|ATT_EN_UL4_Pin|PATH_EN_DL4_Pin|PATH_EN_UL4_Pin;
  705. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  706. GPIO_InitStruct.Pull = GPIO_NOPULL;
  707. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  708. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  709. /*Configure GPIO pins : BOOT_LED_Pin PATH_EN_UL1_Pin */
  710. GPIO_InitStruct.Pin = BOOT_LED_Pin|PATH_EN_UL1_Pin;
  711. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  712. GPIO_InitStruct.Pull = GPIO_NOPULL;
  713. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  714. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  715. /*Configure GPIO pins : ATT_CLOCK3_Pin ATT_DATA3_Pin ATT_EN_DL3_Pin ATT_EN_UL3_Pin
  716. PATH_EN_DL3_Pin PATH_EN_UL3_Pin _PATH_SW1_Pin PATH_SW1_Pin
  717. _PATH_SW2_Pin PATH_SW2_Pin _PATH_SW3_Pin PATH_SW3_Pin
  718. _PATH_SW4_Pin PATH_SW4_Pin */
  719. GPIO_InitStruct.Pin = ATT_CLOCK3_Pin|ATT_DATA3_Pin|ATT_EN_DL3_Pin|ATT_EN_UL3_Pin
  720. |PATH_EN_DL3_Pin|PATH_EN_UL3_Pin|_PATH_SW1_Pin|PATH_SW1_Pin
  721. |_PATH_SW2_Pin|PATH_SW2_Pin|_PATH_SW3_Pin|PATH_SW3_Pin
  722. |_PATH_SW4_Pin|PATH_SW4_Pin;
  723. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  724. GPIO_InitStruct.Pull = GPIO_NOPULL;
  725. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  726. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  727. /*Configure GPIO pins : ATT_EN_UL1_Pin PATH_EN_DL1_Pin ATT_CLOCK1_Pin ATT_DATA1_Pin
  728. ATT_EN_DL1_Pin */
  729. GPIO_InitStruct.Pin = ATT_EN_UL1_Pin|PATH_EN_DL1_Pin|ATT_CLOCK1_Pin|ATT_DATA1_Pin
  730. |ATT_EN_DL1_Pin;
  731. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  732. GPIO_InitStruct.Pull = GPIO_NOPULL;
  733. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  734. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  735. /*Configure GPIO pins : PATH_EN_DL2_Pin PATH_EN_UL2_Pin LED_ACT_Pin LED_FAIL_Pin
  736. ATT_CLOCK2_Pin ATT_DATA2_Pin ATT_EN_DL2_Pin ATT_EN_UL2_Pin */
  737. GPIO_InitStruct.Pin = PATH_EN_DL2_Pin|PATH_EN_UL2_Pin|LED_ACT_Pin|LED_FAIL_Pin
  738. |ATT_CLOCK2_Pin|ATT_DATA2_Pin|ATT_EN_DL2_Pin|ATT_EN_UL2_Pin;
  739. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  740. GPIO_InitStruct.Pull = GPIO_NOPULL;
  741. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  742. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  743. }
  744. /* USER CODE BEGIN 4 */
  745. /* USER CODE END 4 */
  746. /**
  747. * @brief Period elapsed callback in non blocking mode
  748. * @note This function is called when TIM2 interrupt took place, inside
  749. * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
  750. * a global variable "uwTick" used as application time base.
  751. * @param htim : TIM handle
  752. * @retval None
  753. */
  754. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  755. {
  756. /* USER CODE BEGIN Callback 0 */
  757. /* USER CODE END Callback 0 */
  758. if (htim->Instance == TIM2) {
  759. HAL_IncTick();
  760. }
  761. /* USER CODE BEGIN Callback 1 */
  762. if(htim->Instance == TIM6){
  763. UartRxTimerCnt++;
  764. LedTimerCnt++;
  765. AdcTimerCnt++;
  766. LDTimerCnt++;
  767. ALCTimerCnt++;
  768. AGCTimerCnt++;
  769. if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index] == true){
  770. DET_UL_Shutdown_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;
  771. DET_UL_Shutdown_On_AlarmTimerCnt[ALC_Alarm_UL1_Index]++;
  772. if(DET_UL_Shutdown_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] == 0xFFFFFFFF){
  773. DET_UL_Shutdown_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] = MBIC_ON_MAINTAIN_SEC;
  774. }
  775. }else{
  776. DET_UL_Shutdown_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;
  777. DET_UL_Shutdown_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index]++;
  778. if(DET_UL_Shutdown_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] == 0xFFFFFFFF){
  779. DET_UL_Shutdown_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = MBIC_OFF_MAINTAIN_SEC;
  780. }
  781. }
  782. /*ALC Alarm timer start*/
  783. if(ALC_AlarmSet[ALC_Alarm_UL1_Index] == true){
  784. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;
  785. ALC_On_AlarmTimerCnt[ALC_Alarm_UL1_Index]++;
  786. if(ALC_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] == 0xFFFFFFFF){
  787. ALC_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] = MBIC_ON_MAINTAIN_SEC;
  788. }
  789. }else{
  790. ALC_On_AlarmTimerCnt[ALC_Alarm_UL1_Index] = 0;
  791. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index]++;
  792. if(ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] == 0xFFFFFFFF){
  793. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL1_Index] = MBIC_OFF_MAINTAIN_SEC;
  794. }
  795. }
  796. if(ALC_AlarmSet[ALC_Alarm_UL2_Index] == true){
  797. ALC_On_AlarmTimerCnt[ALC_Alarm_UL2_Index]++;
  798. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL2_Index] = 0;
  799. if(ALC_On_AlarmTimerCnt[ALC_Alarm_UL2_Index] == 0xFFFFFFFF){
  800. ALC_On_AlarmTimerCnt[ALC_Alarm_UL2_Index] = MBIC_ON_MAINTAIN_SEC;
  801. }
  802. }else{
  803. ALC_On_AlarmTimerCnt[ALC_Alarm_UL2_Index] = 0;
  804. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL2_Index]++;
  805. if(ALC_Off_AlarmTimerCnt[ALC_Alarm_UL2_Index] == 0xFFFFFFFF){
  806. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL2_Index] = MBIC_OFF_MAINTAIN_SEC;
  807. }
  808. }
  809. if(ALC_AlarmSet[ALC_Alarm_UL3_Index] == true){
  810. ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index]++;
  811. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL3_Index] = 0;
  812. if(ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index] == 0xFFFFFFFF){
  813. ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index] = MBIC_ON_MAINTAIN_SEC;
  814. }
  815. }else{
  816. ALC_On_AlarmTimerCnt[ALC_Alarm_UL3_Index] = 0;
  817. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL3_Index]++;
  818. if(ALC_Off_AlarmTimerCnt[ALC_Alarm_UL3_Index] == 0xFFFFFFFF){
  819. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL3_Index] = MBIC_OFF_MAINTAIN_SEC;
  820. }
  821. }
  822. if(ALC_AlarmSet[ALC_Alarm_UL4_Index] == true){
  823. ALC_On_AlarmTimerCnt[ALC_Alarm_UL4_Index]++;
  824. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL4_Index] = 0;
  825. if(ALC_On_AlarmTimerCnt[ALC_Alarm_UL4_Index] == 0xFFFFFFFF){
  826. ALC_On_AlarmTimerCnt[ALC_Alarm_UL4_Index] = MBIC_ON_MAINTAIN_SEC;
  827. }
  828. }else{
  829. ALC_On_AlarmTimerCnt[ALC_Alarm_UL4_Index] = 0;
  830. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL4_Index]++;
  831. if(ALC_Off_AlarmTimerCnt[ALC_Alarm_UL4_Index] == 0xFFFFFFFF){
  832. ALC_Off_AlarmTimerCnt[ALC_Alarm_UL4_Index] = MBIC_OFF_MAINTAIN_SEC;
  833. }
  834. }
  835. /*AGC Alarm timer start*/
  836. if(AGC_AlarmSet[AGC_Alarm_DL1_Index] == true){
  837. AGC_On_AlarmTimerCnt[AGC_Alarm_DL1_Index]++;
  838. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL1_Index] = 0;
  839. if(AGC_On_AlarmTimerCnt[AGC_Alarm_DL1_Index] == 0xFFFFFFFF){
  840. AGC_On_AlarmTimerCnt[AGC_Alarm_DL1_Index] = MBIC_ON_MAINTAIN_SEC;
  841. }
  842. }else{
  843. AGC_On_AlarmTimerCnt[AGC_Alarm_DL1_Index] = 0;
  844. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL1_Index]++;
  845. if(AGC_Off_AlarmTimerCnt[AGC_Alarm_DL1_Index] == 0xFFFFFFFF){
  846. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL1_Index] = MBIC_OFF_MAINTAIN_SEC;
  847. }
  848. }
  849. if(AGC_AlarmSet[AGC_Alarm_DL2_Index] == true){
  850. AGC_On_AlarmTimerCnt[AGC_Alarm_DL2_Index]++;
  851. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL2_Index] = 0;
  852. if(AGC_On_AlarmTimerCnt[AGC_Alarm_DL2_Index] == 0xFFFFFFFF){
  853. AGC_On_AlarmTimerCnt[AGC_Alarm_DL2_Index] = MBIC_ON_MAINTAIN_SEC;
  854. }
  855. }else{
  856. AGC_On_AlarmTimerCnt[AGC_Alarm_DL2_Index] = 0;
  857. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL2_Index]++;
  858. if(AGC_Off_AlarmTimerCnt[AGC_Alarm_DL2_Index] == 0xFFFFFFFF){
  859. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL2_Index] = MBIC_OFF_MAINTAIN_SEC;
  860. }
  861. }
  862. if(AGC_AlarmSet[AGC_Alarm_DL3_Index] == true){
  863. AGC_On_AlarmTimerCnt[AGC_Alarm_DL3_Index]++;
  864. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL3_Index] = 0;
  865. if(AGC_On_AlarmTimerCnt[AGC_Alarm_DL3_Index] == 0xFFFFFFFF){
  866. AGC_On_AlarmTimerCnt[AGC_Alarm_DL3_Index] = MBIC_ON_MAINTAIN_SEC;
  867. }
  868. }else{
  869. AGC_On_AlarmTimerCnt[AGC_Alarm_DL3_Index] = 0;
  870. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL3_Index]++;
  871. if(AGC_Off_AlarmTimerCnt[AGC_Alarm_DL3_Index] == 0xFFFFFFFF){
  872. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL3_Index] = MBIC_OFF_MAINTAIN_SEC;
  873. }
  874. }
  875. if(AGC_AlarmSet[AGC_Alarm_DL4_Index] == true){
  876. AGC_On_AlarmTimerCnt[AGC_Alarm_DL4_Index]++;
  877. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL4_Index] = 0;
  878. if(AGC_On_AlarmTimerCnt[AGC_Alarm_DL4_Index] == 0xFFFFFFFF){
  879. AGC_On_AlarmTimerCnt[AGC_Alarm_DL4_Index] = MBIC_ON_MAINTAIN_SEC;
  880. }
  881. }else{
  882. AGC_On_AlarmTimerCnt[AGC_Alarm_DL4_Index] = 0;
  883. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL4_Index]++;
  884. if(AGC_Off_AlarmTimerCnt[AGC_Alarm_DL4_Index] == 0xFFFFFFFF){
  885. AGC_Off_AlarmTimerCnt[AGC_Alarm_DL4_Index] = MBIC_OFF_MAINTAIN_SEC;
  886. }
  887. }
  888. /*********************UL LEVEL HIGH START****************************/
  889. if(ADC_Alarm_UL_Set[DET_Alarm_UL1_Index ] == true){
  890. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL1_Index]++;
  891. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL1_Index] = 0;
  892. if(DET_UL_On_AlarmTimerCnt[DET_Alarm_UL1_Index] == 0xFFFFFFFF){
  893. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL1_Index] = MBIC_ON_MAINTAIN_SEC;
  894. }
  895. }
  896. else{
  897. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL1_Index] = 0;
  898. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL1_Index]++;
  899. if(DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL1_Index] == 0xFFFFFFFF){
  900. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL1_Index] = MBIC_OFF_MAINTAIN_SEC;
  901. }
  902. }
  903. if(ADC_Alarm_UL_Set[DET_Alarm_UL2_Index ] == true){
  904. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL2_Index]++;
  905. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL2_Index] = 0;
  906. if(DET_UL_On_AlarmTimerCnt[DET_Alarm_UL2_Index] == 0xFFFFFFFF){
  907. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL2_Index] = MBIC_ON_MAINTAIN_SEC;
  908. }
  909. }
  910. else{
  911. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL2_Index] = 0;
  912. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL2_Index]++;
  913. if(DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL2_Index] == 0xFFFFFFFF){
  914. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL2_Index] = MBIC_OFF_MAINTAIN_SEC;
  915. }
  916. }
  917. if(ADC_Alarm_UL_Set[DET_Alarm_UL3_Index ] == true){
  918. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL3_Index]++;
  919. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL3_Index] = 0;
  920. if(DET_UL_On_AlarmTimerCnt[DET_Alarm_UL3_Index] == 0xFFFFFFFF){
  921. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL3_Index] = MBIC_ON_MAINTAIN_SEC;
  922. }
  923. }
  924. else{
  925. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL3_Index] = 0;
  926. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL3_Index]++;
  927. if(DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL3_Index] == 0xFFFFFFFF){
  928. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL3_Index] = MBIC_OFF_MAINTAIN_SEC;
  929. }
  930. }
  931. if(ADC_Alarm_UL_Set[DET_Alarm_UL4_Index ] == true){
  932. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL4_Index]++;
  933. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL4_Index] = 0;
  934. if(DET_UL_On_AlarmTimerCnt[DET_Alarm_UL4_Index] == 0xFFFFFFFF){
  935. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL4_Index] = MBIC_ON_MAINTAIN_SEC;
  936. }
  937. }
  938. else{
  939. DET_UL_On_AlarmTimerCnt[DET_Alarm_UL4_Index] = 0;
  940. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL4_Index]++;
  941. if(DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL4_Index] == 0xFFFFFFFF){
  942. DET_UL_Off_AlarmTimerCnt[DET_Alarm_UL4_Index] = MBIC_OFF_MAINTAIN_SEC;
  943. }
  944. }
  945. /*********************DL LEVEL LOW START****************************/
  946. if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index ] == true){
  947. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL1_Index]++;
  948. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL1_Index] = 0;
  949. if(DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL1_Index] == 0xFFFFFFFF){
  950. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL1_Index] = MBIC_ON_MAINTAIN_SEC;
  951. }
  952. }
  953. else{
  954. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL1_Index] = 0;
  955. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL1_Index]++;
  956. if(DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL1_Index] == 0xFFFFFFFF){
  957. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL1_Index] = MBIC_OFF_MAINTAIN_SEC;
  958. }
  959. }
  960. if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL2_Index ] == true){
  961. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL2_Index]++;
  962. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL2_Index] = 0;
  963. if(DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL2_Index] == 0xFFFFFFFF){
  964. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL2_Index] = MBIC_ON_MAINTAIN_SEC;
  965. }
  966. }
  967. else{
  968. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL2_Index] = 0;
  969. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL2_Index]++;
  970. if(DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL2_Index] == 0xFFFFFFFF){
  971. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL2_Index] = MBIC_OFF_MAINTAIN_SEC;
  972. }
  973. }
  974. if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL3_Index ] == true){
  975. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL3_Index]++;
  976. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL3_Index] = 0;
  977. if(DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL3_Index] == 0xFFFFFFFF){
  978. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL3_Index] = MBIC_ON_MAINTAIN_SEC;
  979. }
  980. }
  981. else{
  982. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL3_Index] = 0;
  983. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL3_Index]++;
  984. if(DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL3_Index] == 0xFFFFFFFF){
  985. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL3_Index] = MBIC_OFF_MAINTAIN_SEC;
  986. }
  987. }
  988. if(ADC_Alarm_DL_Low_Set[DET_Alarm_DL4_Index ] == true){
  989. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL4_Index]++;
  990. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL4_Index] = 0;
  991. if(DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL4_Index] == 0xFFFFFFFF){
  992. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL4_Index] = MBIC_ON_MAINTAIN_SEC;
  993. }
  994. }
  995. else{
  996. DET_DL_Low_On_AlarmTimerCnt[DET_Alarm_DL4_Index] = 0;
  997. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL4_Index]++;
  998. if(DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL4_Index] == 0xFFFFFFFF){
  999. DET_DL_Low_Off_AlarmTimerCnt[DET_Alarm_DL4_Index] = MBIC_OFF_MAINTAIN_SEC;
  1000. }
  1001. }
  1002. /*********************DL LEVEL LOW END****************************/
  1003. /*********************DL LEVEL HIGH START***************************/
  1004. if(ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index ] == true){
  1005. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL1_Index]++;
  1006. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL1_Index] = 0;
  1007. if(DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL1_Index] == 0xFFFFFFFF){
  1008. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL1_Index] = MBIC_ON_MAINTAIN_SEC;
  1009. }
  1010. }
  1011. else{
  1012. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL1_Index] = 0;
  1013. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL1_Index]++;
  1014. if(DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL1_Index] == 0xFFFFFFFF){
  1015. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL1_Index] = MBIC_OFF_MAINTAIN_SEC;
  1016. }
  1017. }
  1018. if(ADC_Alarm_DL_High_Set[DET_Alarm_DL2_Index ] == true){
  1019. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL2_Index]++;
  1020. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL2_Index] = 0;
  1021. if(DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL2_Index] == 0xFFFFFFFF){
  1022. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL2_Index] = MBIC_ON_MAINTAIN_SEC;
  1023. }
  1024. }
  1025. else{
  1026. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL2_Index] = 0;
  1027. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL2_Index]++;
  1028. if(DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL2_Index] == 0xFFFFFFFF){
  1029. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL2_Index] = MBIC_OFF_MAINTAIN_SEC;
  1030. }
  1031. }
  1032. if(ADC_Alarm_DL_High_Set[DET_Alarm_DL3_Index ] == true){
  1033. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL3_Index]++;
  1034. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL3_Index] = 0;
  1035. if(DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL3_Index] == 0xFFFFFFFF){
  1036. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL3_Index] = MBIC_ON_MAINTAIN_SEC;
  1037. }
  1038. }
  1039. else{
  1040. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL3_Index] = 0;
  1041. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL3_Index]++;
  1042. if(DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL3_Index] == 0xFFFFFFFF){
  1043. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL3_Index] = MBIC_OFF_MAINTAIN_SEC;
  1044. }
  1045. }
  1046. if(ADC_Alarm_DL_High_Set[DET_Alarm_DL4_Index ] == true){
  1047. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL4_Index]++;
  1048. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL4_Index] = 0;
  1049. if(DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL4_Index] == 0xFFFFFFFF){
  1050. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL4_Index] = MBIC_ON_MAINTAIN_SEC;
  1051. }
  1052. }
  1053. else{
  1054. DET_DL_High_On_AlarmTimerCnt[DET_Alarm_DL4_Index] = 0;
  1055. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL4_Index]++;
  1056. if(DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL4_Index] == 0xFFFFFFFF){
  1057. DET_DL_High_Off_AlarmTimerCnt[DET_Alarm_DL4_Index] = MBIC_OFF_MAINTAIN_SEC;
  1058. }
  1059. }
  1060. /*********************DL LEVEL HIGH END***************************/
  1061. #if 0 // PYJ.2020.06.19_BEGIN --
  1062. if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index] == true){
  1063. MBIC_ShutdownCnt[MBIC_Shutdown_DL1]++;
  1064. }else{
  1065. MBIC_ShutdownCnt[MBIC_Shutdown_DL1] = 0;
  1066. }
  1067. if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL2_Shutdown_Index] == true){
  1068. MBIC_ShutdownCnt[MBIC_Shutdown_DL2]++;
  1069. }else{
  1070. MBIC_ShutdownCnt[MBIC_Shutdown_DL2] = 0;
  1071. }
  1072. if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL3_Shutdown_Index] == true){
  1073. MBIC_ShutdownCnt[MBIC_Shutdown_DL3]++;
  1074. }else{
  1075. MBIC_ShutdownCnt[MBIC_Shutdown_DL3] = 0;
  1076. }
  1077. if(ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL4_Shutdown_Index] == true){
  1078. MBIC_ShutdownCnt[MBIC_Shutdown_DL4]++;
  1079. }else{
  1080. MBIC_ShutdownCnt[MBIC_Shutdown_DL4] = 0;
  1081. }
  1082. if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index] == true){
  1083. MBIC_ShutdownCnt[MBIC_Shutdown_UL1]++;
  1084. }else{
  1085. MBIC_ShutdownCnt[MBIC_Shutdown_UL1] = 0;
  1086. }
  1087. if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL2_Shutdown_Index] == true){
  1088. MBIC_ShutdownCnt[MBIC_Shutdown_UL2]++;
  1089. }else{
  1090. MBIC_ShutdownCnt[MBIC_Shutdown_UL2] = 0;
  1091. }
  1092. if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL3_Shutdown_Index] == true){
  1093. MBIC_ShutdownCnt[MBIC_Shutdown_UL3]++;
  1094. }else{
  1095. MBIC_ShutdownCnt[MBIC_Shutdown_UL3] = 0;
  1096. }
  1097. if(ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL4_Shutdown_Index] == true){
  1098. MBIC_ShutdownCnt[MBIC_Shutdown_UL4]++;
  1099. }else{
  1100. MBIC_ShutdownCnt[MBIC_Shutdown_UL4] = 0;
  1101. }
  1102. #endif // PYJ.2020.06.19_END --
  1103. /*3 Sec Time Cnt */
  1104. if(AlarmTimerOnSet == true){
  1105. if(AlarmTimerOnCnt == 0xFFFFFFFF)
  1106. AlarmTimerOnCnt = MBIC_ON_MAINTAIN_SEC;
  1107. else{
  1108. AlarmTimerOnCnt++;
  1109. }
  1110. }
  1111. else{
  1112. AlarmTimerOnCnt = 0;
  1113. }
  1114. /*10 Sec Time Cnt*/
  1115. if(AlarmTimerOffSet == true){
  1116. if(AlarmTimerOffCnt == 0xFFFFFFFF)
  1117. AlarmTimerOffCnt = MBIC_OFF_MAINTAIN_SEC;
  1118. else{
  1119. AlarmTimerOffCnt++;
  1120. }
  1121. }
  1122. else{
  1123. AlarmTimerOffCnt = 0;
  1124. }
  1125. }
  1126. /* USER CODE END Callback 1 */
  1127. }
  1128. /**
  1129. * @brief This function is executed in case of error occurrence.
  1130. * @retval None
  1131. */
  1132. void Error_Handler(void)
  1133. {
  1134. /* USER CODE BEGIN Error_Handler_Debug */
  1135. /* User can add his own implementation to report the HAL error return state */
  1136. /* USER CODE END Error_Handler_Debug */
  1137. }
  1138. #ifdef USE_FULL_ASSERT
  1139. /**
  1140. * @brief Reports the name of the source file and the source line number
  1141. * where the assert_param error has occurred.
  1142. * @param file: pointer to the source file name
  1143. * @param line: assert_param error line source number
  1144. * @retval None
  1145. */
  1146. void assert_failed(uint8_t *file, uint32_t line)
  1147. {
  1148. /* USER CODE BEGIN 6 */
  1149. /* User can add his own implementation to report the file name and line number,
  1150. tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  1151. /* USER CODE END 6 */
  1152. }
  1153. #endif /* USE_FULL_ASSERT */
  1154. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/