FreeRTOS系统内核函数预览
taskYIELD(); //任务切换
taskENTER_CRITICAL() //进入临界区,用于任务中
taskEXIT_CRITICAL() //退出临界区,用于任务中
taskENTER_CRITICAL_FROM_ISR() //进入临界区,用于中断服务函数中
taskEXIT_CRITICAL_FROM_ISR() //退出临界区,用于中断服务函数中
taskDISABLE_INTERRUPTS() //关闭中断
taskENABLE_INTERRUPTS() //打开中断
vTaskStartScheduler() //开启任务调度器
vTaskEndScheduler() //关闭任务调度器
vTaskSuspendAll() //挂起任务调度器
xTaskResumeAll() //恢复任务调度器
vTaskStepTick() //设置系统节拍值
FreeRTOS系统内核函数详解
taskYIELD(); //任务切换
#define portYIELD() \
{
\
/* Set a PendSV to request a context switch. */ \
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; \
\
/* Barriers are normally not required but do ensure the code is completely \
within the specified behaviour for the architecture. */ \
__dsb( portSY_FULL_READ_WRITE ); \
__isb( portSY_FULL_READ_WRITE ); \
}
taskENTER_CRITICAL() //进入临界区,用于任务中
taskEXIT_CRITICAL() //退出临界区,用于任务中
taskENTER_CRITICAL_FROM_ISR() //进入临界区,用于中断服务函数中
taskEXIT_CRITICAL_FROM_ISR() //退出临界区,用于中断服务函数中
taskDISABLE_INTERRUPTS() //关闭中断
taskENABLE_INTERRUPTS() //打开中断
vTaskStartScheduler() //开启任务调度器
在这里插入代码片void vTaskStartScheduler( void )
{
BaseType_t xReturn;
/* Add the idle task at the lowest priority. */
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
{
StaticTask_t *pxIdleTaskTCBBuffer = NULL;
StackType_t *pxIdleTaskStackBuffer = NULL;
uint32_t ulIdleTaskStackSize;
/* The Idle task is created using user provided RAM - obtain the
address of the RAM then create the idle task. */
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize ); /*创建空闲任务*/
xIdleTaskHandle = xTaskCreateStatic( prvIdleTask,
"IDLE",
ulIdleTaskStackSize,
( void * ) NULL,
( tskIDLE_PRIORITY | portPRIVILEGE_BIT ),
pxIdleTaskStackBuffer,
pxIdleTaskTCBBuffer ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
if