Skip to content

Commit 92ab01c

Browse files
andrzej-kaczmarekMichał Narajowski
authored and
Michał Narajowski
committed
porting: Add NPL equivalent for OS_ASSERT_CRITICAL
1 parent 8ae6aff commit 92ab01c

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

nimble/include/nimble/nimble_npl.h

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ uint32_t ble_npl_hw_enter_critical(void);
165165

166166
void ble_npl_hw_exit_critical(uint32_t ctx);
167167

168+
bool ble_npl_hw_is_in_critical(void);
169+
168170
#ifdef __cplusplus
169171
}
170172
#endif

porting/nimble/include/os/os.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern "C" {
4545
typedef uint32_t os_sr_t;
4646
#define OS_ENTER_CRITICAL(_sr) (_sr = ble_npl_hw_enter_critical())
4747
#define OS_EXIT_CRITICAL(_sr) (ble_npl_hw_exit_critical(_sr))
48+
#define OS_ASSERT_CRITICAL() (assert(ble_npl_hw_is_in_critical()))
4849

4950
/* Mynewt components (not abstracted in NPL) */
5051
#include "os/endian.h"

porting/npl/riot/include/nimble/nimble_npl_os.h

+6
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ ble_npl_hw_exit_critical(uint32_t ctx)
256256
irq_restore((unsigned)ctx);
257257
}
258258

259+
static inline bool
260+
ble_npl_hw_is_in_critical(void)
261+
{
262+
return irq_is_in();
263+
}
264+
259265
#ifdef __cplusplus
260266
}
261267
#endif

0 commit comments

Comments
 (0)