Skip to content

Commit

Permalink
Expose the USB-serial-jtag peripheral (#503)
Browse files Browse the repository at this point in the history
* add BlockingIoDriver to make stdin/out/err calls blocking

* gate sys imports

* use at least enumset 1.1.4 to make EnumSet::empty() a const fn

* add missing trait impl

* fix wrong macro usage

* fix macro

* Remove all VFS code in prep to move it to esp_idf_svc::io::vfs

---------

Co-authored-by: Frederick Vollbrecht <[email protected]>
  • Loading branch information
ivmarkov and Vollbrecht authored Jan 1, 2025
1 parent 21b2ce6 commit 0c912c8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking
- Make the UART config to ESP-IDF C config reusable outside the UART driver (for OpenThread)
- Re-use the SPI config struct of the SPI driver (for OpenThread)
- Add a `usb_serial` peripheral to the `Peripherals` struct for MCUs that do support the USB-serial-jtag peripheral (#503)

### Added
- Docs: Add some docstrings for ADC module. (#455)
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub mod uart;
))]
pub mod ulp;
pub mod units;
#[cfg(esp_idf_soc_usb_serial_jtag_supported)]
pub mod usb_serial;

// This is used to create `embedded_hal` compatible error structs
// that preserve original `EspError`.
Expand Down
6 changes: 6 additions & 0 deletions src/peripherals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ use crate::uart;
esp_idf_comp_ulp_enabled
))]
use crate::ulp;
#[cfg(esp_idf_soc_usb_serial_jtag_supported)]
use crate::usb_serial;

pub struct Peripherals {
pub pins: gpio::Pins,
Expand Down Expand Up @@ -106,6 +108,8 @@ pub struct Peripherals {
any(esp_idf_version_major = "4", esp_idf_version = "5.0")
))]
pub twdt: watchdog::TWDT,
#[cfg(esp_idf_soc_usb_serial_jtag_supported)]
pub usb_serial: usb_serial::USB_SERIAL,
}

static TAKEN: core::sync::atomic::AtomicBool = core::sync::atomic::AtomicBool::new(false);
Expand Down Expand Up @@ -208,6 +212,8 @@ impl Peripherals {
any(esp_idf_version_major = "4", esp_idf_version = "5.0")
))]
twdt: watchdog::TWDT::new(),
#[cfg(esp_idf_soc_usb_serial_jtag_supported)]
usb_serial: usb_serial::USB_SERIAL::new(),
}
}
}
19 changes: 19 additions & 0 deletions src/usb_serial.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![allow(non_camel_case_types)]
//! USB Serial / JTAG peripheral
//!
//! Communication through a virtualized UART-like USB-CDC interface.
//!
//! By default, `println!` and `log!` output will be redirected to it if no UART
//! connection is established to a HOST PC. The peripheral is initialized at startup
//! and is using the ESP console slot 2 by default.
//!
//! ESP console slot 2 cannot be used to read from the HOST, only writing is supported.
//! If reading from the HOST is necessary, reconfigure the ESP console by setting
//! the following into your projects sdkconfig.default file:
//! ```
//! CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
//! ```
// TODO: impl usb_serial driver

crate::impl_peripheral!(USB_SERIAL);

0 comments on commit 0c912c8

Please sign in to comment.