/***************************************************************************** Function : osTickStart Description: Configure Tick Interrupt Start Input : none output : none return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed *****************************************************************************/ LITE_OS_SEC_TEXT_INIT UINT32 osTickStart(VOID) { UINT32 uwRet; if ((0 == OS_SYS_CLOCK) || (0 == LOSCFG_BASE_CORE_TICK_PER_SECOND) || (LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK))/*lint !e506*/ { return LOS_ERRNO_TICK_CFG_INVALID; } #if (OS_HWI_WITH_ARG == YES) osSetVector(SysTick_IRQn, (HWI_PROC_FUNC)osTickHandler, NULL); #else osSetVector(SysTick_IRQn, osTickHandler); #endif g_uwCyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND; g_ullTickCount = 0; uwRet = SysTick_Config(OS_SYS_CLOCK/LOSCFG_BASE_CORE_TICK_PER_SECOND); if (uwRet == 1) { return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL; } return LOS_OK; }
/***************************************************************************** Function : LOS_HwiCreate Description : create hardware interrupt Input : uwHwiNum --- hwi num to create usHwiPrio --- priority of the hwi usMode --- unused pfnHandler --- hwi handler uwArg --- param of the hwi handler Output : None Return : OS_SUCCESS on success or error code on failure *****************************************************************************/ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate( HWI_HANDLE_T uwHwiNum, HWI_PRIOR_T usHwiPrio, HWI_MODE_T usMode, HWI_PROC_FUNC pfnHandler, HWI_ARG_T uwArg ) { UINTPTR uvIntSave; (void)usMode; (void)uwArg; if (NULL == pfnHandler) { return OS_ERRNO_HWI_PROC_FUNC_NULL; } if (uwHwiNum >= OS_M0PLUS_IRQ_VECTOR_CNT) { return OS_ERRNO_HWI_NUM_INVALID; } if (m_pstHwiForm[uwHwiNum + OS_M0PLUS_SYS_VECTOR_CNT] != osHwiDefaultHandler) { return OS_ERRNO_HWI_ALREADY_CREATED; } if (usHwiPrio > OS_HWI_PRIO_LOWEST) { return OS_ERRNO_HWI_PRIO_INVALID; } uvIntSave = LOS_IntLock(); osSetVector(uwHwiNum, pfnHandler); LosAdapIrpEnable(uwHwiNum, usHwiPrio); LOS_IntRestore(uvIntSave); return LOS_OK; }