esp8266/esp_mphal: Add higher-level event polling function.
ets_event_poll() polls both system events and uPy pending exception.
This commit is contained in:
parent
e5b047369b
commit
a099bfe89c
@ -30,6 +30,7 @@
|
||||
#include "uart.h"
|
||||
#include "esp_mphal.h"
|
||||
#include "user_interface.h"
|
||||
#include "ets_alt_task.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/mpstate.h"
|
||||
|
||||
@ -105,6 +106,15 @@ void mp_hal_set_interrupt_char(int c) {
|
||||
interrupt_char = c;
|
||||
}
|
||||
|
||||
void ets_event_poll(void) {
|
||||
ets_loop_iter();
|
||||
if (MP_STATE_VM(mp_pending_exception) != NULL) {
|
||||
mp_obj_t obj = MP_STATE_VM(mp_pending_exception);
|
||||
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
|
||||
nlr_raise(obj);
|
||||
}
|
||||
}
|
||||
|
||||
void __assert_func(const char *file, int line, const char *func, const char *expr) {
|
||||
printf("assert:%s:%d:%s: %s\n", file, line, func, expr);
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_AssertionError,
|
||||
|
@ -39,5 +39,6 @@ uint32_t mp_hal_get_cpu_freq(void);
|
||||
#define UART_TASK_ID 0
|
||||
void uart_task_init();
|
||||
|
||||
void ets_event_poll(void);
|
||||
|
||||
#endif // _INCLUDED_MPHAL_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user