diff --git a/CHANGELOG.md b/CHANGELOG.md index 46b1f4570f2..31f51746aaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add GPIO (output) and delay functionality to `esp32c6-lp-hal` (#715) - Implement RTCIO pullup, pulldown and hold control for Xtensa MCUs (#684) - Add GPIO input support and implement additional `embedded-hal` output traits for the C6's LP core [#720] +- Implement `ufmt_write::uWrite` trait for USB Serial JTAG (#751) ### Changed diff --git a/esp-hal-common/src/usb_serial_jtag.rs b/esp-hal-common/src/usb_serial_jtag.rs index 0e4e494eaae..ff4cddf0c8d 100644 --- a/esp-hal-common/src/usb_serial_jtag.rs +++ b/esp-hal-common/src/usb_serial_jtag.rs @@ -240,6 +240,25 @@ impl core::fmt::Write for UsbSerialJtag<'_> { } } +#[cfg(feature = "ufmt")] +impl ufmt_write::uWrite for UsbSerialJtag<'_> { + type Error = Error; + + #[inline] + fn write_str(&mut self, s: &str) -> Result<(), Self::Error> { + self.write_bytes(s.as_bytes())?; + Ok(()) + } + + #[inline] + fn write_char(&mut self, ch: char) -> Result<(), Self::Error> { + let mut buffer = [0u8; 4]; + self.write_bytes(ch.encode_utf8(&mut buffer).as_bytes())?; + + Ok(()) + } +} + impl embedded_hal::serial::Read for UsbSerialJtag<'_> { type Error = Error;