esp8266/esp_mphal: Make atomic section more atomic.
By disabling ets_loop_iter when the atomic section is active. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
4bf7987f0a
commit
39d4153a8d
|
@ -166,6 +166,21 @@ void mp_hal_signal_dupterm_input(void) {
|
||||||
system_os_post(DUPTERM_TASK_ID, 0, 0);
|
system_os_post(DUPTERM_TASK_ID, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this bit is unused in the Xtensa PS register
|
||||||
|
#define ETS_LOOP_ITER_BIT (12)
|
||||||
|
|
||||||
|
uint32_t esp_disable_irq(void) {
|
||||||
|
uint32_t state = disable_irq();
|
||||||
|
state = (state & ~(1 << ETS_LOOP_ITER_BIT)) | (ets_loop_iter_disable << ETS_LOOP_ITER_BIT);
|
||||||
|
ets_loop_iter_disable = 1;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_enable_irq(uint32_t state) {
|
||||||
|
ets_loop_iter_disable = (state >> ETS_LOOP_ITER_BIT) & 1;
|
||||||
|
enable_irq(state & ~(1 << ETS_LOOP_ITER_BIT));
|
||||||
|
}
|
||||||
|
|
||||||
// Get pointer to esf_buf bookkeeping structure
|
// Get pointer to esf_buf bookkeeping structure
|
||||||
void *ets_get_esf_buf_ctlblk(void) {
|
void *ets_get_esf_buf_ctlblk(void) {
|
||||||
// Get literal ptr before start of esf_rx_buf_alloc func
|
// Get literal ptr before start of esf_rx_buf_alloc func
|
||||||
|
|
|
@ -126,9 +126,8 @@
|
||||||
#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
|
#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
|
||||||
#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
|
#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
|
||||||
|
|
||||||
#include "xtirq.h"
|
#define MICROPY_BEGIN_ATOMIC_SECTION() esp_disable_irq()
|
||||||
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
#define MICROPY_END_ATOMIC_SECTION(state) esp_enable_irq(state)
|
||||||
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
|
|
||||||
|
|
||||||
// type definitions for the specific machine
|
// type definitions for the specific machine
|
||||||
|
|
||||||
|
@ -173,3 +172,6 @@ extern const struct _mp_print_t mp_debug_print;
|
||||||
#define WDEV_HWRNG ((volatile uint32_t *)0x3ff20e44)
|
#define WDEV_HWRNG ((volatile uint32_t *)0x3ff20e44)
|
||||||
|
|
||||||
#define _assert(expr) ((expr) ? (void)0 : __assert_func(__FILE__, __LINE__, __func__, #expr))
|
#define _assert(expr) ((expr) ? (void)0 : __assert_func(__FILE__, __LINE__, __func__, #expr))
|
||||||
|
|
||||||
|
uint32_t esp_disable_irq(void);
|
||||||
|
void esp_enable_irq(uint32_t state);
|
||||||
|
|
Loading…
Reference in New Issue