From be17bfa9f5efa3d55b7b7a17ef28c6372cda7b2c Mon Sep 17 00:00:00 2001 From: Juraj Sadel Date: Wed, 22 May 2024 13:33:34 +0200 Subject: [PATCH 1/2] GPIO: Use Level enum instead of plain bool in constructors --- esp-hal/src/etm.rs | 4 +-- esp-hal/src/gpio/etm.rs | 14 ++++----- esp-hal/src/gpio/mod.rs | 16 +++++----- esp-hal/src/rmt.rs | 2 +- esp-hal/src/soc/esp32c6/lp_core.rs | 31 +++---------------- examples/src/bin/blinky.rs | 4 +-- examples/src/bin/blinky_erased_pins.rs | 8 ++--- examples/src/bin/embassy_multicore.rs | 4 +-- .../src/bin/embassy_multicore_interrupt.rs | 4 +-- examples/src/bin/embassy_rmt_rx.rs | 4 +-- examples/src/bin/etm_blinky_systimer.rs | 3 +- examples/src/bin/etm_gpio.rs | 3 +- examples/src/bin/gpio_interrupt.rs | 4 +-- examples/src/bin/lcd_i8080.rs | 6 ++-- examples/src/bin/spi_eh1_device_loopback.rs | 13 ++++---- examples/src/bin/spi_slave_dma.rs | 8 ++--- hil-test/tests/gpio.rs | 8 ++--- 17 files changed, 59 insertions(+), 77 deletions(-) diff --git a/esp-hal/src/etm.rs b/esp-hal/src/etm.rs index b148067bdc2..fac9ed75296 100644 --- a/esp-hal/src/etm.rs +++ b/esp-hal/src/etm.rs @@ -23,8 +23,8 @@ //! ## Example //! ```no_run //! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! let mut led = io.pins.gpio1.into_push_pull_output(); -//! let button = io.pins.gpio9.into_pull_down_input(); +//! let mut led = io.pins.gpio1; +//! let button = io.pins.gpio9; //! //! // setup ETM //! let gpio_ext = GpioEtmChannels::new(peripherals.GPIO_SD); diff --git a/esp-hal/src/gpio/etm.rs b/esp-hal/src/gpio/etm.rs index 36f7dff4a87..159c192c6d4 100644 --- a/esp-hal/src/gpio/etm.rs +++ b/esp-hal/src/gpio/etm.rs @@ -28,7 +28,7 @@ //! GpioEtmOutputConfig { //! open_drain: false, //! pull: Pull::None, -//! initial_state: false, +//! initial_state: Level::Low, //! }, //! ); //! let button_event = gpio_ext @@ -37,7 +37,7 @@ //! ``` use crate::{ - gpio::Pull, + gpio::{Level, Pull}, peripheral::{Peripheral, PeripheralRef}, private, }; @@ -252,7 +252,7 @@ pub struct GpioEtmOutputConfig { /// Only used when open-drain pub pull: Pull, /// Initial pin state - pub initial_state: bool, + pub initial_state: Level, } impl Default for GpioEtmOutputConfig { @@ -260,7 +260,7 @@ impl Default for GpioEtmOutputConfig { Self { open_drain: false, pull: Pull::None, - initial_state: false, + initial_state: Level::Low, } } } @@ -285,7 +285,7 @@ impl GpioEtmTaskChannel { { crate::into_ref!(pin); - pin.set_output_high(pin_config.initial_state, private::Internal); + pin.set_output_high(pin_config.initial_state.into(), private::Internal); if pin_config.open_drain { pin.internal_pull_down(pin_config.pull == Pull::Down, private::Internal); pin.internal_pull_up(pin_config.pull == Pull::Up, private::Internal); @@ -309,7 +309,7 @@ impl GpioEtmTaskChannel { { crate::into_ref!(pin); - pin.set_output_high(pin_config.initial_state, private::Internal); + pin.set_output_high(pin_config.initial_state.into(), private::Internal); if pin_config.open_drain { pin.internal_pull_down(pin_config.pull == Pull::Down, private::Internal); pin.internal_pull_up(pin_config.pull == Pull::Up, private::Internal); @@ -333,7 +333,7 @@ impl GpioEtmTaskChannel { { crate::into_ref!(pin); - pin.set_output_high(pin_config.initial_state, private::Internal); + pin.set_output_high(pin_config.initial_state.into(), private::Internal); if pin_config.open_drain { pin.internal_pull_down(pin_config.pull == Pull::Down, private::Internal); pin.internal_pull_up(pin_config.pull == Pull::Up, private::Internal); diff --git a/esp-hal/src/gpio/mod.rs b/esp-hal/src/gpio/mod.rs index 0a873f031b4..517edc9721e 100644 --- a/esp-hal/src/gpio/mod.rs +++ b/esp-hal/src/gpio/mod.rs @@ -1557,10 +1557,10 @@ where { /// Create GPIO output driver for a [GpioPin] with the provided level #[inline] - pub fn new(pin: impl crate::peripheral::Peripheral

+ 'd, initial_output: bool) -> Self { + pub fn new(pin: impl crate::peripheral::Peripheral

+ 'd, initial_output: Level) -> Self { crate::into_ref!(pin); - pin.set_output_high(initial_output, private::Internal); + pin.set_output_high(initial_output.into(), private::Internal); pin.set_to_push_pull_output(private::Internal); Self { pin } @@ -1683,11 +1683,11 @@ where #[inline] pub fn new( pin: impl crate::peripheral::Peripheral

+ 'd, - initial_output: bool, + initial_output: Level, pull: Pull, ) -> Self { crate::into_ref!(pin); - pin.set_output_high(initial_output, private::Internal); + pin.set_output_high(initial_output.into(), private::Internal); pin.set_to_open_drain_output(private::Internal); pin.internal_pull_down(pull == Pull::Down, private::Internal); pin.internal_pull_up(pull == Pull::Up, private::Internal); @@ -1785,11 +1785,11 @@ impl<'d> AnyOutput<'d> { #[inline] pub fn new( pin: impl crate::peripheral::Peripheral

+ 'd, - initial_output: bool, + initial_output: Level, ) -> Self { crate::into_ref!(pin); - pin.set_output_high(initial_output, private::Internal); + pin.set_output_high(initial_output.into(), private::Internal); pin.set_to_push_pull_output(private::Internal); let pin = pin.erased_pin(private::Internal); @@ -1912,11 +1912,11 @@ impl<'d> AnyOutputOpenDrain<'d> { #[inline] pub fn new( pin: impl crate::peripheral::Peripheral

+ 'd, - initial_output: bool, + initial_output: Level, pull: Pull, ) -> Self { crate::into_ref!(pin); - pin.set_output_high(initial_output, private::Internal); + pin.set_output_high(initial_output.into(), private::Internal); pin.internal_pull_down(pull == Pull::Down, private::Internal); pin.internal_pull_up(pull == Pull::Up, private::Internal); pin.set_to_open_drain_output(private::Internal); diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs index 419f182489e..6834acf80b5 100644 --- a/esp-hal/src/rmt.rs +++ b/esp-hal/src/rmt.rs @@ -45,7 +45,7 @@ //! let mut channel = rmt //! .channel0 //! .configure( -//! io.pins.gpio1.into_push_pull_output(), +//! io.pins.gpio1, //! TxChannelConfig { //! clk_divider: 1, //! idle_output_level: false, diff --git a/esp-hal/src/soc/esp32c6/lp_core.rs b/esp-hal/src/soc/esp32c6/lp_core.rs index 47360a16e80..b1ab8226e32 100644 --- a/esp-hal/src/soc/esp32c6/lp_core.rs +++ b/esp-hal/src/soc/esp32c6/lp_core.rs @@ -15,43 +15,22 @@ //! //! ## Example //! ```no_run -//! const CODE: &[u8] = &[ -//! 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, -//! 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, -//! 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, -//! 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, -//! 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, -//! 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, -//! 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, -//! 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, -//! 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x05, -//! 0x04, 0x85, 0x45, 0x23, 0x00, 0xb5, 0x00, 0xb7, 0x26, 0x0b, 0x60, 0xa1, 0x06, 0x37, 0x26, -//! 0x0b, 0x60, 0x11, 0x06, 0x09, 0x47, 0x18, 0xc2, 0xb7, 0x47, 0x0f, 0x00, 0x93, 0x87, 0x07, -//! 0x24, 0xfd, 0x17, 0xfd, 0xff, 0x85, 0x05, 0x23, 0x00, 0xb5, 0x00, 0x98, 0xc2, 0xb7, 0x47, -//! 0x0f, 0x00, 0x93, 0x87, 0x07, 0x24, 0xfd, 0x17, 0xfd, 0xff, 0xf9, 0xbf, 0x00, 0x00, 0x00, -//! 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -//! ]; -//! //! // configure GPIO 1 as LP output pin -//! let mut lp_pin = io.pins.gpio1.into_low_power(); -//! lp_pin.output_enable(true); +//! let lp_pin = LowPowerOutput::new(io.pins.gpio1); //! //! let mut lp_core = esp_hal::lp_core::LpCore::new(peripherals.LP_CORE); //! lp_core.stop(); //! println!("lp core stopped"); //! -//! // copy code to LP ram -//! let lp_ram = 0x5000_0000 as *mut u8; -//! unsafe { -//! core::ptr::copy_nonoverlapping(CODE as *const _ as *const u8, lp_ram, CODE.len()); -//! } -//! println!("copied code (len {})", CODE.len()); +//! // load code to LP core +//! let lp_core_code = +//! load_lp_code!("../esp-lp-hal/target/riscv32imac-unknown-none-elf/release/examples/blinky"); //! //! // start LP core //! lp_core.run(lp_core::LpCoreWakeupSource::HpCpu); //! println!("lpcore run"); //! -//! let data = (0x500000c0) as *mut u32; +//! let data = (0x5000_2000) as *mut u32; //! loop { //! print!("Current {:x} \u{000d}", unsafe { //! data.read_volatile() diff --git a/examples/src/bin/blinky.rs b/examples/src/bin/blinky.rs index 9b04ae96f6e..7911d86585d 100644 --- a/examples/src/bin/blinky.rs +++ b/examples/src/bin/blinky.rs @@ -11,7 +11,7 @@ use esp_backtrace as _; use esp_hal::{ clock::ClockControl, delay::Delay, - gpio::{Io, Output}, + gpio::{Io, Level, Output}, peripherals::Peripherals, prelude::*, system::SystemControl, @@ -25,7 +25,7 @@ fn main() -> ! { // Set GPIO0 as an output, and set its state high initially. let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let mut led = Output::new(io.pins.gpio0, true); + let mut led = Output::new(io.pins.gpio0, Level::High); // Initialize the Delay peripheral, and use it to toggle the LED state in a // loop. diff --git a/examples/src/bin/blinky_erased_pins.rs b/examples/src/bin/blinky_erased_pins.rs index f63aad287a1..8a9b377d29c 100644 --- a/examples/src/bin/blinky_erased_pins.rs +++ b/examples/src/bin/blinky_erased_pins.rs @@ -14,7 +14,7 @@ use esp_backtrace as _; use esp_hal::{ clock::ClockControl, delay::Delay, - gpio::{AnyInput, AnyOutput, Io, Pull}, + gpio::{AnyInput, AnyOutput, Io, Level, Pull}, peripherals::Peripherals, prelude::*, system::SystemControl, @@ -29,9 +29,9 @@ fn main() -> ! { let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); // Set LED GPIOs as an output: - let led1 = AnyOutput::new(io.pins.gpio2, false); - let led2 = AnyOutput::new(io.pins.gpio4, false); - let led3 = AnyOutput::new(io.pins.gpio5, false); + let led1 = AnyOutput::new(io.pins.gpio2, Level::Low); + let led2 = AnyOutput::new(io.pins.gpio4, Level::Low); + let led3 = AnyOutput::new(io.pins.gpio5, Level::Low); // Use boot button as an input: #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] diff --git a/examples/src/bin/embassy_multicore.rs b/examples/src/bin/embassy_multicore.rs index 96079f401f8..a0519ad96a5 100644 --- a/examples/src/bin/embassy_multicore.rs +++ b/examples/src/bin/embassy_multicore.rs @@ -20,7 +20,7 @@ use esp_hal::{ cpu_control::{CpuControl, Stack}, embassy::{self, executor::Executor}, get_core, - gpio::{AnyOutput, Io}, + gpio::{AnyOutput, Io, Level}, peripherals::Peripherals, prelude::*, system::SystemControl, @@ -66,7 +66,7 @@ async fn main(_spawner: Spawner) { static LED_CTRL: StaticCell> = StaticCell::new(); let led_ctrl_signal = &*LED_CTRL.init(Signal::new()); - let led = AnyOutput::new(io.pins.gpio0, false); + let led = AnyOutput::new(io.pins.gpio0, Level::Low); let _guard = cpu_control .start_app_core(unsafe { &mut *addr_of_mut!(APP_CORE_STACK) }, move || { diff --git a/examples/src/bin/embassy_multicore_interrupt.rs b/examples/src/bin/embassy_multicore_interrupt.rs index 5dccb071ff0..2d610fffafa 100644 --- a/examples/src/bin/embassy_multicore_interrupt.rs +++ b/examples/src/bin/embassy_multicore_interrupt.rs @@ -19,7 +19,7 @@ use esp_hal::{ cpu_control::{CpuControl, Stack}, embassy::{self, executor::InterruptExecutor}, get_core, - gpio::{AnyOutput, Io}, + gpio::{AnyOutput, Io, Level}, interrupt::Priority, peripherals::Peripherals, prelude::*, @@ -85,7 +85,7 @@ fn main() -> ! { static LED_CTRL: StaticCell> = StaticCell::new(); let led_ctrl_signal = &*LED_CTRL.init(Signal::new()); - let led = AnyOutput::new(io.pins.gpio0, false); + let led = AnyOutput::new(io.pins.gpio0, Level::Low); static EXECUTOR_CORE_1: StaticCell> = StaticCell::new(); let executor_core1 = diff --git a/examples/src/bin/embassy_rmt_rx.rs b/examples/src/bin/embassy_rmt_rx.rs index 4e7da6acc7c..356db94c430 100644 --- a/examples/src/bin/embassy_rmt_rx.rs +++ b/examples/src/bin/embassy_rmt_rx.rs @@ -13,7 +13,7 @@ use esp_backtrace as _; use esp_hal::{ clock::ClockControl, embassy::{self}, - gpio::{Gpio5, Io, Output}, + gpio::{Gpio5, Io, Level, Output}, peripherals::Peripherals, prelude::*, rmt::{asynch::RxChannelAsync, PulseCode, Rmt, RxChannelConfig, RxChannelCreatorAsync}, @@ -75,7 +75,7 @@ async fn main(spawner: Spawner) { } spawner - .spawn(signal_task(Output::new(io.pins.gpio5, false))) + .spawn(signal_task(Output::new(io.pins.gpio5, Level::Low))) .unwrap(); let mut data = [PulseCode { diff --git a/examples/src/bin/etm_blinky_systimer.rs b/examples/src/bin/etm_blinky_systimer.rs index 959c2da2832..b0fde6aefaa 100644 --- a/examples/src/bin/etm_blinky_systimer.rs +++ b/examples/src/bin/etm_blinky_systimer.rs @@ -11,6 +11,7 @@ use esp_hal::{ gpio::{ etm::{GpioEtmChannels, GpioEtmOutputConfig}, Io, + Level, Pull, }, peripherals::Peripherals, @@ -37,7 +38,7 @@ fn main() -> ! { GpioEtmOutputConfig { open_drain: false, pull: Pull::None, - initial_state: true, + initial_state: Level::High, }, ); diff --git a/examples/src/bin/etm_gpio.rs b/examples/src/bin/etm_gpio.rs index a966e6e956c..e8db8bb7b44 100644 --- a/examples/src/bin/etm_gpio.rs +++ b/examples/src/bin/etm_gpio.rs @@ -11,6 +11,7 @@ use esp_hal::{ gpio::{ etm::{GpioEtmChannels, GpioEtmInputConfig, GpioEtmOutputConfig}, Io, + Level, Pull, }, peripherals::Peripherals, @@ -34,7 +35,7 @@ fn main() -> ! { GpioEtmOutputConfig { open_drain: false, pull: Pull::None, - initial_state: false, + initial_state: Level::Low, }, ); let button_event = gpio_ext diff --git a/examples/src/bin/gpio_interrupt.rs b/examples/src/bin/gpio_interrupt.rs index ddbe03e46d8..b98c5aab10b 100644 --- a/examples/src/bin/gpio_interrupt.rs +++ b/examples/src/bin/gpio_interrupt.rs @@ -15,7 +15,7 @@ use esp_backtrace as _; use esp_hal::{ clock::ClockControl, delay::Delay, - gpio::{self, Event, Input, Io, Output, Pull}, + gpio::{self, Event, Input, Io, Level, Output, Pull}, macros::ram, peripherals::Peripherals, prelude::*, @@ -36,7 +36,7 @@ fn main() -> ! { // Set GPIO2 as an output, and set its state high initially. let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX); io.set_interrupt_handler(handler); - let mut led = Output::new(io.pins.gpio2, false); + let mut led = Output::new(io.pins.gpio2, Level::Low); #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] let button = io.pins.gpio0; diff --git a/examples/src/bin/lcd_i8080.rs b/examples/src/bin/lcd_i8080.rs index 509d8358d79..fca40210d93 100644 --- a/examples/src/bin/lcd_i8080.rs +++ b/examples/src/bin/lcd_i8080.rs @@ -28,7 +28,7 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority}, dma_buffers, - gpio::{Io, Output}, + gpio::{Io, Level, Output}, lcd_cam::{ lcd::i8080::{Config, TxEightBits, I8080}, LcdCam, @@ -67,8 +67,8 @@ fn main() -> ! { let delay = Delay::new(&clocks); - let mut backlight = Output::new(lcd_backlight, false); - let mut reset = Output::new(lcd_reset, false); + let mut backlight = Output::new(lcd_backlight, Level::Low); + let mut reset = Output::new(lcd_reset, Level::Low); let tx_pins = TxEightBits::new( io.pins.gpio9, diff --git a/examples/src/bin/spi_eh1_device_loopback.rs b/examples/src/bin/spi_eh1_device_loopback.rs index 26c4496dec1..f590ecd709f 100644 --- a/examples/src/bin/spi_eh1_device_loopback.rs +++ b/examples/src/bin/spi_eh1_device_loopback.rs @@ -37,7 +37,7 @@ use esp_backtrace as _; use esp_hal::{ clock::ClockControl, delay::Delay, - gpio::{self, Io, Output}, + gpio::{self, Io, Level, Output}, peripherals::Peripherals, prelude::*, spi::{master::Spi, SpiMode}, @@ -63,19 +63,20 @@ fn main() -> ! { gpio::NO_PIN, ); let spi_bus = RefCell::new(spi_bus); - let mut spi_device_1 = RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio5, false)); + let mut spi_device_1 = + RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio5, Level::Low)); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { let mut spi_device_2 = - RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio13, false)); + RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio13, Level::Low)); let mut spi_device_3 = - RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio14,false)); + RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio14, Level::Low)); } else { let mut spi_device_2 = - RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio6,false)); + RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio6, Level::Low)); let mut spi_device_3 = - RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio7, false)); + RefCellDevice::new_no_delay(&spi_bus, Output::new(io.pins.gpio7, Level::Low)); } } diff --git a/examples/src/bin/spi_slave_dma.rs b/examples/src/bin/spi_slave_dma.rs index 32b00550188..13c57c4e4d9 100644 --- a/examples/src/bin/spi_slave_dma.rs +++ b/examples/src/bin/spi_slave_dma.rs @@ -34,7 +34,7 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority}, dma_buffers, - gpio::{Input, Io, Output, Pull}, + gpio::{Input, Io, Level, Output, Pull}, peripherals::Peripherals, prelude::*, spi::{ @@ -53,13 +53,13 @@ fn main() -> ! { let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); let slave_sclk = io.pins.gpio0; - let mut master_sclk = Output::new(io.pins.gpio4, false); + let mut master_sclk = Output::new(io.pins.gpio4, Level::Low); let slave_miso = io.pins.gpio1; let master_miso = Input::new(io.pins.gpio5, Pull::None); let slave_mosi = io.pins.gpio2; - let mut master_mosi = Output::new(io.pins.gpio8, false); + let mut master_mosi = Output::new(io.pins.gpio8, Level::Low); let slave_cs = io.pins.gpio3; - let mut master_cs = Output::new(io.pins.gpio9, false); + let mut master_cs = Output::new(io.pins.gpio9, Level::Low); master_cs.set_high(); master_sclk.set_low(); master_mosi.set_low(); diff --git a/hil-test/tests/gpio.rs b/hil-test/tests/gpio.rs index 3f356c09ffb..87da6e82011 100644 --- a/hil-test/tests/gpio.rs +++ b/hil-test/tests/gpio.rs @@ -18,7 +18,7 @@ use esp_hal::{ clock::ClockControl, delay::Delay, embassy, - gpio::{Gpio2, Gpio4, GpioPin, Input, Io, Output, Pull}, + gpio::{Gpio2, Gpio4, GpioPin, Input, Io, Level, Output, Pull}, macros::handler, peripherals::Peripherals, system::SystemControl, @@ -50,7 +50,7 @@ impl<'d> Context<'d> { Context { io2: Input::new(io.pins.gpio2, Pull::Down), - io4: Output::new(io.pins.gpio4, false), + io4: Output::new(io.pins.gpio4, Level::Low), delay, } } @@ -184,8 +184,8 @@ mod tests { #[test] fn test_gpio_od(ctx: Context<'static>) { - let mut io2 = OutputOpenDrain::new(unsafe { GpioPin::<2>::steal() }, true, Pull::Up); - let mut io4 = OutputOpenDrain::new(unsafe { GpioPin::<4>::steal() }, true, Pull::Up); + let mut io2 = OutputOpenDrain::new(unsafe { GpioPin::<2>::steal() }, Level::High, Pull::Up); + let mut io4 = OutputOpenDrain::new(unsafe { GpioPin::<4>::steal() }, Level::High, Pull::Up); ctx.delay.delay_millis(1); From 0c0f65f4e7182fe0098d1978ae885e19621de018 Mon Sep 17 00:00:00 2001 From: Juraj Sadel Date: Wed, 22 May 2024 14:23:58 +0200 Subject: [PATCH 2/2] changelog --- esp-hal/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 969cd6d6273..7ba7be5cfec 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refactoring of GPIO module, have drivers for Input,Output,OutputOpenDrain, all drivers setup their GPIOs correctly (#1542) - DMA transactions are now found in the `dma` module (#1550) - Remove unnecessary generics from PARL_IO driver (#1545) +- Use `Level enum` in GPIO constructors instead of plain bools (#1574) ### Removed