Select one of the symbols to view example projects that use it.
 
Outline
#define _PICO_ASYNC_CONTEXT_FREERTOS_H
#include "pico/async_context.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "timers.h"
#define ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_PRIORITY
#define ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_STACK_SIZE
async_context_freertos
async_context_freertos_config
async_context_freertos
async_context_freertos_init(async_context_freertos_t *, async_context_freertos_config_t *);
async_context_freertos_default_config()
async_context_freertos_init_with_defaults(async_context_freertos_t *)
Files
loading...
SourceVuRaspberry Pi Pico SDK and ExamplesPicoSDKsrc/rp2_common/pico_async_context/include/pico/async_context_freertos.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * 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 /** \file pico/async_context.h * \defgroup async_context_freertos async_context_freertos * \ingroup pico_async_context * * \brief async_context_freertos provides an implementation of \ref async_context that handles asynchronous * work in a separate FreeRTOS task. *//* ... */ #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 /** * \brief Configuration object for async_context_freertos instances. *//* ... */ typedef struct async_context_freertos_config { /** * \brief Task priority for the async_context task *//* ... */ UBaseType_t task_priority; /** * \brief Stack size for the async_context task *//* ... */ configSTACK_DEPTH_TYPE task_stack_size; /** * \brief the core ID (see \ref portGET_CORE_ID()) to pin the task to. * This is only relevant in SMP mode. *//* ... */ #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; TimerHandle_t timer_handle; TaskHandle_t task_handle; uint8_t nesting; volatile bool task_should_exit; ...}; /*! * \brief Initialize an async_context_freertos instance using the specified configuration * \ingroup async_context_freertos * * If this method succeeds (returns true), then the async_context is available for use * and can be de-initialized by calling async_context_deinit(). * * \param self a pointer to async_context_freertos structure to initialize * \param config the configuration object specifying characteristics for the async_context * \return true if initialization is successful, false otherwise *//* ... */ bool async_context_freertos_init(async_context_freertos_t *self, async_context_freertos_config_t *config); /*! * \brief Return a copy of the default configuration object used by \ref async_context_freertos_init_with_defaults() * \ingroup async_context_freertos * * The caller can then modify just the settings it cares about, and call \ref async_context_freertos_init() * \return the default configuration object *//* ... */ 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; }{ ... } /*! * \brief Initialize an async_context_freertos instance with default values * \ingroup async_context_freertos * * If this method succeeds (returns true), then the async_context is available for use * and can be de-initialized by calling async_context_deinit(). * * \param self a pointer to async_context_freertos structure to initialize * \return true if initialization is successful, false otherwise *//* ... */ 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 }extern "C" { ... } #endif /* ... */ #endif
Details