#include "task_hal.h" #include "task.h" #include "main.h" #include "Device_Regs.h" #include "McalLib.h" #define Z20_SYSTICK_CTRL_ENABLE_POS (0U) #define Z20_SYSTICK_CTRL_ENABLE_MASK (1U << Z20_SYSTICK_CTRL_ENABLE_POS) #define Z20_SYSTICK_CTRL_ENABLE(x) \ (((uint32)(((uint32)(x)) << Z20_SYSTICK_CTRL_ENABLE_POS)) & Z20_SYSTICK_CTRL_ENABLE_MASK) #define Z20_SYSTICK_INT_ENABLE_POS (1U) #define Z20_SYSTICK_INT_ENABLE_MASK (1U << Z20_SYSTICK_INT_ENABLE_POS) #define Z20_SYSTICK_INT_ENABLE(x) \ (((uint32)(((uint32)(x)) << Z20_SYSTICK_INT_ENABLE_POS)) & Z20_SYSTICK_INT_ENABLE_MASK) #define Z20_SYSTICK_CTRL_CLKSOURCE_POS (2U) #define Z20_SYSTICK_CTRL_CLKSOURCE_MASK (1U << Z20_SYSTICK_CTRL_CLKSOURCE_POS) #define Z20_SYSTICK_CTRL_CLKSOURCE(x) \ (((uint32)(((uint32)(x)) << Z20_SYSTICK_CTRL_CLKSOURCE_POS)) & Z20_SYSTICK_CTRL_CLKSOURCE_MASK) static Z20_SysTickType *const Z20_SysTickRegPtr = Z20_SYSTICK; #if (MCALLIB_OS_USED == MCALLIB_OS_BAREMETAL) static void Systick_Init(uint32 Reload_Value) { #if (MCALLIB_ENABLE_USER_MODE_SUPPORT == STD_ON) uint32 ModeSwitched; ModeSwitched = Sys_EnterPrivilegedMode(); #endif // set reload value Z20_SysTickRegPtr->LOAD = (uint32)Reload_Value-1; // Load the Z20_SYSTICK Counter Value Z20_SysTickRegPtr->VAL = (uint32)0U; // Disable Z20_SYSTICK IRQ and Enable Z20_SYSTICK Timer Z20_SysTickRegPtr->CTRL = (uint32)(Z20_SYSTICK_CTRL_CLKSOURCE(MCALLIB_SYSTEM_TICK_TIMER_CLKSOURCE) | Z20_SYSTICK_INT_ENABLE(1)| Z20_SYSTICK_CTRL_ENABLE(1)); #if (MCALLIB_ENABLE_USER_MODE_SUPPORT == STD_ON) if (1U == ModeSwitched) { Sys_EnterNonPrivilegedMode(); } #endif } #endif void InitSysTick(void) { uint32 CoreId = McalLib_GetCoreID(); /* Baremetal */ uint32 OsCounterFreq = McalLib_PreDefinedConfigPtr[CoreId]->CounterFreq; uint32_t Reload_Value = OsCounterFreq/ TICK_PER_S; #if (MCALLIB_OS_USED == MCALLIB_OS_BAREMETAL) Systick_Init(Reload_Value); #else //MCALLIB_OS_AUTOSAR (3U) //TODO HOOK monitor #endif (void)Reload_Value; } //TASK led BLINK static int i = 0; PT_THREAD(TaskBlinLed(struct pt *pt1 )) { PT_BEGIN(pt1); static struct timer input_timer; PT_END(pt1); } void InitLEDPort(void) { } PT_THREAD(TaskWDT(struct pt *pt1 )) { PT_BEGIN(pt1); Wdg_Service(); PT_END(pt1); } void InitWdt(void) { } //SYSTICK CALLBACK void SysTick_Handler(void) { Task_SysTick_Handler(); } //AUTOSAR OS void OS_TriggerGroup1ms(void) { }