18#ifndef __COMMON_TYPE_H__
19#define __COMMON_TYPE_H__
36#include "vsf_usr_cfg.h"
70#ifndef __FSM_RT_TYPE__
71#define __FSM_RT_TYPE__
108#if !defined(__USE_LOCAL_LIBC__)
115# undef __USE_LOCAL_LIBC__
122# if VSF_USE_TRACE == ENABLED
126# define VSF_ASSERT(__EXPR) \
129 : vsf_trace_assert(#__EXPR, __FILE__, __LINE__, __FUNCTION__))
131# define VSF_ASSERT assert
135#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
137# define __VSF_STR(__STRING) #__STRING
140# define VSF_STR(__STRING) __VSF_STR(__STRING)
144# define __VSF_STR(...) #__VA_ARGS__
147# define VSF_STR(...) __VSF_STR(__VA_ARGS__)
151#define vsf_max(__a, __b) (((__a) > (__b)) ? (__a) : (__b))
152#define vsf_min(__a, __b) (((__a) < (__b)) ? (__a) : (__b))
155# define dimof(__arr) (sizeof(__arr) / sizeof((__arr)[0]))
159#if __IS_COMPILER_GCC__ || __IS_COMPILER_LLVM__
160# define vsf_offset_of(__type, __member) __builtin_offsetof(__type, __member)
162# define vsf_offset_of(__type, __member) (uintptr_t)(&(((__type *)0)->__member))
164#define vsf_container_of(__ptr, __type, __member) \
165 ((__type *)((uintptr_t)(__ptr) - vsf_offset_of(__type, __member)))
166#define vsf_safe_container_of(__ptr, __type, __member) \
167 (__ptr ? vsf_container_of(__ptr, __type, __member) : NULL)
169#ifndef VSF_COMPATIBILITY
170# define VSF_COMPATIBILITY ENABLED
172#if VSF_COMPATIBILITY == ENABLED
174# define container_of vsf_container_of
176# ifndef safe_container_of
177# define safe_container_of vsf_safe_container_of
181static inline int vsf_sign(
int x)
183 return ((
int)((
int)((
int)(x) > 0) - (
int)((
int)(x) < 0)));
186#define vsf_abs(__num) (((__num) < 0) ? (-(__num)) : (__num))
188#define VSF_BIT(__N) (1UL << (__N))
189#define VSF_BITMASK(__N) (VSF_BIT(__N) - 1)
190#define VSF_UNUSED_PARAM(__VAL) (void)(__VAL)
192#define VSF_STATIC_ASSERT(__COND) \
193 typedef int VSF_MACRO_SAFE_NAME(STATIC_ASSERT)[(__COND) * 2 - 1]
199# define __STR __VSF_STR
201# define sign vsf_sign
207#if __IS_COMPILER_IAR__
209# pragma diag_suppress=pe301
213#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
224#if __IS_COMPILER_IAR__
237#define __REG_CONNECT(__A, __B) __A##__B
238#define __REG_RSVD_NAME(__NAME) __REG_CONNECT(__unused_, __NAME)
240#define ____REG_RSVD(__NAME, __BIT) \
241 reg##__BIT##_t __NAME : __BIT;
242#define ____REG_RSVD_N(__NAME, __BIT, __N) \
243 reg##__BIT##_t __NAME[__N];
244#define __REG_RSVD(__BIT) ____REG_RSVD(REG_RSVD_NAME, __BIT)
245#define __REG_RSVD_N(__BIT, __N) ____REG_RSVD_N(REG_RSVD_NAME, __BIT, (__N))
247#define REG_RSVD_NAME __REG_RSVD_NAME(__LINE__)
248#define REG_RSVD(__BIT) __REG_RSVD(__BIT)
249#define REG_RSVD_N(__BIT, __N) __REG_RSVD_N(__BIT, (__N))
251#define REG_RSVD_U8 REG_RSVD(8)
252#define REG_RSVD_U16 REG_RSVD(16)
253#define REG_RSVD_U32 REG_RSVD(32)
255#define REG_RSVD_U8N(__N) REG_RSVD_N(8, (__N))
256#define REG_RSVD_U16N(__N) REG_RSVD_N(16, (__N))
257#define REG_RSVD_U32N(__N) REG_RSVD_N(32, (__N))
259#define REG8_RSVD_N(__N) REG_RSVD_U8N(__N)
260#define REG8_RSVD_B(__BYTE_CNT) REG8_RSVD_N(__BYTE_CNT)
261#define REG8_RSVD_8B REG8_RSVD_B(8)
262#define REG8_RSVD_16B REG8_RSVD_B(16)
263#define REG8_RSVD_32B REG8_RSVD_B(32)
264#define REG8_RSVD_64B REG8_RSVD_B(64)
265#define REG8_RSVD_128B REG8_RSVD_B(128)
266#define REG8_RSVD_256B REG8_RSVD_B(256)
267#define REG8_RSVD_512B REG8_RSVD_B(512)
268#define REG8_RSVD_1K REG8_RSVD_B(1024)
269#define REG8_RSVD_2K REG8_RSVD_B(2048)
270#define REG8_RSVD_4K REG8_RSVD_B(4096)
271#define REG8_RSVD_8K REG8_RSVD_B(8192)
272#define REG8_RSVD_16K REG8_RSVD_B(16 * 1024)
273#define REG8_RSVD_32K REG8_RSVD_B(32 * 1024)
274#define REG8_RSVD_64K REG8_RSVD_B(64 * 1024)
275#define REG8_RSVD_128K REG8_RSVD_B(128 * 1024)
276#define REG8_RSVD_256K REG8_RSVD_B(256 * 1024)
277#define REG8_RSVD_512K REG8_RSVD_B(512 * 1024)
278#define REG8_RSVD_1M REG8_RSVD_B(1024 * 1024)
280#define REG16_RSVD_N(__N) REG_RSVD_U16N(__N)
282#define REG16_RSVD_B(__BYTE_CNT) REG16_RSVD_N(__BYTE_CNT >> 1)
283#define REG16_RSVD_8B REG16_RSVD_B(8)
284#define REG16_RSVD_16B REG16_RSVD_B(16)
285#define REG16_RSVD_32B REG16_RSVD_B(32)
286#define REG16_RSVD_64B REG16_RSVD_B(64)
287#define REG16_RSVD_128B REG16_RSVD_B(128)
288#define REG16_RSVD_256B REG16_RSVD_B(256)
289#define REG16_RSVD_512B REG16_RSVD_B(512)
290#define REG16_RSVD_1K REG16_RSVD_B(1024)
291#define REG16_RSVD_2K REG16_RSVD_B(2048)
292#define REG16_RSVD_4K REG16_RSVD_B(4096)
293#define REG16_RSVD_8K REG16_RSVD_B(8192)
294#define REG16_RSVD_16K REG16_RSVD_B(16 * 1024)
295#define REG16_RSVD_32K REG16_RSVD_B(32 * 1024)
296#define REG16_RSVD_64K REG16_RSVD_B(64 * 1024)
297#define REG16_RSVD_128K REG16_RSVD_B(128 * 1024)
298#define REG16_RSVD_256K REG16_RSVD_B(256 * 1024)
299#define REG16_RSVD_512K REG16_RSVD_B(512 * 1024)
300#define REG16_RSVD_1M REG16_RSVD_B(1024 * 1024)
302#define REG32_RSVD_N(__N) REG_RSVD_U32N(__N)
304#define REG32_RSVD_B(__BYTE_CNT) REG_RSVD_U32N(__BYTE_CNT >> 2)
305#define REG32_RSVD_8B REG32_RSVD_B(8)
306#define REG32_RSVD_16B REG32_RSVD_B(16)
307#define REG32_RSVD_32B REG32_RSVD_B(32)
308#define REG32_RSVD_64B REG32_RSVD_B(64)
309#define REG32_RSVD_128B REG32_RSVD_B(128)
310#define REG32_RSVD_256B REG32_RSVD_B(256)
311#define REG32_RSVD_512B REG32_RSVD_B(512)
312#define REG32_RSVD_1K REG32_RSVD_B(1024)
313#define REG32_RSVD_2K REG32_RSVD_B(2048)
314#define REG32_RSVD_4K REG32_RSVD_B(4096)
315#define REG32_RSVD_8K REG32_RSVD_B(8192)
316#define REG32_RSVD_16K REG32_RSVD_B(16 * 1024)
317#define REG32_RSVD_32K REG32_RSVD_B(32 * 1024)
318#define REG32_RSVD_64K REG32_RSVD_B(64 * 1024)
319#define REG32_RSVD_128K REG32_RSVD_B(128 * 1024)
320#define REG32_RSVD_256K REG32_RSVD_B(256 * 1024)
321#define REG32_RSVD_512K REG32_RSVD_B(512 * 1024)
322#define REG32_RSVD_1M REG32_RSVD_B(1024 * 1024)
344#if !defined(__USE_LOCAL_STDIO__)
349# undef __USE_LOCAL_STDIO__
352#if !defined(__USE_LOCAL_SETJMP__)
357# undef __USE_LOCAL_SETJMP__
360#if !defined(__USE_LOCAL_STDARG__)
365# undef __USE_LOCAL_STDARG__
volatile uint32_t reg32_t
Definition __type.h:235
volatile uint16_t reg16_t
Definition __type.h:234
volatile uint8_t reg8_t
Definition __type.h:233
vsf_err_t
Definition __type.h:42
@ VSF_ERR_NOT_SUPPORT
function not supported
Definition __type.h:46
@ VSF_ERR_NONE
none error
Definition __type.h:44
@ VSF_ERR_NOT_ACCESSIBLE
Definition __type.h:49
@ VSF_ERR_INVALID_PTR
invalid pointer
Definition __type.h:54
@ VSF_ERR_INVALID_PARAMETER
invalid parameter
Definition __type.h:52
@ VSF_ERR_ALREADY_EXISTS
already exists
Definition __type.h:57
@ VSF_ERR_NOT_READY
service not ready yet
Definition __type.h:43
@ VSF_ERR_NOT_AVAILABLE
service not available
Definition __type.h:47
@ VSF_ERR_REQ_ALREADY_REGISTERED
request all ready exist
Definition __type.h:58
@ VSF_ERR_IO
IO error.
Definition __type.h:56
@ VSF_ERR_BUG
bug
Definition __type.h:59
@ VSF_ERR_TIMEOUT
Definition __type.h:65
@ VSF_ERR_OVERRUN
overrun
Definition __type.h:60
@ VSF_ERR_PROVIDED_RESOURCE_NOT_SUFFICIENT
the resource provided by user is not sufficient
Definition __type.h:61
@ VSF_ERR_PROVIDED_RESOURCE_NOT_ALIGNED
the provided resource is not aligned to certain size (2^N)
Definition __type.h:63
@ VSF_ERR_NOT_ACCESSABLE
target not acceesable
Definition __type.h:48
@ VSF_ERR_UNKNOWN
unknown error
Definition __type.h:45
@ VSF_ERR_INVALID_KEY
invalid key
Definition __type.h:55
@ VSF_ERR_INVALID_RANGE
invalid range
Definition __type.h:53
@ VSF_ERR_FAIL
failed
Definition __type.h:51
@ VSF_ERR_NOT_ENOUGH_RESOURCES
no enough resources
Definition __type.h:50
@ VSF_ERR_BUSY
Definition __type.h:66
fsm_rt_t
Definition __type.h:74
@ fsm_rt_wait_for_evt
Definition __type.h:80
@ fsm_rt_asyn
fsm asynchronose complete, you can check it later.
Definition __type.h:82
@ fsm_rt_err
fsm error, error code can be get from other interface
Definition __type.h:75
@ fsm_rt_wait_for_obj
fsm wait for object
Definition __type.h:79
@ fsm_rt_user
Definition __type.h:83
@ fsm_rt_cpl
fsm complete
Definition __type.h:76
@ fsm_rt_yield
Definition __type.h:78
@ fsm_rt_wfe
Definition __type.h:81
@ fsm_rt_on_going
fsm on-going
Definition __type.h:77
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
unsigned uint_least32_t
Definition stdint.h:18
unsigned short uint_least16_t
Definition stdint.h:16