nrf: Use common implementation of machine disable/enable IRQ.
This is a breaking change due to the signature change of `enable_irq()`.
Previously the signature was:
machine.enable_irq()
Now the signature matches other ports, and the docs, and is:
machine.enable_irq(state)
Where `state` is the return value from `machine.disable_irq()`.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -85,8 +85,6 @@
|
|||||||
|
|
||||||
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
|
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
|
||||||
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) }, \
|
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_info_obj) }, \
|
||||||
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) }, \
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) }, \
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_lightsleep_obj) }, \
|
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_lightsleep_obj) }, \
|
||||||
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&pin_type) }, \
|
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&pin_type) }, \
|
||||||
\
|
\
|
||||||
@@ -214,24 +212,3 @@ static mp_obj_t mp_machine_get_freq(void) {
|
|||||||
static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
|
static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
|
||||||
mp_raise_NotImplementedError(NULL);
|
mp_raise_NotImplementedError(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static mp_obj_t machine_enable_irq(void) {
|
|
||||||
#ifndef BLUETOOTH_SD
|
|
||||||
__enable_irq();
|
|
||||||
#else
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return mp_const_none;
|
|
||||||
}
|
|
||||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_enable_irq_obj, machine_enable_irq);
|
|
||||||
|
|
||||||
// Resets the board in a manner similar to pushing the external RESET button.
|
|
||||||
static mp_obj_t machine_disable_irq(void) {
|
|
||||||
#ifndef BLUETOOTH_SD
|
|
||||||
__disable_irq();
|
|
||||||
#else
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return mp_const_none;
|
|
||||||
}
|
|
||||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
|
|
||||||
|
|||||||
@@ -181,6 +181,7 @@
|
|||||||
#define MICROPY_PY_MACHINE_RESET (1)
|
#define MICROPY_PY_MACHINE_RESET (1)
|
||||||
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
|
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
|
||||||
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
|
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
|
||||||
|
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)
|
||||||
#define MICROPY_PY_MACHINE_PULSE (0)
|
#define MICROPY_PY_MACHINE_PULSE (0)
|
||||||
#define MICROPY_PY_MACHINE_SOFTI2C (MICROPY_PY_MACHINE_I2C)
|
#define MICROPY_PY_MACHINE_SOFTI2C (MICROPY_PY_MACHINE_I2C)
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,22 @@
|
|||||||
#include "nrfx_config.h"
|
#include "nrfx_config.h"
|
||||||
#include "shared/runtime/interrupt_char.h"
|
#include "shared/runtime/interrupt_char.h"
|
||||||
|
|
||||||
|
// Entering a critical section.
|
||||||
|
#ifndef BLUETOOTH_SD
|
||||||
|
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
||||||
|
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline void enable_irq(mp_uint_t state) {
|
||||||
|
__set_PRIMASK(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline mp_uint_t disable_irq(void) {
|
||||||
|
mp_uint_t state = __get_PRIMASK();
|
||||||
|
__disable_irq();
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
HAL_OK = 0x00,
|
HAL_OK = 0x00,
|
||||||
|
|||||||
Reference in New Issue
Block a user