mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 16:30:22 +00:00
[uart_mux] New component to share a UART between a CDC-ACM bridge and local consumers (#19066)
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
co-authored by
Claude Fable 5.1
J. Nick Koston
parent
ec1d8fa953
commit
d824a32ef1
@@ -0,0 +1,44 @@
|
||||
tinyusb:
|
||||
id: tinyusb_test
|
||||
on_mount:
|
||||
- uart_mux.select_bridge: mux_0
|
||||
on_unmount:
|
||||
- uart_mux.select_local: mux_0
|
||||
usb_manufacturer_str: ESPHomeTestManufacturer
|
||||
usb_product_id: 0x1234
|
||||
usb_product_str: ESPHomeTestProduct
|
||||
usb_vendor_id: 0x2345
|
||||
|
||||
uart:
|
||||
- id: uart_0
|
||||
tx_pin: 14
|
||||
rx_pin: 13
|
||||
baud_rate: 115200
|
||||
|
||||
usb_cdc_acm:
|
||||
interfaces:
|
||||
- id: cdc_acm_1
|
||||
|
||||
bridge:
|
||||
- platform: cdc_acm_uart
|
||||
id: bridge_0
|
||||
uart_id: uart_0
|
||||
usb_cdc_acm_id: cdc_acm_1
|
||||
|
||||
uart_mux:
|
||||
- id: mux_0
|
||||
bridge_id: bridge_0
|
||||
initial_route: local
|
||||
|
||||
interval:
|
||||
- interval: 60s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
uart_mux.is_local: mux_0
|
||||
then:
|
||||
- lambda: |-
|
||||
uint8_t byte;
|
||||
if (id(mux_0).available() && id(mux_0).read_byte(&byte)) {
|
||||
id(mux_0).write_byte(byte);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
uart_mux: !include common.yaml
|
||||
@@ -0,0 +1,7 @@
|
||||
# ESP32-S2 has no USB_SERIAL_JTAG, so the logger defaults to USB_CDC, which shares
|
||||
# the USB OTG peripheral with tinyusb. Use a hardware UART for logging instead.
|
||||
logger:
|
||||
hardware_uart: UART0
|
||||
|
||||
packages:
|
||||
uart_mux: !include common.yaml
|
||||
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
uart_mux: !include common.yaml
|
||||
Reference in New Issue
Block a user