123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #include "Hal_Wdg.h"
- volatile uint8 notificationCount = 0;
- void WdgInit(void)
- {
- /* Initialize the Wdg driver */
- Wdg_43_Instance0_Init(&Wdg_Config_0_VS_0);
- /* Set the Wdg Trigger Condition in order to periodically service the Wdg */
- Wdg_43_Instance0_SetTriggerCondition(5000);
- /*Change the Wdg mode of operation */
- Wdg_43_Instance0_SetMode(WDGIF_FAST_MODE);
- /* Set the Wdg Trigger Condition in order to periodically service the Wdg */
- Wdg_43_Instance0_SetTriggerCondition(5000);
- }
- void Wdg_CallBackNotification1(void)
- {
- notificationCount = 1U;
- }
- static void HAL_1msPeriod(void)
- {
- uint16 cntTmp = 0u;
- /* Just for check time overflow or not? */
- cntTmp = hal_1ms_TimerCounter + 1u;
- if (0u != cntTmp)
- {
- hal_1ms_TimerCounter++;
- }
- cntTmp = hal_100ms_TimerCounter + 1u;
- if (0u != cntTmp)
- {
- hal_100ms_TimerCounter++;
- }
- }
- void vTimer1msCallback(TimerHandle_t pxTimer)
- {
- uint32 ulTimerID;
- // Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_ON);
- ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
- if(ulTimerID==0)
- {
- HAL_1msPeriod();
- }
- // Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_OFF);
- }
- boolean HAL_Is1msTickTimeout(void)
- {
- boolean result = FALSE;
- if (hal_1ms_TimerCounter)
- {
- result = TRUE;
- hal_1ms_TimerCounter--;
- }
- return result;
- }
- boolean HAL_Is100msTickTimeout(void)
- {
- boolean result = FALSE;
- if (hal_100ms_TimerCounter >= 100u)
- {
- result = TRUE;
- hal_100ms_TimerCounter -= 100u;
- }
- return result;
- }
- /* Get timer tick cnt for random seed. */
- uint32 HAL_GetTimerTickCnt(void)
- {
- /* This two variables not init before used, because it used for generate random */
- uint32 hardwareTimerTickCnt;
- uint32 timerTickCnt;
- #if 0
- /* For S32K1xx get timer counter(LPTIMER), get timer count will trigger the period incorrect. */
- hardwareTimerTickCnt = LPTMR_DRV_GetCounterValueByCount(INST_LPTMR1);
- #endif
- #pragma GCC diagnostic ignored "-Wuninitialized"
- timerTickCnt = ((hardwareTimerTickCnt & 0xFFFFu)) | (timerTickCnt << 16u);
- return timerTickCnt;
- }
- void WATCHDOG_HAL_Feed(void)
- {
- Wdg_43_Instance0_SetTriggerCondition(500);
- }
- typedef void (*AppAddr)(void);
- void DoResetECU(void)
- {
- IsFeedWdg = FALSE;
- Wdg_43_Instance0_SetTriggerCondition(0);
- while(1)
- {
- // AppAddr resetHandle = (AppAddr)(0x00);
- // (resetHandle)();
- ;
- }
- }
|