24#if VSF_KERNEL_CFG_EDA_SUPPORT_PT == ENABLED && VSF_USE_KERNEL == ENABLED
25#include "../vsf_eda.h"
36#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
37# define __implement_vsf_pt(__name) \
38 __implement_vsf_pt_common(__name, uintptr_t local) \
40 __vsf_pt_common(__name) *vsf_pthis = \
41 *(__vsf_pt_common(__name) **) \
42 ((uintptr_t)local - sizeof(uintptr_t));
44# define __implement_vsf_pt_ex(__name, __func_name) \
45 __implement_vsf_pt_common( __func_name, uintptr_t local) \
47 __vsf_pt_common(__name) *vsf_pthis = \
48 *(__vsf_pt_common(__name) **) \
49 ((uintptr_t)local - sizeof(uintptr_t));
53# define __implement_vsf_pt(__name) \
54 __implement_vsf_pt_common(__name, __name *obj_ptr) { \
55 __vsf_pt_common(__name) *vsf_pthis = &(obj_ptr->param);
57# define __implement_vsf_pt_ex(__name, __func_name) \
58 __implement_vsf_pt_common(__func_name, __name *obj_ptr) { \
59 __vsf_pt_common(__name) *vsf_pthis = &(obj_ptr->param);
62#define __vsf_pt_state() (vsf_this.fsm_state)
63#define __vsf_pt_end() __vsf_pt_end_common()
66#define __vsf_pt_entry(__state, ...) \
67 __vsf_pt_entry_common(__state, __VA_ARGS__)
68#define vsf_pt_entry(...) \
69 __vsf_pt_entry(__vsf_pt_state(), __VA_ARGS__)
71#define __vsf_pt_begin(__state) __vsf_pt_begin_common(__state)
74#define vsf_pt_begin() VSF_UNUSED_PARAM(evt); \
75 __vsf_pt_begin(__vsf_pt_state())
77#define vsf_pt_end() __vsf_pt_end() }
79#define vsf_pt_wait_for_evt(__evt) __vsf_pt_wfe_common(__vsf_pt_state(), __evt)
80#define vsf_pt_wfe(__evt) vsf_pt_wait_for_evt(__evt)
82#define vsf_pt_yield() vsf_pt_entry(__vsf_eda_yield();)
84#if VSF_KERNEL_CFG_EDA_FAST_SUB_CALL == ENABLED
85# define vsf_pt_raw_next() __vsf_pt_raw_next_common(__vsf_pt_state())
86# define vsf_pt_raw_entry(...) __vsf_pt_raw_entry_common(__vsf_pt_state(), __VA_ARGS__)
100#define vsf_pt_wait_until(...) \
102 __VA_ARGS__ {} else { \
106#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
107# define __vsf_pt_call_sub(__name, __target, ...) \
108 __vsf_eda_call_eda( (uintptr_t)(__name), \
109 (uintptr_t)(__target), \
112# if VSF_KERNEL_CFG_EDA_FAST_SUB_CALL == ENABLED
113# define vsf_pt_call_sub(__name, __target) \
115 vsf_err_t VSF_MACRO_SAFE_NAME(ret) = \
116 __vsf_pt_call_sub(__name, (__target)); \
117 VSF_KERNEL_ASSERT(VSF_ERR_NONE == VSF_MACRO_SAFE_NAME(ret)); \
121# define vsf_pt_call_sub(__name, __target) \
123 if (VSF_ERR_NONE != __vsf_pt_call_sub(__name, (__target))) { \
126 vsf_pt_entry(return;);
130# define vsf_pt_call_pt(__name, __target) \
131 (__target)->fsm_state = 0; \
132 vsf_pt_call_sub(vsf_pt_func(__name), (__target))
136#define vsf_eda_call_pt(__name, __target) \
137 __vsf_pt_call_sub(vsf_pt_func(__name), (__target))
139#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
140# define __vsf_pt_call_task(__name, __target, ...) \
141 __vsf_eda_call_task((vsf_task_entry_t)(__name), \
142 (uintptr_t)(__target), \
146# define vsf_pt_call_task(__name, __target, __ret_addr, ...) \
148 fsm_rt_t VSF_MCONNECT3(__vsf_pt_call_task,__LINE__,tReturn); \
150 VSF_MCONNECT3(__vsf_pt_call_task,__LINE__,tReturn) = \
151 __vsf_pt_call_task(vsf_task_func(__name), (__target), (0, ##__VA_ARGS__));\
152 if (fsm_rt_on_going == \
153 VSF_MCONNECT3(__vsf_pt_call_task,__LINE__,tReturn)) { \
156 if (NULL != (__ret_addr)) { \
158 VSF_MCONNECT3(__vsf_pt_call_task,__LINE__,tReturn); \
163#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
164# define vsf_pt_start vsf_teda_start
166# define vsf_pt_start vsf_eda_start
171#define implement_vsf_pt(__name) __implement_vsf_pt(__name)
172#define implement_vsf_pt_ex(__name, __FUNC_NAME) \
173 __implement_vsf_pt_ex(__name, __FUNC_NAME)
175#define imp_vsf_pt(__name) implement_vsf_pt(__name)
176#define imp_vsf_pt_ex(__name, __FUNC_NAME) \
177 implement_vsf_pt_ex(__name, __FUNC_NAME)
179#define __vsf_pt_func(__name) __vsf_pt_func_common(__name)
180#define vsf_pt_func(__name) __vsf_pt_func(__name)
182#define __vsf_pt(__name) __vsf_pt_common(__name)
183#define vsf_pt(__name) __vsf_pt(__name)
185#define __def_vsf_pt(__name,...) \
186 __def_vsf_pt_common(__name, \
190#define def_vsf_pt(__name,...) __def_vsf_pt(__name,__VA_ARGS__)
191#define end_def_vsf_pt(...)
192#define define_vsf_pt(__name,...) def_vsf_pt(__name,__VA_ARGS__)
193#define end_define_vsf_pt(...)
197#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
198# define __declare_vsf_pt(__name) \
199 __declare_vsf_pt_common(__name) \
200 __extern_vsf_pt_common(__name, uintptr_t local)
202# define __declare_vsf_pt(__name) \
203 __declare_vsf_pt_common(__name) \
204 __extern_vsf_pt_common(__name, __name *vsf_pthis)
207#define declare_vsf_pt(__name) __declare_vsf_pt(__name)
208#define dcl_vsf_pt(__name) declare_vsf_pt(__name)
210#define __init_vsf_pt(__name, __pt, __pri, ...) \
212 vsf_eda_cfg_t VSF_MACRO_SAFE_NAME(cfg) = { \
213 .fn.evthandler = (vsf_pt_entry_t)__vsf_pt_func(__name), \
214 .priority = (__pri), \
215 .target = (uintptr_t)&((__pt)->param), \
218 (__pt)->param.fsm_state = 0; \
219 vsf_pt_start(&((__pt)->use_as__vsf_pt_t), \
220 &VSF_MACRO_SAFE_NAME(cfg)); \
225#if VSF_KERNEL_CFG_SUPPORT_THREAD == ENABLED \
226 && VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
228# if VSF_KERNEL_CFG_EDA_FAST_SUB_CALL == ENABLED
229# define vsf_pt_call_thread(__name, __target) \
230 vsf_eda_call_thread_prepare(__name, __target); \
232 vsf_err_t VSF_MACRO_SAFE_NAME(ret) = \
233 vsf_eda_call_thread(__target); \
234 VSF_KERNEL_ASSERT(VSF_ERR_NONE == VSF_MACRO_SAFE_NAME(ret)); \
238# define vsf_pt_call_thread(__name, __target) \
239 vsf_eda_call_thread_prepare(__name, __target); \
241 if (VSF_ERR_NONE != vsf_eda_call_thread(__target)) { \
244 vsf_pt_entry(return;);
248#define init_vsf_pt(__name, __pt, __pri, ...) \
249 __init_vsf_pt(__name, __pt, __pri, __VA_ARGS__)
253#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
void(* vsf_eda_evthandler_t)(vsf_eda_t *eda, vsf_evt_t evt)
Definition vsf_eda.h:656
vsf_teda_t vsf_pt_t
Definition vsf_pt.h:254
vsf_eda_evthandler_t vsf_pt_entry_t
Definition vsf_pt.h:259