Skip to content

Commit 891a0c9

Browse files
committed
npl/riot: simplify ble_npl_hw_is_in_critical()
Recently the RIOT IRQ API was extended to support irq_is_enabled(), so time to switch away from the hacked implementation of ble_npl_hw_is_in_critical().
1 parent ddf8043 commit 891a0c9

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

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

+2-12
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ extern "C" {
3838
typedef uint32_t ble_npl_time_t;
3939
typedef int32_t ble_npl_stime_t;
4040

41-
extern volatile int ble_npl_in_critical;
42-
4341
struct ble_npl_event {
4442
event_callback_t e;
4543
void *arg;
@@ -257,27 +255,19 @@ ble_npl_time_delay(ble_npl_time_t ticks)
257255
static inline uint32_t
258256
ble_npl_hw_enter_critical(void)
259257
{
260-
uint32_t ctx = irq_disable();
261-
++ble_npl_in_critical;
262-
return ctx;
258+
return (uint32_t)irq_disable();
263259
}
264260

265261
static inline void
266262
ble_npl_hw_exit_critical(uint32_t ctx)
267263
{
268-
--ble_npl_in_critical;
269264
irq_restore((unsigned)ctx);
270265
}
271266

272267
static inline bool
273268
ble_npl_hw_is_in_critical(void)
274269
{
275-
/*
276-
* XXX Currently RIOT does not support an API for finding out if interrupts
277-
* are currently disabled, hence in a critical section in this context.
278-
* So for now, we use this global variable to keep this state for us.
279-
-*/
280-
return (ble_npl_in_critical > 0);
270+
return (bool)!irq_is_enabled();
281271
}
282272

283273
#ifdef __cplusplus

0 commit comments

Comments
 (0)