1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

cpu/esp_common/freertos: allow platform independent compilation

This commit is contained in:
Gunar Schorcht 2022-06-17 07:07:41 +02:00
parent 24103ad58a
commit e4f1a94219
6 changed files with 36 additions and 27 deletions

View File

@ -55,7 +55,7 @@ QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
const uint8_t ucQueueType )
{
DEBUG("%s pid=%d len=%u size=%u type=%u ", __func__,
DEBUG("%s pid=%d len=%u size=%u type=%u\n", __func__,
thread_getpid(), uxQueueLength, uxItemSize, ucQueueType);
uint32_t queue_size = uxQueueLength * uxItemSize;
@ -116,8 +116,8 @@ BaseType_t IRAM_ATTR _queue_generic_send(QueueHandle_t xQueue,
TickType_t xTicksToWait,
BaseType_t * const pxHigherPriorityTaskWoken)
{
DEBUG("%s pid=%d prio=%d queue=%p pos=%d wait=%u woken=%p isr=%d\n", __func__,
thread_getpid(), sched_threads[thread_getpid()]->priority,
DEBUG("%s pid=%d prio=%d queue=%p pos=%d wait=%"PRIu32" woken=%p isr=%d\n", __func__,
thread_getpid(), thread_get_priority(thread_get_active()),
xQueue, xCopyPosition, xTicksToWait, pxHigherPriorityTaskWoken,
irq_is_in());
@ -163,7 +163,7 @@ BaseType_t IRAM_ATTR _queue_generic_send(QueueHandle_t xQueue,
list_node_t *next = list_remove_head(&queue->receiving);
thread_t *proc = container_of((clist_node_t*)next, thread_t, rq_entry);
sched_set_status(proc, STATUS_PENDING);
ctx_switch = proc->priority < sched_threads[thread_getpid()]->priority;
ctx_switch = proc->priority < thread_get_priority(thread_get_active());
DEBUG("%s pid=%d queue=%p unlock waiting pid=%d switch=%d\n",
__func__, thread_getpid(), xQueue, proc->pid, ctx_switch);
@ -222,8 +222,8 @@ BaseType_t IRAM_ATTR _queue_generic_recv (QueueHandle_t xQueue,
const BaseType_t xJustPeeking,
BaseType_t * const pxHigherPriorityTaskWoken)
{
DEBUG("%s pid=%d prio=%d queue=%p wait=%u peek=%u woken=%p isr=%d\n", __func__,
thread_getpid(), sched_threads[thread_getpid()]->priority,
DEBUG("%s pid=%d prio=%d queue=%p wait=%"PRIu32" peek=%u woken=%p isr=%d\n", __func__,
thread_getpid(), thread_get_priority(thread_get_active()),
xQueue, xTicksToWait, xJustPeeking, pxHigherPriorityTaskWoken,
irq_is_in());
@ -269,7 +269,7 @@ BaseType_t IRAM_ATTR _queue_generic_recv (QueueHandle_t xQueue,
sched_set_status(proc, STATUS_PENDING);
/* test whether context switch is required */
bool ctx_switch = proc->priority < sched_threads[thread_getpid()]->priority;
bool ctx_switch = proc->priority < thread_get_priority(thread_get_active());
DEBUG("%s pid=%d queue=%p unlock waiting pid=%d switch=%d\n",
__func__, thread_getpid(), xQueue, proc->pid, ctx_switch);
@ -326,8 +326,8 @@ BaseType_t IRAM_ATTR xQueueGenericSend( QueueHandle_t xQueue,
TickType_t xTicksToWait,
const BaseType_t xCopyPosition )
{
DEBUG("%s pid=%d prio=%d queue=%p wait=%u pos=%d\n", __func__,
thread_getpid(), sched_threads[thread_getpid()]->priority,
DEBUG("%s pid=%d prio=%d queue=%p wait=%"PRIu32" pos=%d\n", __func__,
thread_getpid(), thread_get_priority(thread_get_active()),
xQueue, xTicksToWait, xCopyPosition);
return _queue_generic_send(xQueue, pvItemToQueue, xCopyPosition,
@ -340,7 +340,7 @@ BaseType_t IRAM_ATTR xQueueGenericSendFromISR( QueueHandle_t xQueue,
const BaseType_t xCopyPosition )
{
DEBUG("%s pid=%d prio=%d queue=%p pos=%d woken=%p\n", __func__,
thread_getpid(), sched_threads[thread_getpid()]->priority,
thread_getpid(), thread_get_priority(thread_get_active()),
xQueue, xCopyPosition, pxHigherPriorityTaskWoken);
return _queue_generic_send(xQueue, pvItemToQueue, xCopyPosition,
@ -352,8 +352,8 @@ BaseType_t IRAM_ATTR xQueueGenericReceive (QueueHandle_t xQueue,
TickType_t xTicksToWait,
const BaseType_t xJustPeeking)
{
DEBUG("%s pid=%d prio=%d queue=%p wait=%u peek=%d\n", __func__,
thread_getpid(), sched_threads[thread_getpid()]->priority,
DEBUG("%s pid=%d prio=%d queue=%p wait=%"PRIu32" peek=%d\n", __func__,
thread_getpid(), thread_get_priority(thread_get_active()),
xQueue, xTicksToWait, xJustPeeking);
return _queue_generic_recv(xQueue, pvBuffer, xTicksToWait,
@ -365,7 +365,7 @@ BaseType_t IRAM_ATTR xQueueReceiveFromISR (QueueHandle_t xQueue,
BaseType_t * const pxHigherPriorityTaskWoken)
{
DEBUG("%s pid=%d prio=%d queue=%p woken=%p\n", __func__,
thread_getpid(), sched_threads[thread_getpid()]->priority,
thread_getpid(), thread_get_priority(thread_get_active()),
xQueue, pxHigherPriorityTaskWoken);
return _queue_generic_recv(xQueue, pvBuffer, 0,

View File

@ -84,7 +84,7 @@ BaseType_t xSemaphoreGive (SemaphoreHandle_t xSemaphore)
BaseType_t xSemaphoreTake (SemaphoreHandle_t xSemaphore,
TickType_t xTicksToWait)
{
DEBUG("%s mutex=%p wait=%u\n", __func__, xSemaphore, xTicksToWait);
DEBUG("%s mutex=%p wait=%"PRIu32"\n", __func__, xSemaphore, xTicksToWait);
assert(xSemaphore != NULL);
@ -137,7 +137,7 @@ BaseType_t xSemaphoreGiveRecursive (SemaphoreHandle_t xSemaphore)
BaseType_t xSemaphoreTakeRecursive (SemaphoreHandle_t xSemaphore,
TickType_t xTicksToWait)
{
DEBUG("%s rmutex=%p wait=%u\n", __func__, xSemaphore, xTicksToWait);
DEBUG("%s rmutex=%p wait=%"PRIu32"\n", __func__, xSemaphore, xTicksToWait);
assert(xSemaphore != NULL);
assert(((_rmutex_t*)xSemaphore)->type == queueQUEUE_TYPE_RECURSIVE_MUTEX);

View File

@ -66,14 +66,14 @@ BaseType_t xTaskCreatePinnedToCore(TaskFunction_t pvTaskCode,
/* FreeRTOS priority values have to be inverted */
uxPriority = SCHED_PRIO_LEVELS - uxPriority - 1;
DEBUG("%s name=%s size=%d prio=%d pvCreatedTask=%p xCoreId=%d",
DEBUG("%s name=%s size=%"PRIu32" prio=%u pvCreatedTask=%p xCoreId=%d\n",
__func__, pcName, usStackDepth, uxPriority, pvCreatedTask, xCoreID);
char* stack = malloc(usStackDepth + sizeof(thread_t));
if (!stack) {
LOG_TAG_ERROR("freertos", "not enough memory to create task %s with "
"stack size of %d bytes\n", pcName, usStackDepth);
"stack size of %"PRIu32" bytes\n", pcName, usStackDepth);
abort();
return pdFALSE;
}
@ -249,7 +249,7 @@ void vTaskExitCritical( portMUX_TYPE *mux )
void vTaskStepTick(const TickType_t xTicksToJump)
{
DEBUG("%s xTicksToJump=%d\n", __func__, xTicksToJump);
DEBUG("%s xTicksToJump=%"PRIu32"\n", __func__, xTicksToJump);
/*
* TODO:
* At the moment, only the calling task is set to sleep state. Usually, the

View File

@ -71,13 +71,14 @@ TimerHandle_t xTimerCreate (const char * const pcTimerName,
timer->ztimer.callback = _ztimer_callback;
timer->ztimer.arg = timer;
DEBUG("%s %p %s %d %u\n", __func__, timer, pcTimerName, xTimerPeriod, uxAutoReload);
DEBUG("%s %p %s %"PRIu32" %u\n",
__func__, timer, pcTimerName, xTimerPeriod, uxAutoReload);
return timer;
}
BaseType_t xTimerDelete(TimerHandle_t xTimer, TickType_t xBlockTime)
{
DEBUG("%s %p %d\n", __func__, xTimer, xBlockTime);
DEBUG("%s %p %"PRIu32"\n", __func__, xTimer, xBlockTime);
assert(xTimer != NULL);
freertos_ztimer_t* timer = (freertos_ztimer_t*)xTimer;
@ -89,7 +90,7 @@ BaseType_t xTimerDelete(TimerHandle_t xTimer, TickType_t xBlockTime)
BaseType_t xTimerStart (TimerHandle_t xTimer, TickType_t xBlockTime)
{
DEBUG("%s %p %d\n", __func__, xTimer, xBlockTime);
DEBUG("%s %p %"PRIu32"\n", __func__, xTimer, xBlockTime);
assert(xTimer != NULL);
freertos_ztimer_t* timer = (freertos_ztimer_t*)xTimer;
@ -100,7 +101,7 @@ BaseType_t xTimerStart (TimerHandle_t xTimer, TickType_t xBlockTime)
BaseType_t xTimerStop (TimerHandle_t xTimer, TickType_t xBlockTime)
{
DEBUG("%s %p %d\n", __func__, xTimer, xBlockTime);
DEBUG("%s %p %"PRIu32"\n", __func__, xTimer, xBlockTime);
assert(xTimer != NULL);
freertos_ztimer_t* timer = (freertos_ztimer_t*)xTimer;
@ -111,7 +112,7 @@ BaseType_t xTimerStop (TimerHandle_t xTimer, TickType_t xBlockTime)
BaseType_t xTimerReset (TimerHandle_t xTimer, TickType_t xBlockTime)
{
DEBUG("%s %p %d\n", __func__, xTimer, xBlockTime);
DEBUG("%s %p %"PRIu32"\n", __func__, xTimer, xBlockTime);
assert(xTimer != NULL);
freertos_ztimer_t* timer = (freertos_ztimer_t*)xTimer;

View File

@ -27,16 +27,19 @@ extern "C" {
#endif
#define portTICK_PERIOD_MS 10
#define portTickType TickType_t
#define portTICK_RATE_MS portTICK_PERIOD_MS
#define BaseType_t portBASE_TYPE
#define UBaseType_t unsigned portBASE_TYPE
#define UBaseType_t portUBASE_TYPE
#define TickType_t portTICK_TYPE
#define StackType_t portSTACK_TYPE
#define portTickType TickType_t
#define pdMS_TO_TICKS(ms) ((TickType_t)(ms / portTICK_PERIOD_MS))
typedef uint32_t TickType_t;
#define xSemaphoreHandle SemaphoreHandle_t
uint32_t xPortGetTickRateHz(void);
BaseType_t xPortInIsrContext(void);

View File

@ -17,6 +17,7 @@
#include "stdint.h"
#ifndef MCU_ESP8266
#include "esp_heap_caps.h"
#include "esp_timer.h"
#endif
@ -29,8 +30,10 @@ extern "C" {
#define portBASE_TYPE int
#define portUBASE_TYPE unsigned portBASE_TYPE
#define portTICK_TYPE uint32_t
#define portSTACK_TYPE uint8_t
#define portMAX_DELAY 0xFFFFFFFF
#define portMAX_DELAY 0xFFFFFFFFUL
#define portMUX_TYPE mutex_t
#define portMUX_INITIALIZE mutex_init
@ -50,6 +53,8 @@ extern "C" {
#define portSET_INTERRUPT_MASK_FROM_ISR xPortSetInterruptMaskFromISR
#define portCLEAR_INTERRUPT_MASK_FROM_ISR vPortClearInterruptMaskFromISR
#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
#ifdef MCU_ESP32
#define portNUM_PROCESSORS 2