8000 stm32/mpconfigport.h: Use IRQ_PRI_PENDSV to protect bluetooth ringbuf. · rlangoy/micropython@40cc7ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 40cc7ec

Browse files
committed
stm32/mpconfigport.h: Use IRQ_PRI_PENDSV to protect bluetooth ringbuf.
The default protection for the BLE ringbuf is to use MICROPY_BEGIN_ATOMIC_SECTION, which disables all interrupts. On stm32 it only needs to disable the lowest priority IRQ, pendsv, because that's the IRQ level at which the BLE stack is driven.
1 parent 82a19cb commit 40cc7ec

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

extmod/modbluetooth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "py/objarray.h"
3434
#include "py/qstr.h"
3535
#include "py/runtime.h"
36+
#include "py/mphal.h"
3637
#include "extmod/modbluetooth.h"
3738
#include <string.h>
3839

ports/stm32/mpconfigport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ static inline mp_uint_t disable_irq(void) {
366366
#define MICROPY_PY_LWIP_REENTER irq_state = raise_irq_pri(IRQ_PRI_PENDSV);
367367
#define MICROPY_PY_LWIP_EXIT restore_irq_pri(irq_state);
368368

369+
// Bluetooth calls must run at a raised IRQ priority
370+
#define MICROPY_PY_BLUETOOTH_ENTER MICROPY_PY_LWIP_ENTER
371+
#define MICROPY_PY_BLUETOOTH_EXIT MICROPY_PY_LWIP_EXIT
372+
369373
// We need an implementation of the log2 function which is not a macro
370374
#define MP_NEED_LOG2 (1)
371375

0 commit comments

Comments
 (0)
0