18#ifndef __VSF_KERNEL_TASK_H__
19#define __VSF_KERNEL_TASK_H__
25#if VSF_USE_KERNEL == ENABLED && VSF_KERNEL_CFG_EDA_SUPPORT_TASK == ENABLED
28#include "../vsf_eda.h"
39#define __vsf_task_func(__name) vsf_task_func_##__name
40#define vsf_task_func(__name) __vsf_task_func(__name)
42#define __vsf_task(__name) task_cb_##__name
43#define vsf_task(__name) __vsf_task(__name)
45#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
46# define __implement_vsf_task(__name) \
47 fsm_rt_t vsf_task_func(__name)( uintptr_t local, \
50 vsf_task(__name) *vsf_pthis = \
51 *(vsf_task(__name) **) \
52 ((uintptr_t)local - sizeof(uintptr_t));
54# define vsf_task_begin()
56# define vsf_task_end() \
57 } return fsm_rt_on_going;
59# define vsf_task_state (vsf_this.fsm_state)
62# define __implement_vsf_task(__name) \
63 void vsf_task_func(__name)(__name *obj_ptr, vsf_evt_t evt) \
65 vsf_task(__name) *vsf_pthis = &(obj_ptr->param);
67# define vsf_task_begin()
68# define vsf_task_end() } __vsf_eda_yield();
70# define vsf_task_state (vsf_this.fsm_state)
73#define implement_vsf_task(__name) __implement_vsf_task(__name)
74#define imp_vsf_task(__name) implement_vsf_task(__name)
76#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
77# define vsf_task_start vsf_teda_start
79# define vsf_task_start vsf_eda_start
82#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
83# define __def_vsf_task(__name,...) \
84 struct task_cb_##__name { \
89 implement(vsf_task_t); \
90 implement_ex(task_cb_##__name, param); \
92 extern fsm_rt_t vsf_task_func_##__name( uintptr_t local, \
96# define __def_vsf_task(__name,...) \
97 typedef struct task_cb_##__name { \
100 } task_cb_##__name; \
101 typedef struct __name { \
102 implement(vsf_task_t); \
103 implement_ex(task_cb_##__name, param); \
105 extern void vsf_task_func_##__name(struct __name *vsf_pthis, vsf_evt_t evt);
108#define def_vsf_task(__name,...) __def_vsf_task(__name,__VA_ARGS__)
109#define define_vsf_task(__name,...) def_vsf_task(__name,__VA_ARGS__)
110#define end_def_vsf_task(...)
111#define end_define_vsf_task(...)
113#define __declare_vsf_task(__name) \
114 typedef struct __name __name; \
115 typedef struct task_cb_##__name task_cb_##__name;
117#define declare_vsf_task(__name) __declare_vsf_task(__name)
118#define dcl_vsf_task(__name) declare_vsf_task(__name)
120#define prepare_vsf_task(__name, __task) \
121 do {(__task)->fsm_state = 0; } while(0)
123#define prp_vsf_task(__name, __task) prepare_vsf_task(__name, __task)
125#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
126# define __init_vsf_task(__name, __task, __pri, ...) \
128 vsf_eda_cfg_t VSF_MACRO_SAFE_NAME(cfg) = { \
129 .fn.func = (uintptr_t)vsf_task_func(__name), \
130 .priority = (__pri), \
131 .target = (uintptr_t)&((__task)->param), \
132 .feature.is_subcall_has_return_value = true, \
135 prepare_vsf_task(__name, &((__task)->param)); \
136 vsf_task_start(&((__task)->use_as__vsf_task_t), \
137 &VSF_MACRO_SAFE_NAME(cfg)); \
140# define __init_vsf_task(__name, __task, __pri, ...) \
142 vsf_eda_cfg_t VSF_MACRO_SAFE_NAME(cfg) = { \
143 .fn.evthandler = (vsf_task_entry_t)vsf_task_func(__name), \
144 .priority = (__pri), \
148 prepare_vsf_task(__name, &((__task)->param)); \
149 vsf_task_start(&((__task)->use_as__vsf_task_t), \
150 &VSF_MACRO_SAFE_NAME(cfg)); \
154#define init_vsf_task(__name, __task, __pri, ...) \
155 __init_vsf_task(__name, (__task), (__pri), __VA_ARGS__)
158#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
159#define vsf_task_call_task(__name, __target, ...) \
160 __vsf_eda_call_task((vsf_task_entry_t)vsf_task_func(__name), \
161 (uintptr_t)(__target), (0, ##__VA_ARGS__))
164#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
165# define vsf_task_call_sub(__name, __target, ...) \
166 if (VSF_ERR_NONE != __vsf_eda_call_eda( \
167 (vsf_task_entry_t)(__name), \
169 (0, ##__VA_ARGS))) { \
170 return fsm_rt_on_going; \
172# define vsf_eda_call_task vsf_task_call_task
174#elif VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
175# define vsf_task_call_sub(__name, __target, ...) \
176 if (VSF_ERR_NONE != __vsf_eda_call_eda( \
177 (vsf_task_entry_t)(__name), \
179 (0, ##__VA_ARGS))) { \
182# define vsf_eda_call_task(__name, __target) \
183 vsf_eda_call_sub((vsf_task_entry_t)vsf_task_func(__name), (__target))
187#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
188#define vsf_task_call_pt(__name, __target) \
189 vsf_task_call_sub(vsf_pt_func(__name), __target)
192#define on_vsf_task_init() \
193 if (VSF_EVT_INIT == evt)
195#define on_vsf_task_fini() \
196 if (VSF_EVT_FINI == evt)
198#define on_vsf_task_evt(__evt) \
219#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
220# define vsf_task_wait_until(...) \
221 __VA_ARGS__ {} else { \
222 return fsm_rt_wait_for_evt; \
226# define vsf_task_wait_until(...) \
227 __VA_ARGS__ {} else { \
234# if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
240#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
250#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
251# if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
#define VSF_CAL_SECTION(__SEC)
Definition __compiler.h:181
uint32_t uintptr_t
Definition stdint.h:38
int16_t vsf_evt_t
Definition vsf_eda.h:654
void(* vsf_eda_evthandler_t)(vsf_eda_t *eda, vsf_evt_t evt)
Definition vsf_eda.h:656
fsm_rt_t
Definition vsf_fsm.h:315
fsm_rt_t(* vsf_task_entry_t)(uintptr_t target, vsf_evt_t evt)
Definition vsf_task.h:241
vsf_teda_t vsf_task_t
Definition vsf_task.h:235
fsm_rt_t __vsf_eda_call_task(vsf_task_entry_t entry, uintptr_t param, size_t local_size)
Definition vsf_task.c:49