VSF Documented
vsf_simple.h File Reference

Go to the source code of this file.

Macros

#define static_task_instance(...)
 Declare the per-invocation static task-local control block and fetch the current event.
 
#define features_used(...)
 Non-IAR variant; shares the documentation of the first variant above.
 
#define mem_sharable(...)
 Non-IAR variant; shares the documentation of the first variant above.
 
#define mem_nonsharable(...)
 Non-IAR variant; shares the documentation of the first variant above.
 
#define vsf_yield()
 Yield the CPU cooperatively so that other tasks of the same event queue can run before this task continues.
 
#define vsf_delay(__tick)
 Delay for a given number of system timer ticks (cooperative, non-blocking for other tasks).
 
#define vsf_delay_ms(__ms)
 Delay for a given number of milliseconds (cooperative, non-blocking for other tasks).
 
#define vsf_delay_us(__us)
 Delay for a given number of microseconds (cooperative, non-blocking for other tasks).
 
#define on_timeout()
 Catch the timeout case of a preceding *_timeout wait macro.
 
#define vsf_mutex_init(__mutex_addr)
 Initialize a mutex.
 
#define vsf_mutex_leave(__mutex_addr)
 Leave (release) a mutex previously entered by the current task.
 
#define vsf_mutex_enter(__mutex_addr)
 Enter (lock) a mutex, waiting forever until it is obtained (cooperative, non-blocking for other tasks).
 
#define vsf_mutex_try_enter_timeout(__mutex_addr, __timeout)
 Try to enter (lock) a mutex with a timeout in system timer ticks (cooperative, non-blocking for other tasks).
 
#define vsf_mutex_try_enter_timeout_ms(__mutex_addr, __timeout)
 Try to enter (lock) a mutex with a timeout in milliseconds (cooperative, non-blocking for other tasks).
 
#define vsf_mutex_try_enter_timeout_us(__mutex_addr, __timeout)
 Try to enter (lock) a mutex with a timeout in microseconds (cooperative, non-blocking for other tasks).
 
#define vsf_crit_init(__crit_addr)
 Initialize a critical section object.
 
#define vsf_crit_leave(__crit_addr)
 Leave a critical section previously entered by the current task.
 
#define vsf_crit_enter(__crit_addr)
 Enter a critical section, waiting forever until it is obtained (cooperative, non-blocking for other tasks).
 
#define vsf_crit_try_enter_timeout(__crit_addr, __timeout)
 Try to enter a critical section with a timeout in system timer ticks (cooperative, non-blocking for other tasks).
 
#define vsf_crit_try_enter_timeout_ms(__crit_addr, __timeout)
 Try to enter a critical section with a timeout in milliseconds (cooperative, non-blocking for other tasks).
 
#define vsf_crit_try_enter_timeout_us(__crit_addr, __timeout)
 Try to enter a critical section with a timeout in microseconds (cooperative, non-blocking for other tasks).
 
#define vsf_sem_init(__psem, __cnt)
 Initialize a semaphore with an initial count; the count is auto-reset and limited by VSF_SYNC_MAX.
 
#define vsf_sem_post(__psem)
 Post (increase) a semaphore, waking up one pending task if any.
 
#define vsf_sem_pend(__psem)
 Wait for (pend on) a semaphore, waiting forever until it is obtained (cooperative, non-blocking for other tasks).
 
#define vsf_sem_pend_timeout(__psem, __timeout)
 Wait for (pend on) a semaphore with a timeout in system timer ticks (cooperative, non-blocking for other tasks).
 
#define vsf_sem_pend_timeout_ms(__psem, __timeout)
 Wait for (pend on) a semaphore with a timeout in milliseconds (cooperative, non-blocking for other tasks).
 
#define vsf_sem_pend_timeout_us(__psem, __timeout)
 Wait for (pend on) a semaphore with a timeout in microseconds (cooperative, non-blocking for other tasks).
 
#define vsf_trig_init(__ptrig, __set, __auto_rst)
 Initialize a trigger.
 
#define vsf_trig_set(__ptrig)
 Set a trigger, waking up the tasks waiting for it (all waiters for a manual-reset trigger, one waiter otherwise).
 
#define vsf_trig_reset(__ptrig)
 Reset a trigger.
 
#define vsf_trig_wait(__ptrig)
 Wait for a trigger to be set, waiting forever (cooperative, non-blocking for other tasks).
 
#define vsf_trig_wait_timeout(__ptrig, __timeout)
 Wait for a trigger to be set with a timeout in system timer ticks (cooperative, non-blocking for other tasks).
 
#define vsf_trig_wait_timeout_ms(__ptrig, __timeout)
 Wait for a trigger to be set with a timeout in milliseconds (cooperative, non-blocking for other tasks).
 
#define vsf_trig_wait_timeout_us(__ptrig, __timeout)
 Wait for a trigger to be set with a timeout in microseconds (cooperative, non-blocking for other tasks).
 
#define vsf_call_eda(__entry, __param_addr)
 Call a sub eda task (event handler) from the current task.
 
#define vsf_call_fsm(__entry, __param_addr, ...)
 Call a sub fsm task from the current task, and wait until it finishes. Internally mapped to __vsf_call_task(); an fsm is a vsf task in this codebase.
 
#define vsf_call_peda4(__peda_name, __entry, __private_local_size, __peda_param_addr, __buff)
 Call a sub peda task (eda task with private local variables and argument buffer) from the current task.
 
#define vsf_call_peda3(__peda_name, __entry, __private_local_size, __peda_param_addr)
 Helper of vsf_call_peda() with explicit entry and private local size, without the argument buffer; shares the documentation of vsf_call_peda4.
 
#define vsf_call_peda2(__peda_name, __peda_param_addr, __buff)
 Helper of vsf_call_peda() with an explicit argument buffer, using the peda's own entry; shares the documentation of vsf_call_peda4.
 
#define vsf_call_peda1(__peda_name, __peda_param_addr)
 Helper of vsf_call_peda() using the peda's own entry without the argument buffer; shares the documentation of vsf_call_peda4.
 
#define vsf_call_peda(__peda_name, ...)
 

Functions

vsf_evt_t __vsf_delay (vsf_systimer_tick_t tick)
 Low-level delay helper backing the vsf_delay() statement macros.
 
vsf_sync_reason_t __vsf_sem_pend (vsf_sem_t *sem_ptr, vsf_timeout_tick_t time_out)
 Low-level semaphore-pend helper backing the vsf_sem_pend() and vsf_trig_wait() statement macros.
 
vsf_sync_reason_t __vsf_mutex_enter (vsf_mutex_t *mtx_ptr, vsf_timeout_tick_t time_out)
 Low-level mutex-enter helper backing the vsf_mutex_enter() and vsf_crit_enter() statement macros.
 
vsf_evt_t __vsf_yield (void)
 Low-level yield helper backing the vsf_yield() statement macro.
 
vsf_err_t __vsf_call_eda (uintptr_t evthandler, uintptr_t param, size_t local_size, size_t local_buff_size, uintptr_t local_buff)
 Low-level sub-task-call helper backing the vsf_call_eda() and vsf_call_peda() macros.
 
fsm_rt_t __vsf_call_task (vsf_task_entry_t entry, uintptr_t param, size_t local_size)
 Low-level helper for calling a sub task with a return value.
 

Macro Definition Documentation

◆ static_task_instance

#define static_task_instance ( ...)
Value:
struct { \
uint_fast8_t fsm_state; \
__VA_ARGS__ \
} static VSF_MACRO_SAFE_NAME(local_cb), \
*this_ptr = &VSF_MACRO_SAFE_NAME(local_cb); \
VSF_UNUSED_PARAM(evt); \
VSF_UNUSED_PARAM(this_ptr);
unsigned char uint_fast8_t
Definition stdint.h:23
vsf_evt_t vsf_eda_get_cur_evt(void)
Get the event currently being processed by the current task.
Definition vsf_eda.c:458
int16_t vsf_evt_t
Kernel event type.
Definition vsf_eda.h:1658
#define VSF_MACRO_SAFE_NAME(__NAME)
Definition vsf_preprocessor.h:32

Declare the per-invocation static task-local control block and fetch the current event.

Parameters
[in]...user local variable declarations appended to the control block
Note
Expands to an anonymous struct with a static instance and a pointer this_ptr to it; the first member fsm_state is reserved for the simple-shell state machine. Also defines a local variable evt holding the current event (vsf_eda_get_cur_evt()).
Must be placed at the beginning of a simple-shell event handler.

◆ features_used

#define features_used ( ...)
Value:
__VA_ARGS__

Non-IAR variant; shares the documentation of the first variant above.

◆ mem_sharable

#define mem_sharable ( ...)
Value:
union {__VA_ARGS__};

Non-IAR variant; shares the documentation of the first variant above.

◆ mem_nonsharable

#define mem_nonsharable ( ...)
Value:
__VA_ARGS__

Non-IAR variant; shares the documentation of the first variant above.

◆ vsf_yield

#define vsf_yield ( )
Value:
for ( vsf_evt_t result = VSF_EVT_INVALID; \
result == VSF_EVT_INVALID;) \
if ((result =__vsf_yield(), result == VSF_EVT_YIELD))
@ VSF_EVT_YIELD
Cooperative yield event; compatible with fsm_rt_on_going.
Definition vsf_eda.h:1517
@ VSF_EVT_INVALID
Invalid event; waiting for it means waiting for any event; also compatible with fsm_rt_err.
Definition vsf_eda.h:1507
vsf_evt_t __vsf_yield(void)
Low-level yield helper backing the vsf_yield() statement macro.
Definition vsf_simple_task.c:159

Yield the CPU cooperatively so that other tasks of the same event queue can run before this task continues.

Note
Statement macro: the following brace block runs after the task is resumed. Usage: vsf_yield() { ... }. Must be used inside a simple-shell event handler.

◆ vsf_delay

#define vsf_delay ( __tick)
Value:
uint64_t vsf_systimer_tick_t
Definition cortex_a_generic.h:70
@ VSF_EVT_TIMER
teda timer expired (only for teda tasks)
Definition vsf_eda.h:1569
vsf_evt_t __vsf_delay(vsf_systimer_tick_t tick)
Low-level delay helper backing the vsf_delay() statement macros.
Definition vsf_simple_task.c:50

Delay for a given number of system timer ticks (cooperative, non-blocking for other tasks).

Parameters
[in]__tickdelay time in system timer ticks
Note
Statement macro: the following brace block runs after the delay expires. Usage: vsf_delay(tick) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_delay_ms

#define vsf_delay_ms ( __ms)
Value:
vsf_systimer_tick_t vsf_systimer_ms_to_tick(uint_fast32_t time_ms)
Definition linux_generic.c:440

Delay for a given number of milliseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__msdelay time in milliseconds, converted to ticks via vsf_systimer_ms_to_tick()
Note
Statement macro: the following brace block runs after the delay expires. Usage: vsf_delay_ms(ms) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_delay_us

#define vsf_delay_us ( __us)
Value:
vsf_systimer_tick_t vsf_systimer_us_to_tick(uint_fast32_t time_us)
Definition linux_generic.c:435

Delay for a given number of microseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__usdelay time in microseconds, converted to ticks via vsf_systimer_us_to_tick()
Note
Statement macro: the following brace block runs after the delay expires. Usage: vsf_delay_us(us) { ... }. Must be used inside a simple-shell event handler.

◆ on_timeout

#define on_timeout ( )
Value:

Catch the timeout case of a preceding *_timeout wait macro.

Note
Statement macro: the following brace block runs when the preceding wait timed out, i.e. the current event is VSF_EVT_TIMER. Usage: on_timeout() { ... }. Must be used inside a simple-shell event handler, right after a *_timeout() statement macro.

◆ vsf_mutex_init

#define vsf_mutex_init ( __mutex_addr)
Value:
vsf_eda_mutex_init(__mutex_addr)
#define vsf_eda_mutex_init(__pmtx)
Initialize a mutex.
Definition vsf_eda.h:209

Initialize a mutex.

Parameters
[in]__mutex_addrpointer to the mutex vsf_mutex_t
Returns
vsf_err_t: always VSF_ERR_NONE (invalid parameters trigger an assertion)
Note
Must be called in task (or initialization) context, NOT in interrupt context.

◆ vsf_mutex_leave

#define vsf_mutex_leave ( __mutex_addr)
Value:
vsf_eda_mutex_leave(__mutex_addr)
#define vsf_eda_mutex_leave(__pmtx)
Leave (unlock) a mutex, waking up one pending task if any.
Definition vsf_eda.h:264

Leave (release) a mutex previously entered by the current task.

Parameters
[in]__mutex_addrpointer to the mutex vsf_mutex_t
Returns
vsf_err_t: VSF_ERR_NONE if successful; VSF_ERR_OVERRUN if the mutex is not owned
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_mutex_enter

#define vsf_mutex_enter ( __mutex_addr)
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__mutex_addr), \
(-1)), reason == VSF_SYNC_GET))
vsf_sync_reason_t
Result of a sync wait, returned by the *_get_reason() APIs and thread IPC.
Definition vsf_eda.h:2262
@ VSF_SYNC_GET
Obtained.
Definition vsf_eda.h:2282
@ VSF_SYNC_CANCEL
Cancelled.
Definition vsf_eda.h:2287
vsf_sync_reason_t __vsf_mutex_enter(vsf_mutex_t *mtx_ptr, vsf_timeout_tick_t time_out)
Low-level mutex-enter helper backing the vsf_mutex_enter() and vsf_crit_enter() statement macros.
Definition vsf_simple_task.c:150

Enter (lock) a mutex, waiting forever until it is obtained (cooperative, non-blocking for other tasks).

Parameters
[in]__mutex_addrpointer to the mutex vsf_mutex_t
Note
Statement macro: the following brace block runs after the mutex is obtained. Usage: vsf_mutex_enter(pmtx) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_mutex_try_enter_timeout

#define vsf_mutex_try_enter_timeout ( __mutex_addr,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__mutex_addr), \
(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
@ VSF_SYNC_TIMEOUT
Timed out.
Definition vsf_eda.h:2272

Try to enter (lock) a mutex with a timeout in system timer ticks (cooperative, non-blocking for other tasks).

Parameters
[in]__mutex_addrpointer to the mutex vsf_mutex_t
[in]__timeouttimeout in system timer ticks; a negative value waits forever
Note
Statement macro: the following brace block runs when the mutex is obtained (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_mutex_try_enter_timeout(pmtx, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_mutex_try_enter_timeout_ms

#define vsf_mutex_try_enter_timeout_ms ( __mutex_addr,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__mutex_addr), \
vsf_systimer_ms_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Try to enter (lock) a mutex with a timeout in milliseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__mutex_addrpointer to the mutex vsf_mutex_t
[in]__timeouttimeout in milliseconds, converted to ticks via vsf_systimer_ms_to_tick()
Note
Statement macro: the following brace block runs when the mutex is obtained (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_mutex_try_enter_timeout_ms(pmtx, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_mutex_try_enter_timeout_us

#define vsf_mutex_try_enter_timeout_us ( __mutex_addr,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__mutex_addr), \
vsf_systimer_us_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Try to enter (lock) a mutex with a timeout in microseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__mutex_addrpointer to the mutex vsf_mutex_t
[in]__timeouttimeout in microseconds, converted to ticks via vsf_systimer_us_to_tick()
Note
Statement macro: the following brace block runs when the mutex is obtained (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_mutex_try_enter_timeout_us(pmtx, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_crit_init

#define vsf_crit_init ( __crit_addr)
Value:
vsf_eda_crit_init(__crit_addr)
#define vsf_eda_crit_init(__pcrit)
Initialize a critical section.
Definition vsf_eda.h:307

Initialize a critical section object.

Parameters
[in]__crit_addrpointer to the critical section object vsf_crit_t
Returns
vsf_err_t: always VSF_ERR_NONE (invalid parameters trigger an assertion)
Note
Must be called in task (or initialization) context, NOT in interrupt context.

◆ vsf_crit_leave

#define vsf_crit_leave ( __crit_addr)
Value:
vsf_eda_crit_leave(__crit_addr)
#define vsf_eda_crit_leave(__pcrit)
Leave a critical section, same semantics as vsf_eda_mutex_leave()
Definition vsf_eda.h:356

Leave a critical section previously entered by the current task.

Parameters
[in]__crit_addrpointer to the critical section object vsf_crit_t
Returns
vsf_err_t: VSF_ERR_NONE if successful; VSF_ERR_OVERRUN if the critical section is not owned
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_crit_enter

#define vsf_crit_enter ( __crit_addr)
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__crit_addr), \
(-1)), reason == VSF_SYNC_GET))

Enter a critical section, waiting forever until it is obtained (cooperative, non-blocking for other tasks).

Parameters
[in]__crit_addrpointer to the critical section object vsf_crit_t
Note
Statement macro: the following brace block runs after the critical section is entered. Usage: vsf_crit_enter(pcrit) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_crit_try_enter_timeout

#define vsf_crit_try_enter_timeout ( __crit_addr,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__crit_addr), \
(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Try to enter a critical section with a timeout in system timer ticks (cooperative, non-blocking for other tasks).

Parameters
[in]__crit_addrpointer to the critical section object vsf_crit_t
[in]__timeouttimeout in system timer ticks; a negative value waits forever
Note
Statement macro: the following brace block runs when the critical section is entered (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_crit_try_enter_timeout(pcrit, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_crit_try_enter_timeout_ms

#define vsf_crit_try_enter_timeout_ms ( __crit_addr,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__crit_addr), \
vsf_systimer_ms_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Try to enter a critical section with a timeout in milliseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__crit_addrpointer to the critical section object vsf_crit_t
[in]__timeouttimeout in milliseconds, converted to ticks via vsf_systimer_ms_to_tick()
Note
Statement macro: the following brace block runs when the critical section is entered (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_crit_try_enter_timeout_ms(pcrit, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_crit_try_enter_timeout_us

#define vsf_crit_try_enter_timeout_us ( __crit_addr,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_mutex_enter((__crit_addr), \
vsf_systimer_us_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Try to enter a critical section with a timeout in microseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__crit_addrpointer to the critical section object vsf_crit_t
[in]__timeouttimeout in microseconds, converted to ticks via vsf_systimer_us_to_tick()
Note
Statement macro: the following brace block runs when the critical section is entered (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_crit_try_enter_timeout_us(pcrit, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_sem_init

#define vsf_sem_init ( __psem,
__cnt )
Value:
vsf_err_t vsf_eda_sync_init(vsf_sync_t *pthis, uint_fast16_t cur_value, uint_fast16_t max_value)
Initialize a sync object, the base of semaphore, mutex, trigger etc.
#define VSF_SYNC_MAX
Maximum count value of a sync object vsf_sync_t.
Definition vsf_eda.h:85
#define VSF_SYNC_AUTO_RST
Auto-reset flag, OR-ed into max_value of vsf_eda_sync_init(): the count is decreased automatically ea...
Definition vsf_eda.h:59

Initialize a semaphore with an initial count; the count is auto-reset and limited by VSF_SYNC_MAX.

Parameters
[in]__psempointer to the semaphore vsf_sem_t
[in]__cntinitial count of the semaphore
Returns
vsf_err_t: always VSF_ERR_NONE (invalid parameters trigger an assertion)
Note
Must be called in task (or initialization) context, NOT in interrupt context.

◆ vsf_sem_post

#define vsf_sem_post ( __psem)
Value:
#define vsf_eda_sem_post(__psem)
Post (increase) a semaphore, waking up one pending task if any.
Definition vsf_eda.h:132

Post (increase) a semaphore, waking up one pending task if any.

Parameters
[in]__psempointer to the semaphore vsf_sem_t
Returns
vsf_err_t: VSF_ERR_NONE if successful; VSF_ERR_OVERRUN if the count has reached the maximum
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_sem_pend

#define vsf_sem_pend ( __psem)
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__psem), \
(-1)), reason == VSF_SYNC_GET))
vsf_sync_reason_t __vsf_sem_pend(vsf_sem_t *sem_ptr, vsf_timeout_tick_t time_out)
Low-level semaphore-pend helper backing the vsf_sem_pend() and vsf_trig_wait() statement macros.
Definition vsf_simple_task.c:103

Wait for (pend on) a semaphore, waiting forever until it is obtained (cooperative, non-blocking for other tasks).

Parameters
[in]__psempointer to the semaphore vsf_sem_t
Note
Statement macro: the following brace block runs after the semaphore is obtained. Usage: vsf_sem_pend(psem) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_sem_pend_timeout

#define vsf_sem_pend_timeout ( __psem,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__psem), \
(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Wait for (pend on) a semaphore with a timeout in system timer ticks (cooperative, non-blocking for other tasks).

Parameters
[in]__psempointer to the semaphore vsf_sem_t
[in]__timeouttimeout in system timer ticks; a negative value waits forever
Note
Statement macro: the following brace block runs when the semaphore is obtained (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_sem_pend_timeout(psem, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_sem_pend_timeout_ms

#define vsf_sem_pend_timeout_ms ( __psem,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__psem), \
vsf_systimer_ms_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Wait for (pend on) a semaphore with a timeout in milliseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__psempointer to the semaphore vsf_sem_t
[in]__timeouttimeout in milliseconds, converted to ticks via vsf_systimer_ms_to_tick()
Note
Statement macro: the following brace block runs when the semaphore is obtained (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_sem_pend_timeout_ms(psem, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_sem_pend_timeout_us

#define vsf_sem_pend_timeout_us ( __psem,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__psem), \
vsf_systimer_us_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Wait for (pend on) a semaphore with a timeout in microseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__psempointer to the semaphore vsf_sem_t
[in]__timeouttimeout in microseconds, converted to ticks via vsf_systimer_us_to_tick()
Note
Statement macro: the following brace block runs when the semaphore is obtained (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_sem_pend_timeout_us(psem, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_trig_init

#define vsf_trig_init ( __ptrig,
__set,
__auto_rst )
Value:
vsf_eda_trig_init(__ptrig, __set, __auto_rst)
#define vsf_eda_trig_init(__pevt, __set, __auto_rst)
Initialize a trigger (a sync object with maximum count 1)
Definition vsf_eda.h:376

Initialize a trigger.

Parameters
[in]__ptrigpointer to the trigger vsf_trig_t
[in]__setinitial state, non-zero for set, zero for reset
[in]__auto_rstnon-zero to reset the trigger automatically after it is obtained, zero to reset it manually with vsf_trig_reset()
Returns
vsf_err_t: always VSF_ERR_NONE (invalid parameters trigger an assertion)
Note
Must be called in task (or initialization) context, NOT in interrupt context.

◆ vsf_trig_set

#define vsf_trig_set ( __ptrig)
Value:
vsf_eda_trig_set((__ptrig))
#define vsf_eda_trig_set(__pevt,...)
Set (trigger) a trigger, waking up the pending tasks.
Definition vsf_eda.h:403

Set a trigger, waking up the tasks waiting for it (all waiters for a manual-reset trigger, one waiter otherwise).

Parameters
[in]__ptrigpointer to the trigger vsf_trig_t
Returns
vsf_err_t: VSF_ERR_NONE if successful; VSF_ERR_OVERRUN if the trigger is already set
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_trig_reset

#define vsf_trig_reset ( __ptrig)
Value:
#define vsf_eda_trig_reset(__pevt)
Reset a trigger to the untriggered state.
Definition vsf_eda.h:418

Reset a trigger.

Parameters
[in]__ptrigpointer to the trigger vsf_trig_t
Returns
none
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_trig_wait

#define vsf_trig_wait ( __ptrig)
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__ptrig), \
(-1)), reason == VSF_SYNC_GET))

Wait for a trigger to be set, waiting forever (cooperative, non-blocking for other tasks).

Parameters
[in]__ptrigpointer to the trigger vsf_trig_t
Note
Statement macro: the following brace block runs after the trigger is set. Usage: vsf_trig_wait(ptrig) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_trig_wait_timeout

#define vsf_trig_wait_timeout ( __ptrig,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__ptrig), \
(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Wait for a trigger to be set with a timeout in system timer ticks (cooperative, non-blocking for other tasks).

Parameters
[in]__ptrigpointer to the trigger vsf_trig_t
[in]__timeouttimeout in system timer ticks; a negative value waits forever
Note
Statement macro: the following brace block runs when the trigger is set (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_trig_wait_timeout(ptrig, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_trig_wait_timeout_ms

#define vsf_trig_wait_timeout_ms ( __ptrig,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__ptrig), \
vsf_systimer_ms_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Wait for a trigger to be set with a timeout in milliseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__ptrigpointer to the trigger vsf_trig_t
[in]__timeouttimeout in milliseconds, converted to ticks via vsf_systimer_ms_to_tick()
Note
Statement macro: the following brace block runs when the trigger is set (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_trig_wait_timeout_ms(ptrig, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_trig_wait_timeout_us

#define vsf_trig_wait_timeout_us ( __ptrig,
__timeout )
Value:
reason == VSF_SYNC_CANCEL;) \
if ((reason =__vsf_sem_pend((__ptrig), \
vsf_systimer_us_to_tick(__timeout)), \
(reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))

Wait for a trigger to be set with a timeout in microseconds (cooperative, non-blocking for other tasks).

Parameters
[in]__ptrigpointer to the trigger vsf_trig_t
[in]__timeouttimeout in microseconds, converted to ticks via vsf_systimer_us_to_tick()
Note
Statement macro: the following brace block runs when the trigger is set (VSF_SYNC_GET) or the wait times out (VSF_SYNC_TIMEOUT); use on_timeout() to catch the timeout case. Usage: vsf_trig_wait_timeout_us(ptrig, timeout) { ... }. Must be used inside a simple-shell event handler.

◆ vsf_call_eda

#define vsf_call_eda ( __entry,
__param_addr )
Value:
__vsf_call_eda( (uintptr_t)(__entry), \
(__param_addr), \
0, 0, 0)
uint32_t uintptr_t
Definition stdint.h:38
vsf_err_t __vsf_call_eda(uintptr_t evthandler, uintptr_t param, size_t local_size, size_t local_buff_size, uintptr_t local_buff)
Low-level sub-task-call helper backing the vsf_call_eda() and vsf_call_peda() macros.
Definition vsf_simple_task.c:193

Call a sub eda task (event handler) from the current task.

Parameters
[in]__entryentry function of the sub task
[in]__param_addrparameter passed to the sub task
Returns
vsf_err_t: VSF_ERR_NONE if the call is started successfully; VSF_ERR_NOT_ENOUGH_RESOURCES if no frame is available
Note
Must be used inside a simple-shell event handler. After the sub task returns, the caller resumes with the VSF_EVT_RETURN event.

◆ vsf_call_fsm

#define vsf_call_fsm ( __entry,
__param_addr,
... )
Value:
(uintptr_t)(__param_addr), \
(0, ##__VA_ARGS__))
fsm_rt_t __vsf_call_task(vsf_task_entry_t entry, uintptr_t param, size_t local_size)
Low-level helper for calling a sub task with a return value.
Definition vsf_simple_task.c:241
fsm_rt_t(* vsf_task_entry_t)(uintptr_t target, vsf_evt_t evt)
Task entry function (the event handler of the task), returning fsm_rt_t when VSF_KERNEL_CFG_EDA_SUBCA...
Definition vsf_task.h:632

Call a sub fsm task from the current task, and wait until it finishes. Internally mapped to __vsf_call_task(); an fsm is a vsf task in this codebase.

Parameters
[in]__entryentry function of the sub task
[in]__param_addrparameter passed to the sub task
[in]...optional size of the local variables of the sub-task frame
Returns
fsm_rt_t: the return value of the sub fsm task when it finishes, or fsm_rt_yield while the sub task is scheduled to run
Note
Must be used inside a simple-shell event handler. Only available when VSF_KERNEL_CFG_EDA_SUPPORT_TASK and VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE are ENABLED (the same requirements as the simple-fsm module).

◆ vsf_call_peda4

#define vsf_call_peda4 ( __peda_name,
__entry,
__private_local_size,
__peda_param_addr,
__buff )
Value:
(uintptr_t)(__peda_param_addr), \
((sizeof(vsf_peda_local(__peda_name)) + 7) & ~0x07) + (__private_local_size),\
sizeof(vsf_peda_arg(__peda_name)), \
(uintptr_t)(__buff))
#define vsf_peda_arg(__name)
Generate the argument type name of a peda task.
Definition vsf_eda.h:749
#define vsf_peda_local(__name)
Generate the local type name of a peda task.
Definition vsf_eda.h:738

Call a sub peda task (eda task with private local variables and argument buffer) from the current task.

Parameters
[in]__peda_namename of the peda task declared with the peda macros
[in]__entry(vsf_call_peda4/3 only) entry function of the sub task
[in]__private_local_size(vsf_call_peda4/3 only) extra private local size appended to the peda local variables
[in]__peda_param_addrparameter passed to the sub task
[in]__buff(vsf_call_peda4/2 only) buffer used to initialize the argument area of the sub task
Returns
vsf_err_t: VSF_ERR_NONE if the call is started successfully; VSF_ERR_NOT_ENOUGH_RESOURCES if no frame is available
Note
vsf_call_peda() dispatches to vsf_call_peda1/2/3/4 according to the argument count; the four helpers share this documentation.
Must be used inside a simple-shell event handler. After the sub task returns, the caller resumes with the VSF_EVT_RETURN event.

◆ vsf_call_peda3

#define vsf_call_peda3 ( __peda_name,
__entry,
__private_local_size,
__peda_param_addr )
Value:
(uintptr_t)(__peda_param_addr), \
((sizeof(vsf_peda_local(__peda_name)) + 7) & ~0x07) + (__private_local_size),\
sizeof(vsf_peda_arg(__peda_name)), \
0)

Helper of vsf_call_peda() with explicit entry and private local size, without the argument buffer; shares the documentation of vsf_call_peda4.

◆ vsf_call_peda2

#define vsf_call_peda2 ( __peda_name,
__peda_param_addr,
__buff )
Value:
(uintptr_t)(__peda_param_addr), \
sizeof(vsf_peda_local(__peda_name)), \
sizeof(vsf_peda_arg(__peda_name)), \
(uintptr_t)(__buff))
#define vsf_peda_func(__name)
Generate the event handler function name of a peda task.
Definition vsf_eda.h:760

Helper of vsf_call_peda() with an explicit argument buffer, using the peda's own entry; shares the documentation of vsf_call_peda4.

◆ vsf_call_peda1

#define vsf_call_peda1 ( __peda_name,
__peda_param_addr )
Value:
(uintptr_t)(__peda_param_addr), \
sizeof(vsf_peda_local(__peda_name)), \
sizeof(vsf_peda_arg(__peda_name)), \
0)

Helper of vsf_call_peda() using the peda's own entry without the argument buffer; shares the documentation of vsf_call_peda4.

◆ vsf_call_peda

#define vsf_call_peda ( __peda_name,
... )
Value:
__PLOOC_EVAL(vsf_call_peda, __VA_ARGS__) (__peda_name, __VA_ARGS__)
#define vsf_call_peda(__peda_name,...)
Definition vsf_simple.h:1013

Function Documentation

◆ __vsf_delay()

vsf_evt_t __vsf_delay ( vsf_systimer_tick_t tick)
extern

Low-level delay helper backing the vsf_delay() statement macros.

Parameters
[in]tickdelay time in system timer ticks
Returns
vsf_evt_t: VSF_EVT_TIMER when the delay expires, otherwise VSF_EVT_INVALID while the delay is still pending
Note
Internal use only.

◆ __vsf_sem_pend()

vsf_sync_reason_t __vsf_sem_pend ( vsf_sem_t * sem_ptr,
vsf_timeout_tick_t time_out )
extern

Low-level semaphore-pend helper backing the vsf_sem_pend() and vsf_trig_wait() statement macros.

Parameters
[in]sem_ptrpointer to the semaphore vsf_sem_t
[in]time_outtimeout in system timer ticks; a negative value waits forever
Returns
vsf_sync_reason_t: VSF_SYNC_GET when the semaphore is obtained, VSF_SYNC_TIMEOUT on timeout, VSF_SYNC_CANCEL when the wait is cancelled, VSF_SYNC_FAIL on error, otherwise VSF_SYNC_PENDING while the wait is still in progress
Note
Internal use only.

◆ __vsf_mutex_enter()

vsf_sync_reason_t __vsf_mutex_enter ( vsf_mutex_t * mtx_ptr,
vsf_timeout_tick_t time_out )
extern

Low-level mutex-enter helper backing the vsf_mutex_enter() and vsf_crit_enter() statement macros.

Parameters
[in]mtx_ptrpointer to the mutex vsf_mutex_t
[in]time_outtimeout in system timer ticks; a negative value waits forever
Returns
vsf_sync_reason_t: VSF_SYNC_GET when the mutex is obtained, VSF_SYNC_TIMEOUT on timeout, VSF_SYNC_CANCEL when the wait is cancelled, VSF_SYNC_FAIL on error, otherwise VSF_SYNC_PENDING while the wait is still in progress
Note
Internal use only.

◆ __vsf_yield()

vsf_evt_t __vsf_yield ( void )
extern

Low-level yield helper backing the vsf_yield() statement macro.

Returns
vsf_evt_t: VSF_EVT_YIELD when the task is resumed after the yield, otherwise VSF_EVT_NONE while the yield is still pending
Note
Internal use only.

◆ __vsf_call_eda()

vsf_err_t __vsf_call_eda ( uintptr_t evthandler,
uintptr_t param,
size_t local_size,
size_t local_buff_size,
uintptr_t local_buff )
extern

Low-level sub-task-call helper backing the vsf_call_eda() and vsf_call_peda() macros.

Parameters
[in]evthandlerentry function of the sub task
[in]paramparameter passed to the sub task
[in]local_sizesize of the local variable area of the sub task
[in]local_buff_sizesize of the buffer pointed by local_buff
[in]local_buffbuffer used to initialize the local variable area of the sub task, NULL if not used
Returns
vsf_err_t: VSF_ERR_NONE if the call is started successfully; VSF_ERR_NOT_ENOUGH_RESOURCES if no frame is available
Note
Internal use only.

◆ __vsf_call_task()

fsm_rt_t __vsf_call_task ( vsf_task_entry_t entry,
uintptr_t param,
size_t local_size )
extern

Low-level helper for calling a sub task with a return value.

Parameters
[in]entryentry function of the sub task vsf_task_entry_t
[in]paramparameter passed to the sub task
[in]local_sizesize of the local variable area of the sub task
Returns
fsm_rt_t: return status of the sub task
Note
Internal use only.
Generated from commit: vsfteam/vsf@a5104db