Edge AI Add-on API 2.2.0
Loading...
Searching...
No Matches
nrf_edgeai_macro.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6#ifndef _NRF_EDGEAI_MACRO_H_
7#define _NRF_EDGEAI_MACRO_H_
8
16#ifndef RETURN_IF
17#define RETURN_IF(is_true, ret_val) \
18 do \
19 { \
20 if ((is_true)) { return ret_val; } \
21 } \
22 while (0)
23#endif // RETURN_IF
24
32#ifndef BIT_ONE
33#define BIT_ONE(pos) (1UL << (pos))
34#endif
35
43#ifndef BIT_ZERO
44#define BIT_ZERO(pos) (~BIT_ONE(pos))
45#endif
46
55#ifndef BIT_IS_SET
56#define BIT_IS_SET(value, pos) (BIT_ONE(pos) & (value) != 0)
57#endif
58
67#ifndef BIT_IS_CLR
68#define BIT_IS_CLR(value, pos) (BIT_ONE(pos) & (value) == 0)
69#endif
70
79#ifndef BITS_CHANGED
80#define BITS_CHANGED(before, after) ((before) ^ (after))
81#endif
82
91#ifndef BITS_RISING
92#define BITS_RISING(before, after) (BITS_CHANGED(before, after) & (after))
93#endif
94
103#ifndef BITS_FALLING
104#define BITS_FALLING(before, after) (BITS_CHANGED(before, after) & (before))
105#endif
106
115#ifndef ROUNDED_DIV
116#define ROUNDED_DIV(A, B) (((A) + ((B) / 2)) / (B))
117#endif
118
126#ifndef COUNT_OF
127#define COUNT_OF(x) ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x])))))
128#endif
129
138#ifndef OFFSET_OF
139#define OFFSET_OF(type, field) ((unsigned long)&(((type*)0)->field))
140#endif
141
142#endif /* _NRF_EDGEAI_MACRO_H_ */