@@ -52,6 +52,10 @@ static async_context_t *example_async_context(void) {
5252 async_context_freertos_config_t config = async_context_freertos_default_config ();
5353 config .task_priority = WORKER_TASK_PRIORITY ; // defaults to ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_PRIORITY
5454 config .task_stack_size = WORKER_TASK_STACK_SIZE ; // defaults to ASYNC_CONTEXT_DEFAULT_FREERTOS_TASK_STACK_SIZE
55+ #if configSUPPORT_STATIC_ALLOCATION
56+ static StackType_t async_context_freertos_task_stack [WORKER_TASK_STACK_SIZE ];
57+ config .task_stack = async_context_freertos_task_stack ;
58+ #endif
5559 if (!async_context_freertos_init (& async_context_instance , & config ))
5660 return NULL ;
5761 return & async_context_instance .core ;
@@ -127,8 +131,15 @@ void main_task(__unused void *params) {
127131 async_context_add_at_time_worker_in_ms (context , & worker_timeout , 0 );
128132#if USE_LED
129133 // start the led blinking
134+ #if configSUPPORT_STATIC_ALLOCATION
135+ static StackType_t blink_stack [BLINK_TASK_STACK_SIZE ];
136+ static StaticTask_t blink_buf ;
137+ xTaskCreateStatic (blink_task , "BlinkThread" , BLINK_TASK_STACK_SIZE , NULL , BLINK_TASK_PRIORITY , blink_stack , & blink_buf );
138+ #else
139+ static_assert (configSUPPORT_DYNAMIC_ALLOCATION , "" );
130140 xTaskCreate (blink_task , "BlinkThread" , BLINK_TASK_STACK_SIZE , NULL , BLINK_TASK_PRIORITY , NULL );
131- #endif
141+ #endif // configSUPPORT_STATIC_ALLOCATION
142+ #endif // USE_LED
132143 int count = 0 ;
133144 while (true) {
134145#if configNUMBER_OF_CORES > 1
@@ -146,11 +157,19 @@ void main_task(__unused void *params) {
146157
147158void vLaunch ( void ) {
148159 TaskHandle_t task ;
160+ #if configSUPPORT_STATIC_ALLOCATION
161+ static StackType_t main_stack [MAIN_TASK_STACK_SIZE ];
162+ static StaticTask_t main_buf ;
163+ task = xTaskCreateStatic (main_task , "MainThread" , MAIN_TASK_STACK_SIZE , NULL , MAIN_TASK_PRIORITY , main_stack , & main_buf );
164+ #else
165+ static_assert (configSUPPORT_DYNAMIC_ALLOCATION , "" );
149166 xTaskCreate (main_task , "MainThread" , MAIN_TASK_STACK_SIZE , NULL , MAIN_TASK_PRIORITY , & task );
150-
167+ #endif // configSUPPORT_STATIC_ALLOCATION
151168#if configUSE_CORE_AFFINITY && configNUMBER_OF_CORES > 1
152169 // we must bind the main task to one core (well at least while the init is called)
153170 vTaskCoreAffinitySet (task , 1 );
171+ #else
172+ (void )task ;
154173#endif
155174
156175 /* Start the tasks and timer running. */
0 commit comments