Hi Forum,
Just joining you here. Got a how-do-I-do-this for dummies question. I’m writing an application that fires a GPIO interrupt. I’ve got it to run one piece of code. I’m struggling to get it to fire off another Task.
I got the interrupt going by judicious and liberal use of copy and paste from an example library. So no credit goes tome for that. It uses the int_signal_handler. I was trying to get another task to run using xTaskNotifyGive(testTaskHandle) or the FromISR version of that. But both cause a kernal panic. Everything breaks. Clearly something critically wrong with my code!
Here’s the jist of it.
void testTask(void *pvParameter);
TaskHandle_t testTaskHandle = NULL;
TaskHandle_t lis3dhTaskHandle = NULL;
void app_main()
{
user_init();
xTaskCreate(&testTask, "TestTask", 1028, NULL, tskIDLE_PRIORITY + 5, &testTaskHandle );
}
void testTask(void *pvParameter)
{
ESP_LOGI(TAG, "TestTask: Starting");
while (1)
{
ESP_LOGI(TAG, "TestTask: Executing... ");
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
}
}
void user_task_interrupt (void *pvParameters)
{
...
while (1)
{
if (xQueueReceive(gpio_evt_queue, &gpio_num, portMAX_DELAY))
{
do interrupt stuff!
}
}
}
static void IRAM_ATTR int_signal_handler (void* arg) // Needed to change from IRAM to IRAM_ATTR
{
uint32_t gpio_num = (uint32_t) arg;
// send an event with GPIO to the interrupt user task
xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
// xTaskNotifyGive(testTaskHandle);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(testTaskHandle, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR( );
}
void user_init(void)
{
... blah
gpio_isr_handler_add(INT1_PIN, int_signal_handler, (void*) INT1_PIN );
... blah
xTaskCreate(user_task_interrupt, "user_task_interrupt", TASK_STACK_DEPTH, NULL, 2, &lis3dhTaskHandle);
}
user_task_interrupt executes fine. I’m trying to add another Task, testTask for now, as a wireframe into which I’ll copy another working task. Would love it if someone more experienced could give me a few pointers. Apologies if it’s an overly simple question.
Anyway, loving FreeRTOS. Thanks all.
Al.