extmod/modos: Factor os.dupterm_notify() function to common extmod code.

esp8266 doesn't need ets task because the notify is now scheduled (see
commits 7d57037906 and
c60caf1995 for relevant history).

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2023-12-14 17:06:56 +11:00
parent 0e706a62b1
commit 395886caa3
8 changed files with 27 additions and 92 deletions

View File

@@ -134,33 +134,6 @@ void MP_FASTCODE(mp_hal_signal_input)(void) {
#endif
}
STATIC void dupterm_task_handler(os_event_t *evt) {
static byte lock;
if (lock) {
return;
}
lock = 1;
while (1) {
int c = mp_os_dupterm_rx_chr();
if (c < 0) {
break;
}
ringbuf_put(&stdin_ringbuf, c);
}
mp_hal_signal_input();
lock = 0;
}
STATIC os_event_t dupterm_evt_queue[4];
void dupterm_task_init() {
system_os_task(dupterm_task_handler, DUPTERM_TASK_ID, dupterm_evt_queue, MP_ARRAY_SIZE(dupterm_evt_queue));
}
void mp_hal_signal_dupterm_input(void) {
system_os_post(DUPTERM_TASK_ID, 0, 0);
}
// this bit is unused in the Xtensa PS register
#define ETS_LOOP_ITER_BIT (12)

View File

@@ -41,8 +41,6 @@ extern const struct _mp_print_t mp_debug_print;
extern ringbuf_t stdin_ringbuf;
// Call this after putting data to stdin_ringbuf
void mp_hal_signal_input(void);
// Call this when data is available in dupterm object
void mp_hal_signal_dupterm_input(void);
// This variable counts how many times the UART is attached to dupterm
extern int uart_attached_to_dupterm;
@@ -65,9 +63,7 @@ void mp_hal_set_interrupt_char(int c);
uint32_t mp_hal_get_cpu_freq(void);
#define UART_TASK_ID 0
#define DUPTERM_TASK_ID 1
void uart_task_init();
void dupterm_task_init();
uint32_t esp_disable_irq(void);
void esp_enable_irq(uint32_t state);

View File

@@ -63,7 +63,6 @@ STATIC void mp_reset(void) {
#endif
pin_init0();
readline_init0();
dupterm_task_init();
// Activate UART(0) on dupterm slot 1 for the REPL
{

View File

@@ -25,16 +25,10 @@
* THE SOFTWARE.
*/
#include <string.h>
// This file is never compiled standalone, it's included directly from
// extmod/modos.c via MICROPY_PY_OS_INCLUDEFILE.
#include "py/objtuple.h"
#include "py/objstr.h"
#include "extmod/misc.h"
#include "extmod/modmachine.h"
#include "extmod/vfs.h"
#include "extmod/vfs_fat.h"
#include "extmod/vfs_lfs.h"
#include "genhdr/mpversion.h"
#include "user_interface.h"
STATIC const char *mp_os_uname_release(void) {
@@ -60,10 +54,3 @@ void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t s
--uart_attached_to_dupterm;
}
}
STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) {
(void)obj_in;
mp_hal_signal_dupterm_input();
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify);