Nexus Embedded Platform 1.0.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
freertos.h
Go to the documentation of this file.
1
19#ifndef NEXUS_OS_FREERTOS_H
20#define NEXUS_OS_FREERTOS_H
21#include "FreeRTOS.h"
22#include "nexus/core/time.h"
23#include "nexus/os/wait.h"
24#include "queue.h"
25#include "semphr.h"
26#include "task.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
36typedef struct {
37 StaticSemaphore_t storage;
38 SemaphoreHandle_t handle;
39 uint32_t sequence;
40 uint32_t waiting;
42
51typedef struct {
52 StaticTask_t control;
53 StaticSemaphore_t finished_storage;
54 SemaphoreHandle_t finished;
55 TaskHandle_t handle;
56 void (*entry)(void*);
57 void* context;
59
61typedef struct {
62 StaticQueue_t control;
63 QueueHandle_t handle;
64 uint32_t users;
66
68typedef struct {
69 TaskHandle_t receiver;
70 UBaseType_t index;
71 uint32_t sequence;
72 uint32_t waiting;
74
76typedef struct {
77 StaticTask_t control;
78 TaskHandle_t handle;
80
83 StaticSemaphore_t storage;
84 SemaphoreHandle_t handle;
86 uint32_t active;
88
97
151 StackType_t* stack, size_t stack_words,
152 UBaseType_t priority, void (*entry)(void*),
153 void* context);
184 nx_time_us_t deadline);
195 size_t storage_bytes, size_t depth,
196 size_t item_size);
207 TickType_t wait_ticks);
216 TickType_t wait_ticks);
223
234 const void* item,
235 nx_time_us_t deadline);
244 void* item, nx_time_us_t deadline);
256 TaskHandle_t receiver, UBaseType_t index);
290 const char* name, StackType_t* stack,
291 size_t stack_words, UBaseType_t priority,
292 void (*entry)(void*), void* context);
324 uint8_t* storage,
325 size_t storage_bytes, size_t depth,
326 size_t item_size,
327 size_t maximum_waiters);
340 const void* item, nx_time_us_t deadline,
352 void* item, nx_time_us_t deadline,
372
373#ifdef __cplusplus
374}
375#endif
376
377#endif /* NEXUS_OS_FREERTOS_H */
nx_result_t nx_freertos_closable_queue_send_until(nx_freertos_closable_queue_t *queue, const void *item, nx_time_us_t deadline, nx_freertos_queue_waiter_t *waiter)
Send with close-aware admission and absolute deadline.
nx_result_t nx_freertos_closable_queue_receive_until(nx_freertos_closable_queue_t *queue, void *item, nx_time_us_t deadline, nx_freertos_queue_waiter_t *waiter)
Receive existing items after close, then CANCELLED.
nx_result_t nx_freertos_closable_queue_init(nx_freertos_closable_queue_t *queue, uint8_t *storage, size_t storage_bytes, size_t depth, size_t item_size, size_t maximum_waiters)
Initialize an optional reliably closable byte-copy queue.
nx_result_t nx_freertos_queue_waiter_init(nx_freertos_queue_waiter_t *waiter)
Initialize one exact caller-owned queue waiter.
nx_result_t nx_freertos_permanent_task_start(nx_freertos_permanent_task_t *task, const char *name, StackType_t *stack, size_t stack_words, UBaseType_t priority, void(*entry)(void *), void *context)
Start a task whose entry must never return.
nx_result_t nx_freertos_notify_destroy(nx_freertos_notify_t *notification)
Destroy after publishers and waiter have stopped and joined.
nx_result_t nx_freertos_queue_receive(nx_freertos_queue_t *queue, void *item, TickType_t wait_ticks)
Receive one byte-copy item.
nx_result_t nx_freertos_task_join(nx_freertos_task_t *task, nx_time_us_t deadline)
Join a cooperatively returned task and reclaim kernel state.
nx_result_t nx_freertos_direct_notify_destroy(nx_freertos_direct_notify_t *notification)
Unbind after all publishers stop and join.
struct nx_freertos_queue_waiter nx_freertos_queue_waiter_t
Caller-owned single-operation latch for a closable queue.
nx_wait_port_t nx_freertos_direct_notify_port(nx_freertos_direct_notify_t *notification)
Get a direct notification wait port.
nx_result_t nx_freertos_notify_init(nx_freertos_notify_t *notification)
Initialize unused notification storage.
nx_result_t nx_freertos_queue_destroy(nx_freertos_queue_t *queue)
Destroy after admission is stopped and all users joined.
nx_result_t nx_freertos_queue_receive_until(nx_freertos_queue_t *queue, void *item, nx_time_us_t deadline)
Receive using one absolute monotonic deadline.
nx_wait_port_t nx_freertos_notify_port(nx_freertos_notify_t *notification)
Bind a latched single-waiter notification.
nx_result_t nx_freertos_direct_notify_init(nx_freertos_direct_notify_t *notification, TaskHandle_t receiver, UBaseType_t index)
Bind an exclusive slot of one live receiver task.
nx_result_t nx_freertos_queue_waiter_destroy(nx_freertos_queue_waiter_t *waiter)
Destroy only after all operations stop and join.
nx_result_t nx_freertos_queue_send_until(nx_freertos_queue_t *queue, const void *item, nx_time_us_t deadline)
Send using one absolute monotonic deadline.
nx_result_t nx_freertos_task_discard_before_scheduler(nx_freertos_task_t *task)
Discard one created task before its wrapper has executed.
nx_result_t nx_freertos_queue_init(nx_freertos_queue_t *queue, uint8_t *storage, size_t storage_bytes, size_t depth, size_t item_size)
Create an exact-sized static byte-copy queue.
nx_result_t nx_freertos_closable_queue_close(nx_freertos_closable_queue_t *queue)
Stop sends and wake every currently registered waiter.
bool nx_freertos_isr_allowed(void)
Test whether the current context may call kernel ISR APIs.
nx_result_t nx_freertos_queue_send(nx_freertos_queue_t *queue, const void *item, TickType_t wait_ticks)
Copy an item with a bounded relative kernel wait.
nx_result_t nx_freertos_closable_queue_destroy(nx_freertos_closable_queue_t *queue)
Destroy a closed, drained and quiesced queue.
nx_result_t nx_freertos_task_start(nx_freertos_task_t *task, const char *name, StackType_t *stack, size_t stack_words, UBaseType_t priority, void(*entry)(void *), void *context)
Create one task from its exact caller-owned stack and TCB.
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
Opt-in close broadcasts; raw queue storage remains unchanged.
Definition freertos.h:90
nx_freertos_queue_waiter_t * send_waiters
Definition freertos.h:92
nx_freertos_queue_t queue
Definition freertos.h:91
nx_freertos_queue_waiter_t * receive_waiters
Definition freertos.h:93
Fixed receiver and exclusive kernel notification slot; no latch.
Definition freertos.h:68
Static binary latch; one waiter, independently quiesced publishers.
Definition freertos.h:36
StaticSemaphore_t storage
Definition freertos.h:37
SemaphoreHandle_t handle
Definition freertos.h:38
Permanent task control without a join completion semaphore.
Definition freertos.h:76
Queue control only; actual depth/item byte storage is external.
Definition freertos.h:61
QueueHandle_t handle
Definition freertos.h:63
StaticQueue_t control
Definition freertos.h:62
Caller-owned single-operation latch for a closable queue.
Definition freertos.h:82
struct nx_freertos_queue_waiter * next
Definition freertos.h:85
SemaphoreHandle_t handle
Definition freertos.h:84
StaticSemaphore_t storage
Definition freertos.h:83
Task has its own TCB; stack is supplied with its actual word count.
Definition freertos.h:51
StaticTask_t control
Definition freertos.h:52
void(* entry)(void *)
Definition freertos.h:56
SemaphoreHandle_t finished
Definition freertos.h:54
StaticSemaphore_t finished_storage
Definition freertos.h:53
TaskHandle_t handle
Definition freertos.h:55
Single-waiter notification port.
Definition wait.h:42
Absolute monotonic microsecond deadlines and wrap extension.
uint64_t nx_time_us_t
Microseconds in one boot/clock domain; no wall-clock semantics.
Definition time.h:20
Optional sequence-latched waiting without hidden workers.