ESP32S2判断当前代码是否在中断
Posted: Thu Jul 01, 2021 10:22 am
想要移植使用rt-thread的软件包,做了接口适配。
但是比如事件组,在rt-thread里是一个统一接口无需判断是否在中断,FreeRTOS里是区分普通代码和中断代码调用不同的API。
所以问题是,我怎么判断当前代码是否在中断中执行?
但是比如事件组,在rt-thread里是一个统一接口无需判断是否在中断,FreeRTOS里是区分普通代码和中断代码调用不同的API。
所以问题是,我怎么判断当前代码是否在中断中执行?
- rt_err_t IRAM_ATTR rt_event_send(rt_event_t event, rt_uint32_t set)
- {
- if (vPortGetIPSR())
- {
- BaseType_t xHigherPriorityTaskWoken;
- BaseType_t xResult;
- xHigherPriorityTaskWoken = pdFALSE;
- xResult = xEventGroupSetBitsFromISR(event->xHandler, set, &xHigherPriorityTaskWoken);
- if (xResult != pdFAIL)
- {
- /* If xHigherPriorityTaskWoken is now set to pdTRUE then a context
- switch should be requested. The macro used is port specific and will
- be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to
- the documentation page for the port being used. */
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
- }
- }
- else
- {
- xEventGroupSetBits(event->xHandler, set);
- }
- return RT_EOK;
- }