diff options
| author | Dan Halbert <halbert@halwitz.org> | 2021-02-11 18:50:02 -0500 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2021-02-11 18:50:02 -0500 |
| commit | f0564b49862eaef0b9752b62d80ef00e3e12a3ee (patch) | |
| tree | 79a48a30955bdc7ae4e1971135809a0593130417 /supervisor/shared/serial.c | |
| parent | 1b7f3d11e73be5cb0f7a97a528fedad87624b97f (diff) | |
| parent | 206109763f3d8b8dc92a5f5bf1bfabb49ce9c7b7 (diff) | |
merge from upstream; complicated webusb merge
Diffstat (limited to 'supervisor/shared/serial.c')
| -rw-r--r-- | supervisor/shared/serial.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 6199af379..40151cbf6 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -47,6 +47,10 @@ busio_uart_obj_t debug_uart; byte buf_array[64]; #endif +#if CIRCUITPY_USB_VENDOR +bool tud_vendor_connected(void); +#endif + void serial_early_init(void) { #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) debug_uart.base.type = &busio_uart_type; @@ -66,6 +70,12 @@ void serial_init(void) { } bool serial_connected(void) { +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected()) { + return true; + } +#endif + #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) return true; #else @@ -74,6 +84,14 @@ bool serial_connected(void) { } char serial_read(void) { +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected() && tud_vendor_available() > 0) { + char tiny_buffer; + tud_vendor_read(&tiny_buffer, 1); + return tiny_buffer; + } +#endif + #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) if (tud_cdc_connected() && tud_cdc_available() > 0) { return (char) tud_cdc_read_char(); @@ -88,6 +106,12 @@ char serial_read(void) { } bool serial_bytes_available(void) { +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected() && tud_vendor_available() > 0) { + return true; + } +#endif + #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) return common_hal_busio_uart_rx_characters_available(&debug_uart) || (tud_cdc_available() > 0); #else @@ -103,6 +127,12 @@ void serial_write_substring(const char* text, uint32_t length) { common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode); #endif +#if CIRCUITPY_USB_VENDOR + if (tud_vendor_connected()) { + tud_vendor_write(text, length); + } +#endif + uint32_t count = 0; while (count < length && tud_cdc_connected()) { count += tud_cdc_write(text + count, length - count); |
