123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- #ifndef NRF_SVC_ASYNC_FUNCTION_H__
- #define NRF_SVC_ASYNC_FUNCTION_H__
- #include "nrf_svci.h"
- #include "nrf_svci_async_handler.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define NRF_SVCI_ACYNC_FUNC_TYPEDEF(name, param_type, state_type) \
- typedef uint32_t (* name ## _async_fn_t)(param_type * p_param, state_type * p_state)
- #define NRF_SVCI_ASYNC_EVENT_FUNC_TYPEDEF(name, state_type) \
- typedef uint32_t (* name ## _event_fn_t)(uint32_t sys_evt, state_type * p_state)
- #define NRF_SVCI_ASYNC_FUNC_DECLARE(svci_num, \
- name, \
- param_type, \
- state_type) \
- \
- NRF_SVCI_ACYNC_FUNC_TYPEDEF(name, param_type, state_type); \
- NRF_SVCI_ASYNC_EVENT_FUNC_TYPEDEF(name, state_type); \
- \
- typedef struct \
- { \
- name ## _async_fn_t async_func; \
- name ## _event_fn_t sys_evt_handler; \
- state_type state; \
- } name ## _svci_async_t;
- #define NRF_SVCI_ASYNC_FUNC_DEFINE(svci_num, name, param_type) \
- \
- SVCI(svci_num, uint32_t, name ## _svci_async_init, name ## _svci_async_t *, p_async); \
- static name ## _svci_async_t name ## _svci_async_def = {0}; \
- \
- static __INLINE uint32_t name ## _init (void) \
- { \
- return name ## _svci_async_init(&name ## _svci_async_def); \
- } \
- \
- static __INLINE uint32_t name(param_type * p_param) \
- { \
- return name ## _svci_async_def.async_func(p_param, &name ## _svci_async_def.state); \
- } \
- \
- static __INLINE uint32_t name ## _on_sys_evt(uint32_t sys_evt) \
- { \
- return name ## _svci_async_def.sys_evt_handler(sys_evt, &name ## _svci_async_def.state); \
- } \
- \
- static __INLINE uint32_t name ## _is_initialized(void) \
- { \
- return (name ## _svci_async_def.async_func != NULL && \
- name ## _svci_async_def.sys_evt_handler != NULL ); \
- }
- #ifdef __cplusplus
- }
- #endif
- #endif
|