@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
async_context_freertos.h
/*
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _PICO_ASYNC_CONTEXT_FREERTOS_H
#define _PICO_ASYNC_CONTEXT_FREERTOS_H
#include "pico/async_context.h"
// FreeRTOS includes
#include "FreeRTOS.h"
#include "semphr.h"
#include "timers.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_PRIORITY
#define ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_PRIORITY ( tskIDLE_PRIORITY + 4)
#endif
#ifndef ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_STACK_SIZE
#define ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_STACK_SIZE configMINIMAL_STACK_SIZE
#endif
typedef struct async_context_freertos async_context_freertos_t;
#if !defined(configNUMBER_OF_CORES) && defined(configNUM_CORES)
#if !portSUPPORT_SMP
#error configNUMBER_OF_CORES is the new name for configNUM_CORES
#else
// portSUPPORT_SMP was defined in old smp branch
#error configNUMBER_OF_CORES is the new name for configNUM_CORES, however it looks like you may need to define both as you are using an old SMP branch of FreeRTOS
#endif
#endif
typedef struct async_context_freertos_config {
UBaseType_t task_priority;
configSTACK_DEPTH_TYPE task_stack_size;
#if configSUPPORT_STATIC_ALLOCATION
StackType_t *task_stack;
#endif
#if configUSE_CORE_AFFINITY && configNUMBER_OF_CORES > 1
UBaseType_t task_core_id;
#endif
} async_context_freertos_config_t;
struct async_context_freertos {
async_context_t core;
SemaphoreHandle_t lock_mutex;
SemaphoreHandle_t work_needed_sem;
SemaphoreHandle_t task_complete_sem;
TimerHandle_t timer_handle;
TaskHandle_t task_handle;
#if configSUPPORT_STATIC_ALLOCATION
StaticSemaphore_t lock_mutex_buf;
StaticSemaphore_t work_needed_sem_buf;
StaticSemaphore_t task_complete_sem_buf;
StaticTimer_t timer_buf;
StaticTask_t task_buf;
#endif
uint8_t nesting;
volatile bool task_should_exit;
};
bool async_context_freertos_init(async_context_freertos_t *self, async_context_freertos_config_t *config);
static inline async_context_freertos_config_t async_context_freertos_default_config(void) {
async_context_freertos_config_t config = {
.task_priority = ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_PRIORITY,
.task_stack_size = ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_STACK_SIZE,
#if configUSE_CORE_AFFINITY && configNUMBER_OF_CORES > 1
.task_core_id = (UBaseType_t)-1, // none
#endif
};
return config;
}
static inline bool async_context_freertos_init_with_defaults(async_context_freertos_t *self) {
async_context_freertos_config_t config = async_context_freertos_default_config();
return async_context_freertos_init(self, &config);
}
#ifdef __cplusplus
}
#endif
#endif
async_context.h
async_context_freertos_init
bool async_context_freertos_init(async_context_freertos_t *self, async_context_freertos_config_t *config)
Initialize an async_context_freertos instance using the specified configuration.
Definition async_context_freertos.c:108
async_context_freertos_init_with_defaults
static bool async_context_freertos_init_with_defaults(async_context_freertos_t *self)
Initialize an async_context_freertos instance with default values.
Definition async_context_freertos.h:134
async_context_freertos_default_config
static async_context_freertos_config_t async_context_freertos_default_config(void)
Return a copy of the default configuration object used by async_context_freertos_init_with_defaults()...
Definition async_context_freertos.h:112
async_context_freertos_config
Configuration object for async_context_freertos instances.
Definition async_context_freertos.h:50
async_context_freertos_config::task_priority
UBaseType_t task_priority
Task priority for the async_context task.
Definition async_context_freertos.h:54
async_context_freertos_config::task_stack_size
configSTACK_DEPTH_TYPE task_stack_size
Stack size for the async_context task.
Definition async_context_freertos.h:58
async_context_freertos
Definition async_context_freertos.h:74