新手上路
- 积分
- 44
- 金钱
- 44
- 注册时间
- 2019-1-15
- 在线时间
- 9 小时
|
1金钱
本帖最后由 mayuanyun 于 2022-2-11 16:23 编辑
刚开始运行时程序在led_task中,然后触发外部中断之后,程序进入到shell_task中之后,就一直在就一直在shell_task中了,这是为啥阿,求大神解救
static void shell_on_task(void const * argument)
{
UNUSED_PARAMETER(argument);
uint32_t value = pdFALSE;
while(1)
{
value = ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
if(value == pdTRUE)
{
value = pdFALSE;
drv_beep->beep_high();
vTaskDelay(1000);
drv_beep->beep_low();
vTaskDelay(1000);
}
vTaskDelay(20);
}
}
static void led_on_task(void const * argument)
{
UNUSED_PARAMETER(argument);
while(1)
{
drv_led->led_on();
vTaskDelay(1000);
drv_led->led_off();
vTaskDelay(1000);
}
}
static void shell_handle(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
BaseType_t xHigherPriorityTaskWoken;
if(pin == SHELL_GPIO_PIN_NUM)
{
vTaskDelay(20);
if(get_shell_status() == SHELL_ON)
{
if(SHELL_TASK_Handle!=NULL)
{
vTaskNotifyGiveFromISR(SHELL_TASK_Handle,&xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);//如果需要的话进行一次任务切换
}
}
}
}
void main(void)
{
shell_exit_init();
led_init();
if (pdPASS != xTaskCreate((TaskFunction_t)led_on_task, "LOGGER", 256, NULL, 1, &LED_TASK_Handle))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
if (pdPASS != xTaskCreate((TaskFunction_t)shell_on_task, "LOGGER1", 256, NULL, 2, &SHELL_TASK_Handle))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
NRF_LOG_INFO("HRS FreeRTOS example started.");
// Start FreeRTOS scheduler.
vTaskStartScheduler();
for (;;)
{
APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
}
}
|
|