|
发表于 2017-4-26 17:47:22
|
显示全部楼层
在FreeRTOS中应用,我主要修改了2个地方。
一是:
static void get_cur_thread_stack_info(uint32_t sp, uint32_t *start_addr, size_t *size) {
CMB_ASSERT(start_addr);
CMB_ASSERT(size);
#if (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTT)
*start_addr = (uint32_t) rt_thread_self()->stack_addr;
*size = rt_thread_self()->stack_size;
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSII)
extern OS_TCB *OSTCBCur;
*start_addr = (uint32_t) OSTCBCur->OSTCBStkBottom;
*size = OSTCBCur->OSTCBStkSize * sizeof(OS_STK);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSIII)
#error "not implemented, I hope you can do this"
//TODO ´ýʵÏÖ
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
TaskHandle_t xHandle;
TaskStatus_t xTaskDetails;
xHandle = xTaskGetCurrentTaskHandle();
vTaskGetInfo( xHandle,
&xTaskDetails,
pdTRUE, // Include the high water mark in xTaskDetails.
eInvalid ); // Include the task state in xTaskDetails.
*start_addr = (uint32_t)xTaskDetails.pxStackBase;
*size = xTaskDetails.usStackHighWaterMark;
//#error "not implemented, I hope you can do this"
//TODO ´ýʵÏÖ
#endif
}
二是:
static const char *get_cur_thread_name(void) {
#if (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTT)
return rt_thread_self()->name;
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSII)
extern OS_TCB *OSTCBCur;
#if OS_TASK_NAME_SIZE > 0 || OS_TASK_NAME_EN > 0
return (const char *)OSTCBCur->OSTCBTaskName;
#else
return NULL;
#endif /* OS_TASK_NAME_SIZE > 0 || OS_TASK_NAME_EN > 0 */
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSIII)
#error "not implemented, I hope you can do this"
//TODO ´ýʵÏÖ
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
TaskHandle_t xHandle;
TaskStatus_t xTaskDetails;
xHandle = xTaskGetCurrentTaskHandle();
vTaskGetInfo( xHandle,
&xTaskDetails,
pdTRUE, // Include the high water mark in xTaskDetails.
eInvalid ); // Include the task state in xTaskDetails.
return xTaskDetails.pcTaskName;
//#error "not implemented, I hope you can do this"
//TODO ´ýʵÏÖ
#endif
}
FreeRTOS不能直接调用系统函数获取stack_size,我就返回了usStackHighWaterMark剩余堆栈量,不知道是否可以这样用。
|
|