From 008c62318ef9be4f96855f4b1dff22632f3132a1 Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Sun, 17 May 2026 22:58:00 -0700 Subject: [PATCH] examples improvements --- .gitignore | 2 ++ examples/README.md | 2 +- examples/lpc55s28-evk-dma/.cargo/config.toml | 7 ----- examples/lpc55s28-evk-dma/Cargo.toml | 6 ----- examples/lpc55s28-evk-dma/src/main.rs | 28 ++++++++++++-------- examples/lpc55s28-evk/.cargo/config.toml | 7 ----- examples/lpc55s28-evk/Cargo.toml | 6 ----- 7 files changed, 20 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf..f534936 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target +.zed +.gdbinit diff --git a/examples/README.md b/examples/README.md index e11f094..dd30936 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,7 +3,7 @@ Two example backends are provided, both based on the LPCXpresso55S28 demo board, ## LPC55S28 (LPCXpresso55S28) These examples work on the -(LPCXpresso55S28)[https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/lpcxpresso-boards/lpcxpresso55s28-development-board:LPC55S28-EVK] +[LPCXpresso55S28](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/lpcxpresso-boards/lpcxpresso55s28-development-board:LPC55S28-EVK) development board. They use the onboard WM8904 codec, so don't require any additional hardware for audio I/O. diff --git a/examples/lpc55s28-evk-dma/.cargo/config.toml b/examples/lpc55s28-evk-dma/.cargo/config.toml index 48fb7f4..3c2586f 100644 --- a/examples/lpc55s28-evk-dma/.cargo/config.toml +++ b/examples/lpc55s28-evk-dma/.cargo/config.toml @@ -1,10 +1,3 @@ -[target.thumbv8m.main-none-eabi] -rustflags = [ - "-C", "link-arg=-Tlink.x", - "-C", "link-arg=-Tdefmt.x", - "-C", "debug-assertions", -] - [target.thumbv8m.main-none-eabihf] rustflags = [ "-C", "link-arg=-Tlink.x", diff --git a/examples/lpc55s28-evk-dma/Cargo.toml b/examples/lpc55s28-evk-dma/Cargo.toml index 4765b73..5f73b02 100644 --- a/examples/lpc55s28-evk-dma/Cargo.toml +++ b/examples/lpc55s28-evk-dma/Cargo.toml @@ -24,9 +24,3 @@ static_cell = "2.1.1" lpc55-hal = { git = "https://github.com/ktims/lpc55-hal", branch = "main" } usb-device.workspace = true usbd-uac2 = { workspace = true, features = ["defmt"] } - -[profile.release] -opt-level = "z" -lto = true -debug = true -codegen-units = 1 diff --git a/examples/lpc55s28-evk-dma/src/main.rs b/examples/lpc55s28-evk-dma/src/main.rs index d2590b2..000a15b 100644 --- a/examples/lpc55s28-evk-dma/src/main.rs +++ b/examples/lpc55s28-evk-dma/src/main.rs @@ -38,7 +38,7 @@ use pac::interrupt; use static_cell::StaticCell; use usb_device::{ bus::{self}, - device::{StringDescriptors, UsbDeviceBuilder, UsbVidPid}, + device::{StringDescriptors, UsbVidPid}, }; use usbd_uac2::TerminalConfig; use usbd_uac2::{ @@ -53,6 +53,12 @@ mod dma; mod hw; mod wm8904; +// pid.codes test IDs +const USB_VID: u16 = 0x1209; +const USB_PID: u16 = 0x0001; +const USB_MANUFACTURER: &str = "usbd_uac2"; +const USB_PRODUCT: &str = "DMA example device"; + const CODEC_I2C_ADDR: u8 = 0b0011010; const MCLK_FREQ: u32 = 12288000; @@ -199,6 +205,11 @@ impl AudioHandler<' self.running.store(true, Ordering::Relaxed) } } + fn audio_data_tx( + &mut self, + _ep: &usb_device::endpoint::Endpoint<'_, B, usb_device::endpoint::In>, + ) { + } /// Provide rate feedback to the host. P-only is stable and works fine, with /// most hosts. The host can either filter it internally or treat it @@ -229,7 +240,7 @@ impl AudioHandler<' // 0.2% which is a huge clock error let max_allowed_deviation = nominal_v / 500; - let p_term = -(error_permille * nominal_v) / 256000; // this works reasonably well to keep the buffer + let p_term = -(error_permille * nominal_v) / 256000; // this works reasonably well to keep the buffer let i_term = 0; // placeholder let mut v = nominal_v + p_term + i_term; @@ -379,18 +390,13 @@ fn main() -> ! { .with_output_config(TerminalConfig::builder().base_id(2).build()); let mut uac2 = config.build(&usb_bus).unwrap(); - let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x1209, 0xcc1d)) - .composite_with_iads() + let mut usb_dev = usbd_uac2::builder(&usb_bus, UsbVidPid(USB_VID, USB_PID)) .strings(&[StringDescriptors::default() - .manufacturer("Generic") - .product("usbd_uac2 device") - .serial_number("123456789")]) + .manufacturer(USB_MANUFACTURER) + .product(USB_PRODUCT)]) .unwrap() - .max_packet_size_0(64) + .max_packet_size_0(64) // Required to be 64 on HS, allowed on FS .unwrap() - .device_class(0xef) - .device_sub_class(0x02) - .device_protocol(0x01) .build(); defmt::info!("main loop"); diff --git a/examples/lpc55s28-evk/.cargo/config.toml b/examples/lpc55s28-evk/.cargo/config.toml index 48fb7f4..3c2586f 100644 --- a/examples/lpc55s28-evk/.cargo/config.toml +++ b/examples/lpc55s28-evk/.cargo/config.toml @@ -1,10 +1,3 @@ -[target.thumbv8m.main-none-eabi] -rustflags = [ - "-C", "link-arg=-Tlink.x", - "-C", "link-arg=-Tdefmt.x", - "-C", "debug-assertions", -] - [target.thumbv8m.main-none-eabihf] rustflags = [ "-C", "link-arg=-Tlink.x", diff --git a/examples/lpc55s28-evk/Cargo.toml b/examples/lpc55s28-evk/Cargo.toml index d90b2fd..5ad5bba 100644 --- a/examples/lpc55s28-evk/Cargo.toml +++ b/examples/lpc55s28-evk/Cargo.toml @@ -23,9 +23,3 @@ panic-probe = { version = "1.0.0", features = ["print-defmt"] } lpc55-hal = { git = "https://github.com/ktims/lpc55-hal", branch = "main" } usb-device.workspace = true usbd-uac2 = { workspace = true, features = ["defmt"] } - -[profile.release] -opt-level = "z" -lto = true -debug = true -codegen-units = 1