From 3b239cb6de22b7bb8c2d87defb3205294653be7a Mon Sep 17 00:00:00 2001 From: James Munns Date: Sat, 29 Nov 2025 16:07:30 +0100 Subject: Remove Drive/Slew settings for Input pin (#57) * Don't set slew+strength for inputs * Update example --- examples/src/bin/button.rs | 6 ++++-- examples/src/bin/button_async.rs | 5 +++-- examples/src/bin/i2c-scan-blocking.rs | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'examples/src') diff --git a/examples/src/bin/button.rs b/examples/src/bin/button.rs index 2abfe0a9f..943edbb15 100644 --- a/examples/src/bin/button.rs +++ b/examples/src/bin/button.rs @@ -3,7 +3,7 @@ use embassy_executor::Spawner; use embassy_time::Timer; -use hal::gpio::{DriveStrength, Input, Pull, SlewRate}; +use hal::gpio::{Input, Pull}; use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; #[embassy_executor::main] @@ -12,7 +12,9 @@ async fn main(_spawner: Spawner) { defmt::info!("Button example"); - let monitor = Input::new(p.P1_7, Pull::Disabled, DriveStrength::Normal, SlewRate::Slow); + // This button is labeled "WAKEUP" on the FRDM-MCXA276 + // The board already has a 10K pullup + let monitor = Input::new(p.P1_7, Pull::Disabled); loop { defmt::info!("Pin level is {:?}", monitor.get_level()); diff --git a/examples/src/bin/button_async.rs b/examples/src/bin/button_async.rs index 1ecec2e48..6cc7b62cd 100644 --- a/examples/src/bin/button_async.rs +++ b/examples/src/bin/button_async.rs @@ -3,7 +3,7 @@ use embassy_executor::Spawner; use embassy_time::Timer; -use hal::gpio::{DriveStrength, Input, Pull, SlewRate}; +use hal::gpio::{Input, Pull}; use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; #[embassy_executor::main] @@ -13,7 +13,8 @@ async fn main(_spawner: Spawner) { defmt::info!("GPIO interrupt example"); // This button is labeled "WAKEUP" on the FRDM-MCXA276 - let mut pin = Input::new(p.P1_7, Pull::Up, DriveStrength::Normal, SlewRate::Fast); + // The board already has a 10K pullup + let mut pin = Input::new(p.P1_7, Pull::Disabled); let mut press_count = 0u32; diff --git a/examples/src/bin/i2c-scan-blocking.rs b/examples/src/bin/i2c-scan-blocking.rs index 72f9d09e0..4e203597b 100644 --- a/examples/src/bin/i2c-scan-blocking.rs +++ b/examples/src/bin/i2c-scan-blocking.rs @@ -2,7 +2,7 @@ #![no_main] use embassy_executor::Spawner; -use embassy_mcxa::gpio::{DriveStrength, Pull, SlewRate}; +use embassy_mcxa::gpio::Pull; use embassy_mcxa::Input; use embassy_time::Timer; use hal::clocks::config::Div8; @@ -25,7 +25,7 @@ async fn main(_spawner: Spawner) { // Note: P0_2 is connected to P1_8 on the FRDM_MCXA276 via a resistor, and // defaults to SWO on the debug peripheral. Explicitly make it a high-z // input. - let _pin = Input::new(p.P0_2, Pull::Disabled, DriveStrength::Normal, SlewRate::Slow); + let _pin = Input::new(p.P0_2, Pull::Disabled); let mut i2c = I2c::new_blocking(p.LPI2C2, p.P1_9, p.P1_8, config).unwrap(); for addr in 0x01..=0x7f { -- cgit From 717346f21a4cf4993c2a1f046e26b6bf647d89cb Mon Sep 17 00:00:00 2001 From: JanKomarekNXP <151725448+JanKomarekNXP@users.noreply.github.com> Date: Mon, 1 Dec 2025 18:07:58 +0100 Subject: Refactor LPUART driver constructors (#51) * Refactor LPUART driver constructors - Add new_with_rtscts(), new_with_rts(), new_with_cts() methods - Store RTS/CTS pins in TX/RX structs - Remove enable_tx, enable_rx, enable_rx_rts, enable_tx_cts config fields - Fix typo: msb_firs -> msb_first - Fix write_byte() return type to Result<()> * Update hello example for LPUART driver changes * Refactor buffered LPUART initialization logic - Split new_inner() into init_common() and separate helpers for full-duplex, TX-only, and RX-only - Replace assert!() with proper Error::InvalidArgument returns for empty buffers - Simplify constructor implementations by removing expect() calls --- examples/src/bin/hello.rs | 14 ++++++++------ examples/src/bin/lpuart_buffered.rs | 2 -- examples/src/bin/lpuart_polling.rs | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'examples/src') diff --git a/examples/src/bin/hello.rs b/examples/src/bin/hello.rs index f426d1898..e371d9413 100644 --- a/examples/src/bin/hello.rs +++ b/examples/src/bin/hello.rs @@ -2,27 +2,29 @@ #![no_main] use embassy_executor::Spawner; +use embassy_mcxa::clocks::config::Div8; use hal::lpuart::{Blocking, Config, Lpuart}; use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; /// Simple helper to write a byte as hex to UART fn write_hex_byte(uart: &mut Lpuart<'_, Blocking>, byte: u8) { const HEX_DIGITS: &[u8] = b"0123456789ABCDEF"; - uart.write_byte(HEX_DIGITS[(byte >> 4) as usize]); - uart.write_byte(HEX_DIGITS[(byte & 0xF) as usize]); + let _ = uart.write_byte(HEX_DIGITS[(byte >> 4) as usize]); + let _ = uart.write_byte(HEX_DIGITS[(byte & 0xF) as usize]); } #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = hal::init(hal::config::Config::default()); + let mut cfg = hal::config::Config::default(); + cfg.clock_cfg.sirc.fro_12m_enabled = true; + cfg.clock_cfg.sirc.fro_lf_div = Some(Div8::no_div()); + let p = hal::init(cfg); defmt::info!("boot"); // Create UART configuration let config = Config { baudrate_bps: 115_200, - enable_tx: true, - enable_rx: true, ..Default::default() }; @@ -97,7 +99,7 @@ async fn main(_spawner: Spawner) { // Regular character buffer[buf_idx] = byte; buf_idx += 1; - uart.write_byte(byte); + let _ = uart.write_byte(byte); } } } diff --git a/examples/src/bin/lpuart_buffered.rs b/examples/src/bin/lpuart_buffered.rs index 7f77d557d..420589d00 100644 --- a/examples/src/bin/lpuart_buffered.rs +++ b/examples/src/bin/lpuart_buffered.rs @@ -27,8 +27,6 @@ async fn main(_spawner: Spawner) { // UART configuration (enable both TX and RX) let config = Config { baudrate_bps: 115_200, - enable_tx: true, - enable_rx: true, rx_fifo_watermark: 0, tx_fifo_watermark: 0, ..Default::default() diff --git a/examples/src/bin/lpuart_polling.rs b/examples/src/bin/lpuart_polling.rs index 9cea418cc..b80668834 100644 --- a/examples/src/bin/lpuart_polling.rs +++ b/examples/src/bin/lpuart_polling.rs @@ -19,8 +19,6 @@ async fn main(_spawner: Spawner) { // Create UART configuration let config = Config { baudrate_bps: 115_200, - enable_tx: true, - enable_rx: true, ..Default::default() }; -- cgit