用cube生成了个freertos的工程,默认任务是通过这个函数创建的:
MX_FREERTOS_Init();
这个函数里,有两句:
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
第一句中的osThreadDef是个宏定义:
#define osThreadDef(name, thread, priority, instances, stacksz)
const osThreadDef_t os_thread_def_##name =
{ #name, (thread), (priority), (instances), (stacksz) }
其中的 ##name,这是什么用法?
os ThreadDef_t是个结构体:
typedef struct os_thread_def {
char *name; ///< Thread name
os_pthread pthread; ///< start address of thread function
osPriority tpriority; ///< initial thread priority
uint32_t instances; ///< maximum number of instances of that thread function
uint32_t stacksize; ///< stack size requirements in bytes; 0 is default stack size
} osThreadDef_t;
|