Skip to content

Commit a099bfe

Browse files
committed
esp8266/esp_mphal: Add higher-level event polling function.
ets_event_poll() polls both system events and uPy pending exception.
1 parent e5b0473 commit a099bfe

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

esp8266/esp_mphal.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "uart.h"
3131
#include "esp_mphal.h"
3232
#include "user_interface.h"
33+
#include "ets_alt_task.h"
3334
#include "py/obj.h"
3435
#include "py/mpstate.h"
3536

@@ -105,6 +106,15 @@ void mp_hal_set_interrupt_char(int c) {
105106
interrupt_char = c;
106107
}
107108

109+
void ets_event_poll(void) {
110+
ets_loop_iter();
111+
if (MP_STATE_VM(mp_pending_exception) != NULL) {
112+
mp_obj_t obj = MP_STATE_VM(mp_pending_exception);
113+
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
114+
nlr_raise(obj);
115+
}
116+
}
117+
108118
void __assert_func(const char *file, int line, const char *func, const char *expr) {
109119
printf("assert:%s:%d:%s: %s\n", file, line, func, expr);
110120
nlr_raise(mp_obj_new_exception_msg(&mp_type_AssertionError,

esp8266/esp_mphal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ uint32_t mp_hal_get_cpu_freq(void);
3939
#define UART_TASK_ID 0
4040
void uart_task_init();
4141

42+
void ets_event_poll(void);
4243

4344
#endif // _INCLUDED_MPHAL_H_

0 commit comments

Comments
 (0)