From 90e483785163a62a168b193ca82643fb55835553 Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Wed, 25 Oct 2023 19:55:54 +0100 Subject: [PATCH] Different stack trace now... --- main/main.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/main/main.c b/main/main.c index 0bd70db..bc6b98a 100644 --- a/main/main.c +++ b/main/main.c @@ -8,6 +8,7 @@ #include #include "freertos/FreeRTOS.h" //#include "freertos/projdefs.h" +#include "freertos/projdefs.h" #include "freertos/task.h" #include "dht22.h" #include "esp_log.h" @@ -54,33 +55,44 @@ void save_measurements() { // TODO - think about how to actually store this somewhere (for pushing and/or pulling) // and what sort of structures I could use ESP_LOGI(TAG, "Saved DHT data"); - xEventGroupClearBits(s_monitor_event_group, SENSOR_DHT22_BIT); + xEventGroupClearBitsFromISR(s_monitor_event_group, SENSOR_DHT22_BIT); } if (bits & SENSOR_PMS5003_BIT) { ESP_LOGI(TAG, "Saved PMS data"); // TODO - xEventGroupClearBits(s_monitor_event_group, SENSOR_PMS5003_BIT); + xEventGroupClearBitsFromISR(s_monitor_event_group, SENSOR_PMS5003_BIT); } + vTaskDelay(pdMS_TO_TICKS(100)); } } void read_from_pms5003() { + BaseType_t xHigherPriorityTaskWoken, xResult; + xHigherPriorityTaskWoken = pdFALSE; while (run_pms5003) { // TODO - actually collect some data ESP_LOGI(TAG, "Got PMS5003 data! Setting PMS bit now!"); - xEventGroupSetBitsFromISR(s_monitor_event_group, SENSOR_PMS5003_BIT); - vTaskDelay(pdMS_TO_TICKS(100)); // TODO: make this a config check + xResult = xEventGroupSetBitsFromISR(s_monitor_event_group, SENSOR_PMS5003_BIT, &xHigherPriorityTaskWoken); + if (xResult) { + portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + } + vTaskDelay(pdMS_TO_TICKS(1000)); // TODO: make this a config check } } void read_from_dht22() { + BaseType_t xHigherPriorityTaskWoken, xResult; + xHigherPriorityTaskWoken = pdFALSE; while (run_dht) { // Data reading is based on time, so need to block interrups etc portDISABLE_INTERRUPTS(); int ret = dht22_read(); portENABLE_INTERRUPTS(); ESP_LOGI(TAG, "Got DHT22 data! Setting DHT bit now!"); - xEventGroupSetBitsFromISR(s_monitor_event_group, SENSOR_DHT22_BIT); + xResult = xEventGroupSetBitsFromISR(s_monitor_event_group, SENSOR_DHT22_BIT, &xHigherPriorityTaskWoken); + if (xResult) { + portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + } vTaskDelay(pdMS_TO_TICKS(3000)); // TODO: make this a config check } }