From cdc8a725a478ce317c4e90fcf3338d3cb486d6d2 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 11 Aug 2022 10:03:11 +0200 Subject: [PATCH] cpu/esp_common/freertos: changes required for BLE --- cpu/esp_common/freertos/queue.c | 12 ++++++----- cpu/esp_common/include/freertos/FreeRTOS.h | 3 ++- cpu/esp_common/include/freertos/portable.h | 24 ++++++++++++++++++++++ cpu/esp_common/include/freertos/queue.h | 5 +++++ cpu/esp_common/include/freertos/task.h | 1 + 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 cpu/esp_common/include/freertos/portable.h diff --git a/cpu/esp_common/freertos/queue.c b/cpu/esp_common/freertos/queue.c index 7f0aa871ae..33951e6418 100644 --- a/cpu/esp_common/freertos/queue.c +++ b/cpu/esp_common/freertos/queue.c @@ -95,7 +95,8 @@ QueueHandle_t xQueueCreateCountingSemaphore (const UBaseType_t uxMaxCount, queue = xQueueGenericCreate(uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE); - DEBUG("%s pid=%d queue=%p\n", __func__, thread_getpid(), queue); + DEBUG("%s pid=%d queue=%p max=%d initial=%d\n", __func__, + thread_getpid(), queue, uxMaxCount, uxInitialCount); if (queue != NULL) { queue->item_level = uxInitialCount; @@ -509,11 +510,12 @@ UBaseType_t uxQueueMessagesWaiting( QueueHandle_t xQueue ) BaseType_t xQueueGiveFromISR (QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken) { - /* this function only satisfies the linker and should not be called */ - assert(0); + DEBUG("%s pid=%d prio=%d queue=%p woken=%p\n", __func__, + thread_getpid(), thread_get_priority(thread_get_active()), + xQueue, pxHigherPriorityTaskWoken); - DEBUG("%s\n", __func__); - return pdFALSE; + return _queue_generic_send(xQueue, NULL, queueSEND_TO_BACK, + 0, pxHigherPriorityTaskWoken); } #endif /* DOXYGEN */ diff --git a/cpu/esp_common/include/freertos/FreeRTOS.h b/cpu/esp_common/include/freertos/FreeRTOS.h index 30e8df6f65..6fda3e444a 100644 --- a/cpu/esp_common/include/freertos/FreeRTOS.h +++ b/cpu/esp_common/include/freertos/FreeRTOS.h @@ -26,8 +26,9 @@ extern "C" { #define configASSERT assert #endif -#define portTICK_PERIOD_MS 10 +#define configTICK_RATE_HZ ((TickType_t)100) +#define portTICK_PERIOD_MS 10 #define portTICK_RATE_MS portTICK_PERIOD_MS #define BaseType_t portBASE_TYPE diff --git a/cpu/esp_common/include/freertos/portable.h b/cpu/esp_common/include/freertos/portable.h new file mode 100644 index 0000000000..98db50b4d4 --- /dev/null +++ b/cpu/esp_common/include/freertos/portable.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2022 Gunar Schorcht + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + * + * FreeRTOS to RIOT-OS adaption module for source code compatibility + */ + +/* Empty file, only required for source code compatibility */ + +#ifndef FREERTOS_PORTABLE_H +#define FREERTOS_PORTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* FREERTOS_PORTABLE_H */ diff --git a/cpu/esp_common/include/freertos/queue.h b/cpu/esp_common/include/freertos/queue.h index b3557c7077..2c38b0546b 100644 --- a/cpu/esp_common/include/freertos/queue.h +++ b/cpu/esp_common/include/freertos/queue.h @@ -108,6 +108,11 @@ UBaseType_t uxQueueMessagesWaiting( QueueHandle_t xQueue ); ( pxHigherPriorityTaskWoken ), \ queueSEND_TO_BACK ) +#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), \ + ( pxHigherPriorityTaskWoken ), \ + queueSEND_TO_BACK ) + #define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), \ ( pxHigherPriorityTaskWoken ), \ diff --git a/cpu/esp_common/include/freertos/task.h b/cpu/esp_common/include/freertos/task.h index 4b51c716e9..2d10e11ce3 100644 --- a/cpu/esp_common/include/freertos/task.h +++ b/cpu/esp_common/include/freertos/task.h @@ -31,6 +31,7 @@ extern "C" { #define taskENTER_CRITICAL portENTER_CRITICAL #define taskEXIT_CRITICAL portEXIT_CRITICAL +#define taskSCHEDULER_NOT_STARTED 1 #define taskSCHEDULER_RUNNING 2 typedef enum {