Skip to content

Commit

Permalink
stm32/mpconfigport.h: Use IRQ_PRI_PENDSV to protect bluetooth ringbuf.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpgeorge committed Dec 4, 2019
1 parent 82a19cb commit 40cc7ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions extmod/modbluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "py/objarray.h"
#include "py/qstr.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "extmod/modbluetooth.h"
#include <string.h>

Expand Down
4 changes: 4 additions & 0 deletions ports/stm32/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ static inline mp_uint_t disable_irq(void) {
#define MICROPY_PY_LWIP_REENTER irq_state = raise_irq_pri(IRQ_PRI_PENDSV);
#define MICROPY_PY_LWIP_EXIT restore_irq_pri(irq_state);

// Bluetooth calls must run at a raised IRQ priority
#define MICROPY_PY_BLUETOOTH_ENTER MICROPY_PY_LWIP_ENTER
#define MICROPY_PY_BLUETOOTH_EXIT MICROPY_PY_LWIP_EXIT

// We need an implementation of the log2 function which is not a macro
#define MP_NEED_LOG2 (1)

Expand Down

0 comments on commit 40cc7ec

Please sign in to comment.