esp32/mphalport: Provide proper implementations of disable_/enable_irq.
#ifndef INCLUDED_MPHALPORT_H
#define INCLUDED_MPHALPORT_H
+#include "freertos/FreeRTOS.h"
#include "py/ringbuf.h"
#include "lib/utils/interrupt_char.h"
extern ringbuf_t stdin_ringbuf;
-// TODO implement me
-#define disable_irq() 0
-#define enable_irq(irq_state) (void)(irq_state)
+// Note: these "critical nested" macros do not ensure cross-CPU exclusion,
+// the only disable interrupts on the current CPU. To full manage exclusion
+// one should use portENTER_CRITICAL/portEXIT_CRITICAL instead.
+#define disable_irq() portENTER_CRITICAL_NESTED()
+#define enable_irq(irq_state) portEXIT_CRITICAL_NESTED(irq_state)
uint32_t mp_hal_ticks_us(void);
__attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) {
