nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
nrf_rpc_cbkproxy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
15#ifndef NRF_RPC_CBKPROXY_H
16#define NRF_RPC_CBKPROXY_H
17
18#include <stdint.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
58#define NRF_RPC_CBKPROXY_HANDLER(...) \
59 _CBKPROXY_HANDLER_CAT(_CBKPROXY_HANDLER_, _CBKPROXY_HANDLER_CNT(__VA_ARGS__)) (__VA_ARGS__)
60#define _CBKPROXY_HANDLER_CNT2(a, b, c, d, e, f, ...) f
61#define _CBKPROXY_HANDLER_CNT(...) \
62 _CBKPROXY_HANDLER_CNT2(__VA_ARGS__, RET_PARAM, VOID_PARAM, RET_VOID, VOID_VOID)
63#define _CBKPROXY_HANDLER_CAT2(a, b) a ## b
64#define _CBKPROXY_HANDLER_CAT(a, b) _CBKPROXY_HANDLER_CAT2(a, b)
65#define _CBKPROXY_HANDLER_PAR1(...) \
66 uint32_t callback_slot, uint32_t _rsv0, uint32_t _rsv1, uint32_t _ret, __VA_ARGS__
67#define _CBKPROXY_HANDLER_PAR(p) (_CBKPROXY_HANDLER_PAR1 p)
68#define _CBKPROXY_HANDLER_ARG1(...) __VA_ARGS__, callback_slot
69#define _CBKPROXY_HANDLER_ARG(p) (_CBKPROXY_HANDLER_ARG1 p)
70#define _CBKPROXY_HANDLER_VOID_VOID(f, h) \
71 uint64_t f(uint32_t callback_slot, uint32_t _rsv0, uint32_t _rsv1, \
72 uint32_t _ret) \
73 { \
74 h(); \
75 return (uint64_t)_ret << 32; \
76 }
77#define _CBKPROXY_HANDLER_RET_VOID(f, h, r) \
78 uint64_t f(uint32_t callback_slot, uint32_t _rsv0, uint32_t _rsv1, uint32_t _ret) \
79 { \
80 BUILD_ASSERT(sizeof(r) <= 4, "Return value does not fit into uint32_t."); \
81 uint32_t _low_ret = (uint32_t)h(); \
82 return (uint64_t)_low_ret | ((uint64_t)_ret << 32); \
83 }
84#define _CBKPROXY_HANDLER_VOID_PARAM(f, h, p, a) \
85 uint64_t f _CBKPROXY_HANDLER_PAR(p) \
86 { \
87 h _CBKPROXY_HANDLER_ARG(a); \
88 return (uint64_t)_ret << 32; \
89 }
90#define _CBKPROXY_HANDLER_RET_PARAM(f, h, r, p, a) \
91 uint64_t f _CBKPROXY_HANDLER_PAR(p) \
92 { \
93 BUILD_ASSERT(sizeof(r) <= 4, "Return value does not fit into uint32_t."); \
94 uint32_t _low_ret = (uint32_t)h _CBKPROXY_HANDLER_ARG(a); \
95 return (uint64_t)_low_ret | ((uint64_t)_ret << 32); \
96 }
97
106#define NRF_RPC_CBKPROXY_HANDLER_DECL(...) _CBKPROXY_HANDLER_CAT(_CBKPROXY_HANDLER_DECL_, \
107 _CBKPROXY_HANDLER_DECL_CNT(__VA_ARGS__)) (__VA_ARGS__)
108#define _CBKPROXY_HANDLER_DECL_CNT(...) \
109 _CBKPROXY_HANDLER_CNT2(_, __VA_ARGS__, RET_PARAM, VOID_PARAM, RET_VOID, VOID_VOID)
110#define _CBKPROXY_HANDLER_DECL_VOID_VOID(f) \
111 uint64_t f(uint32_t callback_slot, uint32_t _rsv0, uint32_t _rsv1, uint32_t _ret)
112#define _CBKPROXY_HANDLER_DECL_RET_VOID(f, r) \
113 uint64_t f(uint32_t callback_slot, uint32_t _rsv0, uint32_t _rsv1, uint32_t _ret)
114#define _CBKPROXY_HANDLER_DECL_VOID_PARAM(f, p, a) \
115 uint64_t f _CBKPROXY_HANDLER_PAR(p)
116#define _CBKPROXY_HANDLER_DECL_RET_PARAM(f, r, p, a) \
117 uint64_t f _CBKPROXY_HANDLER_PAR(p)
118
138void *nrf_rpc_cbkproxy_out_get(int index, void *handler);
139
149int nrf_rpc_cbkproxy_in_set(void *callback);
150
157void *nrf_rpc_cbkproxy_in_get(int index);
158
159#ifdef __cplusplus
160}
161#endif
162
165#endif /* NRF_RPC_CBKPROXY_H */
int nrf_rpc_cbkproxy_in_set(void *callback)
Sets input callback proxy.
void * nrf_rpc_cbkproxy_out_get(int index, void *handler)
Get output callback proxy.
void * nrf_rpc_cbkproxy_in_get(int index)
Gets input callback proxy.