You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2023/01/27 18:55:25 UTC

[mynewt-nimble] 02/09: nimble/ll: Add few useful macros

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 6e9b61b1c8f6a715ae7fc4676eeecf2ac1fd45e4
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Sat Feb 26 21:35:48 2022 +0100

    nimble/ll: Add few useful macros
---
 nimble/controller/include/controller/ble_ll_utils.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/nimble/controller/include/controller/ble_ll_utils.h b/nimble/controller/include/controller/ble_ll_utils.h
index 16b91a0c..added990 100644
--- a/nimble/controller/include/controller/ble_ll_utils.h
+++ b/nimble/controller/include/controller/ble_ll_utils.h
@@ -23,6 +23,11 @@
 #define INT16_LT(_a, _b) ((int16_t)((_a) - (_b)) < 0)
 #define INT16_LTE(_a, _b) ((int16_t)((_a) - (_b)) <= 0)
 
+#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
+#define MAX(_a, _b) ((_a) < (_b) ? (_a) : (_b))
+#define CLAMP(_n, _min, _max) (MAX(_min, MIN(_n, _max)))
+#define IN_RANGE(_n, _min, _max) (((_n) >= (_min)) && ((_n) <= (_max)))
+
 uint32_t ble_ll_utils_calc_access_addr(void);
 uint8_t ble_ll_utils_remapped_channel(uint8_t remap_index, const uint8_t *chanmap);
 uint8_t ble_ll_utils_dci_csa2(uint16_t counter, uint16_t chan_id,