总目录链接==>> AutoSAR入门和实战系列总目录
总目录链接==>> AutoSAR BSW高阶配置系列总目录
文章目录
我想切换一些 GPIO 以监控 CPU 活动和 FreeRTOS 上下文。更具体地说,我想:
在 CPU 休眠时让 GPIO 处于逻辑低状态,在 CPU 运行时(任务、中断中)让 GPIO 处于逻辑状态高,
当 CPU 在工作时,GPIO 处于逻辑状态高,当 CPU 不工作时,GPIO 处于逻辑状态低
,通过重新定义 traceTASK_SWITCHED_OUT 和 traceTASK_SWITCHED_IN 来监控 FreeRTOS 任务活动;
这是我的 traceTASK_SWITCHED_OUT 和 traceTASK_SWITCHED_IN 宏(25 是我用于空闲任务的 GPIO):
#ifndef traceTASK_SWITCHED_OUT
/* Called before a task has been selected to run. pxCurrentTCB holds a pointer
to the task control block of the task being switched out. */
#define traceTASK_SWITCHED_OUT() if(xTaskGetIdleTaskHandle() == pxCurrentTCB) \{ nrf_gpio_pin_clear(25); } \else { nrf_gpio_pin_clear((int)pxCurrentTCB->pxTaskTag ); }
#endif#ifndef traceTASK_SWITCHED_IN
/* Called after a task has been selected to run. pxCurrentTCB holds a pointer
to the task control block of the selected task. */
#define traceTASK_SWITCHED_IN() if(xTaskGetIdleTaskHandle() == pxCurrentTCB) \{ nrf_gpio_pin_set(25); } \else { nrf_gpio_pin_set((int)pxCurrentTCB->pxTaskTag ); }
#endif