Skip to content

Commit

Permalink
renesas-ra/mphalport: Use dupterm for USBD_CDC repl connection.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
pi-anl committed Oct 27, 2024
1 parent 2fb8b08 commit a9099b3
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions ports/renesas-ra/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,22 @@ uint8_t cdc_itf_pending; // keep track of cdc interfaces which need attention to

uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
uintptr_t ret = 0;
#if MICROPY_HW_USB_CDC
ret |= mp_usbd_cdc_poll_interfaces(poll_flags);
#endif
#if MICROPY_HW_ENABLE_UART_REPL
if (poll_flags & MP_STREAM_POLL_WR) {
ret |= MP_STREAM_POLL_WR;
}
#endif
#if MICROPY_PY_OS_DUPTERM
ret |= mp_os_dupterm_poll(poll_flags);
#elif MICROPY_HW_USB_CDC
ret |= mp_usbd_cdc_poll_interfaces(poll_flags);
#endif
return ret;
}

// Receive single character
int mp_hal_stdin_rx_chr(void) {
for (;;) {
#if MICROPY_HW_USB_CDC
mp_usbd_cdc_poll_interfaces(0);
#endif

#if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
flash_cache_commit();
#endif
Expand All @@ -103,6 +98,8 @@ int mp_hal_stdin_rx_chr(void) {
if (dupterm_c >= 0) {
return dupterm_c;
}
#elif MICROPY_HW_USB_CDC
mp_usbd_cdc_poll_interfaces(0);
#endif
MICROPY_EVENT_POLL_HOOK
}
Expand All @@ -119,20 +116,18 @@ mp_uint_t mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
}
#endif

#if MICROPY_HW_USB_CDC
mp_uint_t cdc_res = mp_usbd_cdc_tx_strn(str, len);
if (cdc_res > 0) {
did_write = true;
ret = MIN(cdc_res, ret);
}
#endif

#if MICROPY_PY_OS_DUPTERM
int dupterm_res = mp_os_dupterm_tx_strn(str, len);
if (dupterm_res >= 0) {
did_write = true;
ret = MIN((mp_uint_t)dupterm_res, ret);
}
#elif MICROPY_HW_USB_CDC
mp_uint_t cdc_res = mp_usbd_cdc_tx_strn(str, len);
if (cdc_res > 0) {
did_write = true;
ret = MIN(cdc_res, ret);
}
#endif

return did_write ? ret : 0;
Expand Down

0 comments on commit a9099b3

Please sign in to comment.