18#ifndef __VSF_KERNEL_SHELL_SIMPLE_H__
19#define __VSF_KERNEL_SHELL_SIMPLE_H__
24#if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
27#if VSF_KERNEL_CFG_EDA_SUPPORT_TASK == ENABLED
62#define static_task_instance(...) \
64 uint_fast8_t fsm_state; \
66 } static VSF_MACRO_SAFE_NAME(local_cb), \
67 *this_ptr = &VSF_MACRO_SAFE_NAME(local_cb); \
68 vsf_evt_t evt = vsf_eda_get_cur_evt(); \
69 VSF_UNUSED_PARAM(evt); \
70 VSF_UNUSED_PARAM(this_ptr);
72#if __IS_COMPILER_IAR__
82# define features_used(...) __VA_ARGS__;
92# define mem_sharable(...) \
93 union {uint_fast8_t __zzzz_do_not_use; __VA_ARGS__;};
103# define mem_nonsharable(...) __VA_ARGS__;
111# define features_used(...) __VA_ARGS__
118# define mem_sharable(...) union {__VA_ARGS__};
125# define mem_nonsharable(...) __VA_ARGS__
143 for ( vsf_evt_t result = VSF_EVT_INVALID; \
144 result == VSF_EVT_INVALID;) \
145 if ((result =__vsf_yield(), result == VSF_EVT_YIELD))
150#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
167# define vsf_delay(__tick) \
168 if (VSF_EVT_TIMER == __vsf_delay((vsf_systimer_tick_t)__tick))
187# define vsf_delay_ms(__ms) \
188 if (VSF_EVT_TIMER == __vsf_delay((vsf_systimer_tick_t)vsf_systimer_ms_to_tick(__ms)))
207# define vsf_delay_us(__us) \
208 if (VSF_EVT_TIMER == __vsf_delay((vsf_systimer_tick_t)vsf_systimer_us_to_tick(__us)))
213#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
232# define on_timeout() \
233 if (VSF_EVT_TIMER == vsf_eda_get_cur_evt())
250# define vsf_mutex_init(__mutex_addr) vsf_eda_mutex_init(__mutex_addr)
263# define vsf_mutex_leave(__mutex_addr) vsf_eda_mutex_leave(__mutex_addr)
282# define vsf_mutex_enter(__mutex_addr) \
283 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
284 reason == VSF_SYNC_CANCEL;) \
285 if ((reason =__vsf_mutex_enter((__mutex_addr), \
286 (-1)), reason == VSF_SYNC_GET))
312# define vsf_mutex_try_enter_timeout(__mutex_addr, __timeout) \
313 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
314 reason == VSF_SYNC_CANCEL;) \
315 if ((reason =__vsf_mutex_enter((__mutex_addr), \
317 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
343# define vsf_mutex_try_enter_timeout_ms(__mutex_addr, __timeout) \
344 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
345 reason == VSF_SYNC_CANCEL;) \
346 if ((reason =__vsf_mutex_enter((__mutex_addr), \
347 vsf_systimer_ms_to_tick(__timeout)), \
348 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
374# define vsf_mutex_try_enter_timeout_us(__mutex_addr, __timeout) \
375 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
376 reason == VSF_SYNC_CANCEL;) \
377 if ((reason =__vsf_mutex_enter((__mutex_addr), \
378 vsf_systimer_us_to_tick(__timeout)), \
379 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
396# define vsf_crit_init(__crit_addr) vsf_eda_crit_init(__crit_addr)
409# define vsf_crit_leave(__crit_addr) vsf_eda_crit_leave(__crit_addr)
428# define vsf_crit_enter(__crit_addr) \
429 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
430 reason == VSF_SYNC_CANCEL;) \
431 if ((reason =__vsf_mutex_enter((__crit_addr), \
432 (-1)), reason == VSF_SYNC_GET))
459# define vsf_crit_try_enter_timeout(__crit_addr, __timeout) \
460 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
461 reason == VSF_SYNC_CANCEL;) \
462 if ((reason =__vsf_mutex_enter((__crit_addr), \
464 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
491# define vsf_crit_try_enter_timeout_ms(__crit_addr, __timeout) \
492 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
493 reason == VSF_SYNC_CANCEL;) \
494 if ((reason =__vsf_mutex_enter((__crit_addr), \
495 vsf_systimer_ms_to_tick(__timeout)), \
496 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
523# define vsf_crit_try_enter_timeout_us(__crit_addr, __timeout) \
524 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
525 reason == VSF_SYNC_CANCEL;) \
526 if ((reason =__vsf_mutex_enter((__crit_addr), \
527 vsf_systimer_us_to_tick(__timeout)), \
528 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
549# define vsf_sem_init(__psem, __cnt) \
550 vsf_eda_sync_init((__psem), (__cnt), VSF_SYNC_MAX | VSF_SYNC_AUTO_RST)
563# define vsf_sem_post(__psem) vsf_eda_sem_post((__psem))
582# define vsf_sem_pend(__psem) \
583 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
584 reason == VSF_SYNC_CANCEL;) \
585 if ((reason =__vsf_sem_pend((__psem), \
586 (-1)), reason == VSF_SYNC_GET))
611# define vsf_sem_pend_timeout(__psem, __timeout) \
612 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
613 reason == VSF_SYNC_CANCEL;) \
614 if ((reason =__vsf_sem_pend((__psem), \
616 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
643# define vsf_sem_pend_timeout_ms(__psem, __timeout) \
644 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
645 reason == VSF_SYNC_CANCEL;) \
646 if ((reason =__vsf_sem_pend((__psem), \
647 vsf_systimer_ms_to_tick(__timeout)), \
648 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
674# define vsf_sem_pend_timeout_us(__psem, __timeout) \
675 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
676 reason == VSF_SYNC_CANCEL;) \
677 if ((reason =__vsf_sem_pend((__psem), \
678 vsf_systimer_us_to_tick(__timeout)), \
679 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
702# define vsf_trig_init(__ptrig, __set, __auto_rst) \
703 vsf_eda_trig_init(__ptrig, __set, __auto_rst)
718# define vsf_trig_set(__ptrig) vsf_eda_trig_set((__ptrig))
731# define vsf_trig_reset(__ptrig) vsf_eda_trig_reset((__ptrig))
750# define vsf_trig_wait(__ptrig) \
751 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
752 reason == VSF_SYNC_CANCEL;) \
753 if ((reason =__vsf_sem_pend((__ptrig), \
754 (-1)), reason == VSF_SYNC_GET))
781# define vsf_trig_wait_timeout(__ptrig, __timeout) \
782 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
783 reason == VSF_SYNC_CANCEL;) \
784 if ((reason =__vsf_sem_pend((__ptrig), \
786 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
814# define vsf_trig_wait_timeout_ms(__ptrig, __timeout) \
815 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
816 reason == VSF_SYNC_CANCEL;) \
817 if ((reason =__vsf_sem_pend((__ptrig), \
818 vsf_systimer_ms_to_tick(__timeout)), \
819 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
846# define vsf_trig_wait_timeout_us(__ptrig, __timeout) \
847 for ( vsf_sync_reason_t reason = VSF_SYNC_CANCEL; \
848 reason == VSF_SYNC_CANCEL;) \
849 if ((reason =__vsf_sem_pend((__ptrig), \
850 vsf_systimer_us_to_tick(__timeout)), \
851 (reason == VSF_SYNC_GET || reason == VSF_SYNC_TIMEOUT)))
855#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
879# define vsf_call_eda(__entry, __param_addr) \
880 __vsf_call_eda( (uintptr_t)(__entry), \
913# define vsf_call_fsm(__entry, __param_addr, ...) \
914 __vsf_call_task( (vsf_task_entry_t)(__entry), \
915 (uintptr_t)(__param_addr), \
951# define vsf_call_peda4( __peda_name, \
953 __private_local_size, \
956 __vsf_call_eda((uintptr_t)__entry, \
957 (uintptr_t)(__peda_param_addr), \
958 ((sizeof(vsf_peda_local(__peda_name)) + 7) & ~0x07) + (__private_local_size),\
959 sizeof(vsf_peda_arg(__peda_name)), \
970# define vsf_call_peda3( __peda_name, \
972 __private_local_size, \
974 __vsf_call_eda((uintptr_t)__entry, \
975 (uintptr_t)(__peda_param_addr), \
976 ((sizeof(vsf_peda_local(__peda_name)) + 7) & ~0x07) + (__private_local_size),\
977 sizeof(vsf_peda_arg(__peda_name)), \
988# define vsf_call_peda2( __peda_name, \
991 __vsf_call_eda((uintptr_t)vsf_peda_func(__peda_name), \
992 (uintptr_t)(__peda_param_addr), \
993 sizeof(vsf_peda_local(__peda_name)), \
994 sizeof(vsf_peda_arg(__peda_name)), \
1005# define vsf_call_peda1( __peda_name, \
1006 __peda_param_addr) \
1007 __vsf_call_eda((uintptr_t)vsf_peda_func(__peda_name), \
1008 (uintptr_t)(__peda_param_addr), \
1009 sizeof(vsf_peda_local(__peda_name)), \
1010 sizeof(vsf_peda_arg(__peda_name)), \
1013# define vsf_call_peda(__peda_name, ...) \
1014 __PLOOC_EVAL(vsf_call_peda, __VA_ARGS__) (__peda_name, __VA_ARGS__)
1023#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1044#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1121#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1150 size_t local_buff_size,
1153# if VSF_KERNEL_CFG_EDA_SUPPORT_TASK == ENABLED && VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
#define VSF_CAL_SECTION(__SEC_STR)
Definition __compiler.h:189
vsf_err_t
Definition __type.h:42
Sync object with an owner (mutex base); supports priority inheritance; the owner must leave it itself...
Definition vsf_eda.h:2009
Base sync IPC object; sem/mutex/trig/crit are built on it.
Definition vsf_eda.h:1964
uint64_t vsf_systimer_tick_t
Definition cortex_a_generic.h:70
uint32_t uintptr_t
Definition stdint.h:38
int16_t vsf_evt_t
Kernel event type.
Definition vsf_eda.h:1658
VSF_KERNEL_TIMEOUT_TICK_T vsf_timeout_tick_t
Timeout type in system timer ticks: negative means wait forever, 0 means non-blocking try,...
Definition vsf_eda.h:1491
vsf_sync_reason_t
Result of a sync wait, returned by the *_get_reason() APIs and thread IPC.
Definition vsf_eda.h:2262
fsm_rt_t
Definition vsf_fsm.h:771
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
#define vsf_mutex_enter(__mutex_addr)
Enter (lock) a mutex, waiting forever until it is obtained (cooperative, non-blocking for other tasks...
Definition vsf_simple.h:282
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
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
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
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
vsf_evt_t __vsf_yield(void)
Low-level yield helper backing the vsf_yield() statement macro.
Definition vsf_simple_task.c:159
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