From e811152c6815765a1dc18fc4a620ad4efecb0dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Thu, 7 Nov 2024 21:13:49 +0100 Subject: [PATCH 1/3] Split pins off of Io --- esp-hal/src/analog/adc/mod.rs | 8 ++--- esp-hal/src/analog/dac.rs | 6 ++-- esp-hal/src/dma/mod.rs | 10 +++--- esp-hal/src/etm.rs | 6 ++-- esp-hal/src/gpio/etm.rs | 6 ++-- esp-hal/src/gpio/lp_io.rs | 6 ++-- esp-hal/src/gpio/mod.rs | 13 +++---- esp-hal/src/gpio/rtc_io.rs | 4 +-- esp-hal/src/i2c/master/mod.rs | 5 ++- esp-hal/src/i2s/master.rs | 10 +++--- esp-hal/src/lcd_cam/cam.rs | 26 +++++++------- esp-hal/src/lcd_cam/lcd/i8080.rs | 20 +++++------ esp-hal/src/ledc/mod.rs | 4 +-- esp-hal/src/lib.rs | 4 +-- esp-hal/src/mcpwm/mod.rs | 4 +-- esp-hal/src/mcpwm/operator.rs | 6 ++-- esp-hal/src/peripheral.rs | 3 ++ esp-hal/src/rmt.rs | 4 +-- esp-hal/src/rng.rs | 6 ++-- esp-hal/src/rom/md5.rs | 8 ++--- esp-hal/src/soc/esp32/efuse/mod.rs | 4 +-- esp-hal/src/soc/esp32c2/efuse/mod.rs | 4 +-- esp-hal/src/soc/esp32c3/efuse/mod.rs | 4 +-- esp-hal/src/soc/esp32c6/efuse/mod.rs | 4 +-- esp-hal/src/soc/esp32h2/efuse/mod.rs | 4 +-- esp-hal/src/soc/esp32s2/efuse/mod.rs | 4 +-- esp-hal/src/soc/esp32s3/efuse/mod.rs | 4 +-- esp-hal/src/spi/master.rs | 10 +++--- esp-hal/src/touch.rs | 4 +-- esp-hal/src/twai/mod.rs | 12 +++---- esp-hal/src/uart.rs | 30 ++++++++-------- examples/src/bin/adc.rs | 8 ++--- examples/src/bin/adc_cal.rs | 6 ++-- examples/src/bin/advanced_serial.rs | 11 ++++-- examples/src/bin/blinky.rs | 4 +-- examples/src/bin/blinky_erased_pins.rs | 12 +++---- examples/src/bin/dac.rs | 10 +++--- examples/src/bin/embassy_i2c.rs | 6 ++-- .../embassy_i2c_bmp180_calibration_data.rs | 6 ++-- examples/src/bin/embassy_i2s_parallel.rs | 20 +++++------ examples/src/bin/embassy_i2s_read.rs | 10 +++--- examples/src/bin/embassy_i2s_sound.rs | 8 ++--- examples/src/bin/embassy_multicore.rs | 4 +-- .../src/bin/embassy_multicore_interrupt.rs | 4 +-- examples/src/bin/embassy_parl_io_rx.rs | 4 +-- examples/src/bin/embassy_parl_io_tx.rs | 8 ++--- examples/src/bin/embassy_rmt_rx.rs | 10 +++--- examples/src/bin/embassy_rmt_tx.rs | 4 +-- examples/src/bin/embassy_serial.rs | 14 ++++---- examples/src/bin/embassy_spi.rs | 10 +++--- examples/src/bin/embassy_touch.rs | 6 ++-- examples/src/bin/embassy_twai.rs | 8 ++--- examples/src/bin/embassy_usb_serial.rs | 4 +-- examples/src/bin/embassy_wait.rs | 6 ++-- examples/src/bin/etm_blinky_systimer.rs | 4 +-- examples/src/bin/etm_gpio.rs | 6 ++-- examples/src/bin/gpio_interrupt.rs | 8 ++--- examples/src/bin/hello_world.rs | 14 ++++---- .../src/bin/i2c_bmp180_calibration_data.rs | 7 ++-- examples/src/bin/i2c_display.rs | 6 ++-- examples/src/bin/i2s_parallel.rs | 20 +++++------ examples/src/bin/i2s_read.rs | 10 +++--- examples/src/bin/i2s_sound.rs | 8 ++--- examples/src/bin/ieee802154_sniffer.rs | 6 ++-- examples/src/bin/lcd_cam_ov2640.rs | 30 ++++++++-------- examples/src/bin/lcd_i8080.rs | 28 +++++++-------- examples/src/bin/ledc.rs | 4 +-- examples/src/bin/lp_core_basic.rs | 4 +-- examples/src/bin/lp_core_i2c.rs | 6 ++-- examples/src/bin/lp_core_uart.rs | 10 +++--- examples/src/bin/mcpwm.rs | 4 +-- examples/src/bin/parl_io_rx.rs | 9 +++-- examples/src/bin/parl_io_tx.rs | 13 ++++--- examples/src/bin/pcnt_encoder.rs | 6 ++-- examples/src/bin/qspi_flash.rs | 26 +++++++------- examples/src/bin/rmt_rx.rs | 10 +++--- examples/src/bin/rmt_tx.rs | 7 ++-- examples/src/bin/serial_interrupts.rs | 14 ++++---- examples/src/bin/sleep_timer_ext0.rs | 4 +-- examples/src/bin/sleep_timer_ext1.rs | 6 ++-- examples/src/bin/sleep_timer_lpio.rs | 6 ++-- examples/src/bin/sleep_timer_rtcio.rs | 10 +++--- .../spi_halfduplex_read_manufacturer_id.rs | 26 +++++++------- examples/src/bin/spi_loopback.rs | 8 ++--- examples/src/bin/spi_loopback_dma.rs | 10 +++--- examples/src/bin/spi_loopback_dma_psram.rs | 8 ++--- examples/src/bin/touch.rs | 6 ++-- examples/src/bin/twai.rs | 8 ++--- examples/src/bin/ulp_riscv_core_basic.rs | 4 +-- examples/src/bin/usb_serial.rs | 8 +++-- examples/src/bin/wifi_ble.rs | 6 ++-- examples/src/bin/wifi_embassy_ble.rs | 6 ++-- hil-test/src/lib.rs | 34 +++++++++---------- hil-test/tests/gpio.rs | 4 +-- hil-test/tests/i2c.rs | 4 +-- hil-test/tests/i2s.rs | 2 +- hil-test/tests/lcd_cam_i8080.rs | 22 ++++++------ hil-test/tests/parl_io_tx.rs | 6 ++-- hil-test/tests/parl_io_tx_async.rs | 6 ++-- hil-test/tests/pcnt.rs | 4 +-- hil-test/tests/qspi.rs | 6 ++-- hil-test/tests/rmt.rs | 4 +-- hil-test/tests/spi_full_duplex.rs | 6 ++-- hil-test/tests/spi_half_duplex_read.rs | 6 ++-- hil-test/tests/spi_half_duplex_write.rs | 6 ++-- hil-test/tests/spi_half_duplex_write_psram.rs | 6 ++-- hil-test/tests/spi_slave.rs | 8 ++--- hil-test/tests/twai.rs | 4 +-- hil-test/tests/uart.rs | 4 +-- hil-test/tests/uart_async.rs | 4 +-- hil-test/tests/uart_regression.rs | 4 +-- hil-test/tests/uart_tx_rx.rs | 4 +-- hil-test/tests/uart_tx_rx_async.rs | 4 +-- 113 files changed, 480 insertions(+), 470 deletions(-) diff --git a/esp-hal/src/analog/adc/mod.rs b/esp-hal/src/analog/adc/mod.rs index b7d4e58d2a8..159ab29cafb 100644 --- a/esp-hal/src/analog/adc/mod.rs +++ b/esp-hal/src/analog/adc/mod.rs @@ -32,12 +32,12 @@ //! # use esp_hal::analog::adc::Adc; //! # use esp_hal::delay::Delay; //! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -#![cfg_attr(esp32, doc = "let analog_pin = io.pins.gpio32;")] -#![cfg_attr(any(esp32s2, esp32s3), doc = "let analog_pin = io.pins.gpio3;")] +//! # let io = Io::new(peripherals.IO_MUX); +#![cfg_attr(esp32, doc = "let analog_pin = peripherals.pins.gpio32;")] +#![cfg_attr(any(esp32s2, esp32s3), doc = "let analog_pin = peripherals.pins.gpio3;")] #![cfg_attr( not(any(esp32, esp32s2, esp32s3)), - doc = "let analog_pin = io.pins.gpio2;" + doc = "let analog_pin = peripherals.pins.gpio2;" )] //! let mut adc1_config = AdcConfig::new(); //! let mut pin = adc1_config.enable_pin( diff --git a/esp-hal/src/analog/dac.rs b/esp-hal/src/analog/dac.rs index 8cb1e859db3..2b1c6a44c46 100644 --- a/esp-hal/src/analog/dac.rs +++ b/esp-hal/src/analog/dac.rs @@ -22,9 +22,9 @@ //! # use esp_hal::delay::Delay; //! # use embedded_hal::delay::DelayNs; //! -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -#![cfg_attr(esp32, doc = "let dac1_pin = io.pins.gpio25;")] -#![cfg_attr(esp32s2, doc = "let dac1_pin = io.pins.gpio17;")] +//! let io = Io::new(peripherals.IO_MUX); +#![cfg_attr(esp32, doc = "let dac1_pin = peripherals.pins.gpio25;")] +#![cfg_attr(esp32s2, doc = "let dac1_pin = peripherals.pins.gpio17;")] //! let mut dac1 = Dac::new(peripherals.DAC1, dac1_pin); //! //! let mut delay = Delay::new(); diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index 0cfbb2e5269..9710cdff97b 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -24,11 +24,11 @@ //! let dma = Dma::new(peripherals.DMA); #![cfg_attr(any(esp32, esp32s2), doc = "let dma_channel = dma.spi2channel;")] #![cfg_attr(not(any(esp32, esp32s2)), doc = "let dma_channel = dma.channel0;")] -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! let sclk = io.pins.gpio0; -//! let miso = io.pins.gpio2; -//! let mosi = io.pins.gpio4; -//! let cs = io.pins.gpio5; +//! let io = Io::new(peripherals.IO_MUX); +//! let sclk = peripherals.pins.gpio0; +//! let miso = peripherals.pins.gpio2; +//! let mosi = peripherals.pins.gpio4; +//! let cs = peripherals.pins.gpio5; //! //! let mut spi = Spi::new_with_config( //! peripherals.SPI2, diff --git a/esp-hal/src/etm.rs b/esp-hal/src/etm.rs index f2c603a67e7..95155a60fb1 100644 --- a/esp-hal/src/etm.rs +++ b/esp-hal/src/etm.rs @@ -29,9 +29,9 @@ //! # use esp_hal::gpio::Pull; //! # use esp_hal::gpio::Level; //! -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! let mut led = io.pins.gpio1; -//! let button = io.pins.gpio9; +//! let io = Io::new(peripherals.IO_MUX); +//! let mut led = peripherals.pins.gpio1; +//! let button = peripherals.pins.gpio9; //! //! // setup ETM //! let gpio_ext = Channels::new(peripherals.GPIO_SD); diff --git a/esp-hal/src/gpio/etm.rs b/esp-hal/src/gpio/etm.rs index 1cae2982a79..2ff09c0c90e 100644 --- a/esp-hal/src/gpio/etm.rs +++ b/esp-hal/src/gpio/etm.rs @@ -33,9 +33,9 @@ //! # use esp_hal::gpio::Pull; //! # use esp_hal::gpio::Level; //! # -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut led = io.pins.gpio1; -//! # let button = io.pins.gpio9; +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut led = peripherals.pins.gpio1; +//! # let button = peripherals.pins.gpio9; //! //! let gpio_ext = Channels::new(peripherals.GPIO_SD); //! let led_task = gpio_ext.channel0_task.toggle( diff --git a/esp-hal/src/gpio/lp_io.rs b/esp-hal/src/gpio/lp_io.rs index 4eb849f83c0..bee8f20fe01 100644 --- a/esp-hal/src/gpio/lp_io.rs +++ b/esp-hal/src/gpio/lp_io.rs @@ -20,10 +20,10 @@ #![doc = crate::before_snippet!()] //! use esp_hal::gpio::Io; //! use esp_hal::gpio::lp_io::LowPowerOutput; -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! let io = Io::new(peripherals.IO_MUX); //! // configure GPIO 1 as LP output pin -//! let lp_pin: LowPowerOutput<'_, 1> = LowPowerOutput::new(io.pins.gpio1); -//! # } +//! let lp_pin: LowPowerOutput<'_, 1> = +//! LowPowerOutput::new(peripherals.pins.gpio1); # } //! ``` use core::marker::PhantomData; diff --git a/esp-hal/src/gpio/mod.rs b/esp-hal/src/gpio/mod.rs index 672021f9df0..521d2eb4f2b 100644 --- a/esp-hal/src/gpio/mod.rs +++ b/esp-hal/src/gpio/mod.rs @@ -52,8 +52,8 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::gpio::{Io, Level, Output}; -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! let mut led = Output::new(io.pins.gpio5, Level::High); +//! let io = Io::new(peripherals.IO_MUX); +//! let mut led = Output::new(peripherals.pins.gpio5, Level::High); //! # } //! ``` //! @@ -813,17 +813,12 @@ pub(crate) fn bind_default_interrupt_handler() { /// General Purpose Input/Output driver pub struct Io { _io_mux: IO_MUX, - /// The pins available on this chip - pub pins: Pins, } impl Io { /// Initialize the I/O driver. - pub fn new(_gpio: GPIO, _io_mux: IO_MUX) -> Self { - Io { - _io_mux, - pins: unsafe { Pins::steal() }, - } + pub fn new(_io_mux: IO_MUX) -> Self { + Io { _io_mux } } /// Set the interrupt priority for GPIO interrupts. diff --git a/esp-hal/src/gpio/rtc_io.rs b/esp-hal/src/gpio/rtc_io.rs index 2eb87a1714e..a265c2ecabb 100644 --- a/esp-hal/src/gpio/rtc_io.rs +++ b/esp-hal/src/gpio/rtc_io.rs @@ -24,9 +24,9 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::gpio::rtc_io::LowPowerOutput; //! # use esp_hal::gpio::Io; -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! let io = Io::new(peripherals.IO_MUX); //! // configure GPIO 1 as ULP output pin -//! let lp_pin = LowPowerOutput::<'static, 1>::new(io.pins.gpio1); +//! let lp_pin = LowPowerOutput::<'static, 1>::new(peripherals.pins.gpio1); //! # } //! ``` diff --git a/esp-hal/src/i2c/master/mod.rs b/esp-hal/src/i2c/master/mod.rs index 01135959dbe..bd4a88b412f 100644 --- a/esp-hal/src/i2c/master/mod.rs +++ b/esp-hal/src/i2c/master/mod.rs @@ -20,7 +20,6 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::i2c::master::{Config, I2c}; //! # use esp_hal::gpio::Io; -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); //! //! // Create a new peripheral object with the described wiring //! // and standard I2C clock speed. @@ -28,8 +27,8 @@ //! peripherals.I2C0, //! Config::default(), //! ) -//! .with_sda(io.pins.gpio1) -//! .with_scl(io.pins.gpio2); +//! .with_sda(peripherals.pins.gpio1) +//! .with_scl(peripherals.pins.gpio2); //! //! loop { //! let mut data = [0u8; 22]; diff --git a/esp-hal/src/i2s/master.rs b/esp-hal/src/i2s/master.rs index 6a418b966e8..3499e5257e1 100644 --- a/esp-hal/src/i2s/master.rs +++ b/esp-hal/src/i2s/master.rs @@ -33,7 +33,7 @@ //! # use esp_hal::gpio::Io; //! # use esp_hal::dma_buffers; //! # use esp_hal::dma::{Dma, DmaPriority}; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); //! let dma = Dma::new(peripherals.DMA); #![cfg_attr(any(esp32, esp32s2), doc = "let dma_channel = dma.i2s0channel;")] #![cfg_attr(not(any(esp32, esp32s2)), doc = "let dma_channel = dma.channel0;")] @@ -52,11 +52,11 @@ //! rx_descriptors, //! tx_descriptors, //! ); -#![cfg_attr(not(esp32), doc = "let i2s = i2s.with_mclk(io.pins.gpio0);")] +#![cfg_attr(not(esp32), doc = "let i2s = i2s.with_mclk(peripherals.pins.gpio0);")] //! let mut i2s_rx = i2s.i2s_rx -//! .with_bclk(io.pins.gpio1) -//! .with_ws(io.pins.gpio2) -//! .with_din(io.pins.gpio5) +//! .with_bclk(peripherals.pins.gpio1) +//! .with_ws(peripherals.pins.gpio2) +//! .with_din(peripherals.pins.gpio5) //! .build(); //! //! let mut transfer = i2s_rx.read_dma_circular(&mut rx_buffer).unwrap(); diff --git a/esp-hal/src/lcd_cam/cam.rs b/esp-hal/src/lcd_cam/cam.rs index 5cb3b9cf263..be60e7ded67 100644 --- a/esp-hal/src/lcd_cam/cam.rs +++ b/esp-hal/src/lcd_cam/cam.rs @@ -21,7 +21,7 @@ //! # use fugit::RateExtU32; //! # use esp_hal::dma_rx_stream_buffer; //! # use esp_hal::dma::{Dma, DmaPriority}; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); //! //! # let dma = Dma::new(peripherals.DMA); //! # let channel = dma.channel0; @@ -33,19 +33,19 @@ //! # DmaPriority::Priority0, //! # ); //! -//! let mclk_pin = io.pins.gpio15; -//! let vsync_pin = io.pins.gpio6; -//! let href_pin = io.pins.gpio7; -//! let pclk_pin = io.pins.gpio13; +//! let mclk_pin = peripherals.pins.gpio15; +//! let vsync_pin = peripherals.pins.gpio6; +//! let href_pin = peripherals.pins.gpio7; +//! let pclk_pin = peripherals.pins.gpio13; //! let data_pins = RxEightBits::new( -//! io.pins.gpio11, -//! io.pins.gpio9, -//! io.pins.gpio8, -//! io.pins.gpio10, -//! io.pins.gpio12, -//! io.pins.gpio18, -//! io.pins.gpio17, -//! io.pins.gpio16, +//! peripherals.pins.gpio11, +//! peripherals.pins.gpio9, +//! peripherals.pins.gpio8, +//! peripherals.pins.gpio10, +//! peripherals.pins.gpio12, +//! peripherals.pins.gpio18, +//! peripherals.pins.gpio17, +//! peripherals.pins.gpio16, //! ); //! //! let lcd_cam = LcdCam::new(peripherals.LCD_CAM); diff --git a/esp-hal/src/lcd_cam/lcd/i8080.rs b/esp-hal/src/lcd_cam/lcd/i8080.rs index 754c5f0e413..3380a711759 100644 --- a/esp-hal/src/lcd_cam/lcd/i8080.rs +++ b/esp-hal/src/lcd_cam/lcd/i8080.rs @@ -19,7 +19,7 @@ //! # use esp_hal::lcd_cam::{LcdCam, lcd::i8080::{Config, I8080, TxEightBits}}; //! # use esp_hal::dma_tx_buffer; //! # use esp_hal::dma::{Dma, DmaPriority, DmaTxBuf}; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); //! //! # let dma = Dma::new(peripherals.DMA); //! # let channel = dma.channel0; @@ -32,14 +32,14 @@ //! # ); //! //! let tx_pins = TxEightBits::new( -//! io.pins.gpio9, -//! io.pins.gpio46, -//! io.pins.gpio3, -//! io.pins.gpio8, -//! io.pins.gpio18, -//! io.pins.gpio17, -//! io.pins.gpio16, -//! io.pins.gpio15, +//! peripherals.pins.gpio9, +//! peripherals.pins.gpio46, +//! peripherals.pins.gpio3, +//! peripherals.pins.gpio8, +//! peripherals.pins.gpio18, +//! peripherals.pins.gpio17, +//! peripherals.pins.gpio16, +//! peripherals.pins.gpio15, //! ); //! let lcd_cam = LcdCam::new(peripherals.LCD_CAM); //! @@ -50,7 +50,7 @@ //! 20.MHz(), //! Config::default(), //! ) -//! .with_ctrl_pins(io.pins.gpio0, io.pins.gpio47); +//! .with_ctrl_pins(peripherals.pins.gpio0, peripherals.pins.gpio47); //! //! dma_buf.fill(&[0x55]); //! let transfer = i8080.send(0x3Au8, 0, dma_buf).unwrap(); // RGB565 diff --git a/esp-hal/src/ledc/mod.rs b/esp-hal/src/ledc/mod.rs index 3b0a61cfefc..316b66adc76 100644 --- a/esp-hal/src/ledc/mod.rs +++ b/esp-hal/src/ledc/mod.rs @@ -30,8 +30,8 @@ //! # use esp_hal::ledc::LowSpeed; //! # use esp_hal::ledc::channel; //! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let led = io.pins.gpio0; +//! # let io = Io::new(peripherals.IO_MUX); +//! # let led = peripherals.pins.gpio0; //! //! let mut ledc = Ledc::new(peripherals.LEDC); //! ledc.set_global_slow_clock(LSGlobalClkSource::APBClk); diff --git a/esp-hal/src/lib.rs b/esp-hal/src/lib.rs index f0c28132f68..a537f6a2982 100644 --- a/esp-hal/src/lib.rs +++ b/esp-hal/src/lib.rs @@ -81,8 +81,8 @@ //! }); //! //! // 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, Level::High); +//! let io = Io::new(peripherals.IO_MUX); +//! let mut led = Output::new(peripherals.pins.gpio0, Level::High); //! //! let delay = Delay::new(); //! diff --git a/esp-hal/src/mcpwm/mod.rs b/esp-hal/src/mcpwm/mod.rs index a4907be376f..e47bdd1ac6c 100644 --- a/esp-hal/src/mcpwm/mod.rs +++ b/esp-hal/src/mcpwm/mod.rs @@ -54,8 +54,8 @@ //! # use esp_hal::mcpwm::{operator::{DeadTimeCfg, PWMStream, PwmPinConfig}, timer::PwmWorkingMode, McPwm, PeripheralClockConfig}; //! # use esp_hal::gpio::Io; //! -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let pin = io.pins.gpio0; +//! # let io = Io::new(peripherals.IO_MUX); +//! # let pin = peripherals.pins.gpio0; //! //! // initialize peripheral #![cfg_attr( diff --git a/esp-hal/src/mcpwm/operator.rs b/esp-hal/src/mcpwm/operator.rs index f467d9f32fc..b14d915f7f3 100644 --- a/esp-hal/src/mcpwm/operator.rs +++ b/esp-hal/src/mcpwm/operator.rs @@ -480,7 +480,7 @@ impl embedded_hal::pwm::SetD /// # use esp_hal::mcpwm::{McPwm, PeripheralClockConfig}; /// # use esp_hal::mcpwm::operator::{DeadTimeCfg, PwmPinConfig, PWMStream}; /// # use esp_hal::gpio::Io; -/// # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +/// # let io = Io::new(peripherals.IO_MUX); /// // active high complementary using PWMA input /// let bridge_active = DeadTimeCfg::new_ahc(); /// // use PWMB as input for both outputs @@ -497,9 +497,9 @@ impl embedded_hal::pwm::SetD /// let mut mcpwm = McPwm::new(peripherals.MCPWM0, clock_cfg); /// /// let mut pins = mcpwm.operator0.with_linked_pins( -/// io.pins.gpio0, +/// peripherals.pins.gpio0, /// PwmPinConfig::UP_DOWN_ACTIVE_HIGH, // use PWMA as our main input -/// io.pins.gpio1, +/// peripherals.pins.gpio1, /// PwmPinConfig::EMPTY, // keep PWMB "low" /// bridge_off, /// ); diff --git a/esp-hal/src/peripheral.rs b/esp-hal/src/peripheral.rs index 6883d2caecc..19639c72b92 100644 --- a/esp-hal/src/peripheral.rs +++ b/esp-hal/src/peripheral.rs @@ -242,6 +242,8 @@ mod peripheral_macros { /// Each field represents a hardware peripheral. pub $name: peripherals::$name, )* + /// The pins available on this chip + pub pins: $crate::gpio::Pins, } impl Peripherals { @@ -271,6 +273,7 @@ mod peripheral_macros { $( $name: peripherals::$name::steal(), )* + pins: $crate::gpio::Pins::steal(), } } } diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs index 984d621cf54..17bf47089e2 100644 --- a/esp-hal/src/rmt.rs +++ b/esp-hal/src/rmt.rs @@ -56,14 +56,14 @@ //! # use esp_hal::rmt::Rmt; //! # use esp_hal::gpio::Io; //! # use crate::esp_hal::rmt::TxChannelCreator; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); #![cfg_attr(esp32h2, doc = "let freq = 32.MHz();")] #![cfg_attr(not(esp32h2), doc = "let freq = 80.MHz();")] //! let rmt = Rmt::new(peripherals.RMT, freq).unwrap(); //! let mut channel = rmt //! .channel0 //! .configure( -//! io.pins.gpio1, +//! peripherals.pins.gpio1, //! TxChannelConfig { //! clk_divider: 1, //! idle_output_level: false, diff --git a/esp-hal/src/rng.rs b/esp-hal/src/rng.rs index d0875012a13..a25cd70d22e 100644 --- a/esp-hal/src/rng.rs +++ b/esp-hal/src/rng.rs @@ -140,7 +140,7 @@ impl rand_core::RngCore for Rng { /// # use esp_hal::analog::adc::{AdcConfig, Attenuation, Adc}; /// # use esp_hal::gpio::Io; /// -/// let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +/// let io = Io::new(peripherals.IO_MUX); /// let mut buf = [0u8; 16]; /// /// // ADC is not available from now @@ -149,8 +149,8 @@ impl rand_core::RngCore for Rng { /// let mut true_rand = trng.random(); /// let mut rng = trng.downgrade(); /// // ADC is available now -#[cfg_attr(esp32, doc = "let analog_pin = io.pins.gpio32;")] -#[cfg_attr(not(esp32), doc = "let analog_pin = io.pins.gpio3;")] +#[cfg_attr(esp32, doc = "let analog_pin = peripherals.pins.gpio32;")] +#[cfg_attr(not(esp32), doc = "let analog_pin = peripherals.pins.gpio3;")] /// let mut adc1_config = AdcConfig::new(); /// let mut adc1_pin = adc1_config.enable_pin(analog_pin, /// Attenuation::Attenuation11dB); let mut adc1 = diff --git a/esp-hal/src/rom/md5.rs b/esp-hal/src/rom/md5.rs index 985334104d0..fa00fb20658 100644 --- a/esp-hal/src/rom/md5.rs +++ b/esp-hal/src/rom/md5.rs @@ -35,8 +35,8 @@ //! # use esp_hal::gpio::Io; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut uart0 = Uart::new(peripherals.UART0, io.pins.gpio1, io.pins.gpio2).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.pins.gpio1, peripherals.pins.gpio2).unwrap(); //! # let data = "Dummy"; //! let d: md5::Digest = md5::compute(&data); //! writeln!(uart0, "{}", d); @@ -51,8 +51,8 @@ //! # use esp_hal::gpio::Io; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut uart0 = Uart::new(peripherals.UART0, io.pins.gpio1, io.pins.gpio2).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.pins.gpio1, peripherals.pins.gpio2).unwrap(); //! # let data0 = "Dummy"; //! # let data1 = "Dummy"; //! # diff --git a/esp-hal/src/soc/esp32/efuse/mod.rs b/esp-hal/src/soc/esp32/efuse/mod.rs index 79773ff0ddd..1ecd29cd15b 100644 --- a/esp-hal/src/soc/esp32/efuse/mod.rs +++ b/esp-hal/src/soc/esp32/efuse/mod.rs @@ -28,8 +28,8 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut serial_tx = Uart::new(peripherals.UART0, io.pins.gpio4, io.pins.gpio5).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32c2/efuse/mod.rs b/esp-hal/src/soc/esp32c2/efuse/mod.rs index 3aeb5fc0a94..b330e4fcdd6 100644 --- a/esp-hal/src/soc/esp32c2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c2/efuse/mod.rs @@ -25,8 +25,8 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut serial_tx = Uart::new(peripherals.UART0, io.pins.gpio4, io.pins.gpio5).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32c3/efuse/mod.rs b/esp-hal/src/soc/esp32c3/efuse/mod.rs index f1f3b0e2fb5..9f5d8eefdfe 100644 --- a/esp-hal/src/soc/esp32c3/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c3/efuse/mod.rs @@ -26,8 +26,8 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut serial_tx = Uart::new(peripherals.UART0, io.pins.gpio4, io.pins.gpio5).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32c6/efuse/mod.rs b/esp-hal/src/soc/esp32c6/efuse/mod.rs index 0caa975a253..4a9464317e6 100644 --- a/esp-hal/src/soc/esp32c6/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c6/efuse/mod.rs @@ -26,8 +26,8 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut serial_tx = Uart::new(peripherals.UART0, io.pins.gpio4, io.pins.gpio5).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32h2/efuse/mod.rs b/esp-hal/src/soc/esp32h2/efuse/mod.rs index 73bdcd57b31..858f4fb44c2 100644 --- a/esp-hal/src/soc/esp32h2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32h2/efuse/mod.rs @@ -26,8 +26,8 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut serial_tx = Uart::new(peripherals.UART0, io.pins.gpio4, io.pins.gpio5).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32s2/efuse/mod.rs b/esp-hal/src/soc/esp32s2/efuse/mod.rs index 6dd75ceca7c..f8524ad682c 100644 --- a/esp-hal/src/soc/esp32s2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32s2/efuse/mod.rs @@ -28,8 +28,8 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut serial_tx = Uart::new(peripherals.UART0, io.pins.gpio4, io.pins.gpio5).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32s3/efuse/mod.rs b/esp-hal/src/soc/esp32s3/efuse/mod.rs index d4303daf85c..85649fd74db 100644 --- a/esp-hal/src/soc/esp32s3/efuse/mod.rs +++ b/esp-hal/src/soc/esp32s3/efuse/mod.rs @@ -26,8 +26,8 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! # let mut serial_tx = Uart::new(peripherals.UART0, io.pins.gpio4, io.pins.gpio5).unwrap(); +//! # let io = Io::new(peripherals.IO_MUX); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 1609c7c2909..c26f5833190 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -41,11 +41,11 @@ //! # use esp_hal::spi::SpiMode; //! # use esp_hal::spi::master::{Config, Spi}; //! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! let sclk = io.pins.gpio0; -//! let miso = io.pins.gpio2; -//! let mosi = io.pins.gpio1; -//! let cs = io.pins.gpio5; +//! # let io = Io::new(peripherals.IO_MUX); +//! let sclk = peripherals.pins.gpio0; +//! let miso = peripherals.pins.gpio2; +//! let mosi = peripherals.pins.gpio1; +//! let cs = peripherals.pins.gpio5; //! //! let mut spi = Spi::new_with_config( //! peripherals.SPI2, diff --git a/esp-hal/src/touch.rs b/esp-hal/src/touch.rs index be397dc10ba..d1dee325822 100644 --- a/esp-hal/src/touch.rs +++ b/esp-hal/src/touch.rs @@ -11,8 +11,8 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::touch::{Touch, TouchPad}; //! # use esp_hal::gpio::Io; -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! let touch_pin0 = io.pins.gpio2; +//! let io = Io::new(peripherals.IO_MUX); +//! let touch_pin0 = peripherals.pins.gpio2; //! let touch = Touch::continuous_mode(peripherals.TOUCH, None); //! let mut touchpad = TouchPad::new(touch_pin0, &touch); //! // ... give the peripheral some time for the measurement diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs index a89d5cfda3d..4d07b8e0b4d 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -35,11 +35,11 @@ //! # use esp_hal::gpio::Io; //! # use embedded_can::Frame; //! # use nb::block; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); //! // Use GPIO pins 2 and 3 to connect to the respective pins on the TWAI //! // transceiver. -//! let can_rx_pin = io.pins.gpio3; -//! let can_tx_pin = io.pins.gpio2; +//! let can_rx_pin = peripherals.pins.gpio3; +//! let can_tx_pin = peripherals.pins.gpio2; //! //! // The speed of the TWAI bus. //! const TWAI_BAUDRATE: twai::BaudRate = BaudRate::B1000K; @@ -89,11 +89,11 @@ //! # use esp_hal::gpio::Io; //! # use embedded_can::Frame; //! # use nb::block; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); //! // Use GPIO pins 2 and 3 to connect to the respective pins on the TWAI //! // transceiver. -//! let can_rx_pin = io.pins.gpio3; -//! let can_tx_pin = io.pins.gpio2; +//! let can_rx_pin = peripherals.pins.gpio3; +//! let can_tx_pin = peripherals.pins.gpio2; //! //! // The speed of the TWAI bus. //! const TWAI_BAUDRATE: twai::BaudRate = BaudRate::B1000K; diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index ef1ccb9e3b0..621f7cd1b66 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -25,12 +25,12 @@ //! # use esp_hal::uart::Uart; //! use esp_hal::gpio::Io; //! -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! let io = Io::new(peripherals.IO_MUX); //! //! let mut uart1 = Uart::new( //! peripherals.UART1, -//! io.pins.gpio1, -//! io.pins.gpio2, +//! peripherals.pins.gpio1, +//! peripherals.pins.gpio2, //! ).unwrap(); //! # } //! ``` @@ -57,12 +57,12 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::uart::{Config, Uart}; //! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); //! # let mut uart1 = Uart::new_with_config( //! # peripherals.UART1, //! # Config::default(), -//! # io.pins.gpio1, -//! # io.pins.gpio2, +//! # peripherals.pins.gpio1, +//! # peripherals.pins.gpio2, //! # ).unwrap(); //! // Write bytes out over the UART: //! uart1.write_bytes(b"Hello, world!").expect("write error!"); @@ -74,12 +74,12 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::uart::{Config, Uart}; //! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! # let io = Io::new(peripherals.IO_MUX); //! # let mut uart1 = Uart::new_with_config( //! # peripherals.UART1, //! # Config::default(), -//! # io.pins.gpio1, -//! # io.pins.gpio2, +//! # peripherals.pins.gpio1, +//! # peripherals.pins.gpio2, //! # ).unwrap(); //! // The UART can be split into separate Transmit and Receive components: //! let (mut rx, mut tx) = uart1.split(); @@ -96,10 +96,10 @@ //! # use esp_hal::uart::Uart; //! use esp_hal::gpio::Io; //! -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! let io = Io::new(peripherals.IO_MUX); //! -//! let (rx, _) = io.pins.gpio2.split(); -//! let (_, tx) = io.pins.gpio1.split(); +//! let (rx, _) = peripherals.pins.gpio2.split(); +//! let (_, tx) = peripherals.pins.gpio1.split(); //! let mut uart1 = Uart::new( //! peripherals.UART1, //! rx.inverted(), @@ -114,10 +114,10 @@ //! # use esp_hal::uart::{UartTx, UartRx}; //! use esp_hal::gpio::Io; //! -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); +//! let io = Io::new(peripherals.IO_MUX); //! -//! let tx = UartTx::new(peripherals.UART0, io.pins.gpio1).unwrap(); -//! let rx = UartRx::new(peripherals.UART1, io.pins.gpio2).unwrap(); +//! let tx = UartTx::new(peripherals.UART0, peripherals.pins.gpio1).unwrap(); +//! let rx = UartRx::new(peripherals.UART1, peripherals.pins.gpio2).unwrap(); //! # } //! ``` //! diff --git a/examples/src/bin/adc.rs b/examples/src/bin/adc.rs index 08fe4b3786a..9ea7dd1d247 100644 --- a/examples/src/bin/adc.rs +++ b/examples/src/bin/adc.rs @@ -29,14 +29,14 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let analog_pin = io.pins.gpio32; + let analog_pin = peripherals.pins.gpio32; } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let analog_pin = io.pins.gpio3; + let analog_pin = peripherals.pins.gpio3; } else { - let analog_pin = io.pins.gpio2; + let analog_pin = peripherals.pins.gpio2; } } diff --git a/examples/src/bin/adc_cal.rs b/examples/src/bin/adc_cal.rs index a025a6ba52f..1fc3e4e85c1 100644 --- a/examples/src/bin/adc_cal.rs +++ b/examples/src/bin/adc_cal.rs @@ -25,12 +25,12 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32s3")] { - let analog_pin = io.pins.gpio3; + let analog_pin = peripherals.pins.gpio3; } else { - let analog_pin = io.pins.gpio2; + let analog_pin = peripherals.pins.gpio2; } } diff --git a/examples/src/bin/advanced_serial.rs b/examples/src/bin/advanced_serial.rs index b0c4e8d90b3..1e62e78798e 100644 --- a/examples/src/bin/advanced_serial.rs +++ b/examples/src/bin/advanced_serial.rs @@ -21,9 +21,14 @@ use nb::block; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - - let mut serial1 = Uart::new(peripherals.UART1, io.pins.gpio4, io.pins.gpio5).unwrap(); + let io = Io::new(peripherals.IO_MUX); + + let mut serial1 = Uart::new( + peripherals.UART1, + peripherals.pins.gpio4, + peripherals.pins.gpio5, + ) + .unwrap(); let delay = Delay::new(); diff --git a/examples/src/bin/blinky.rs b/examples/src/bin/blinky.rs index f863b8b19b8..8f5cb4b0a7e 100644 --- a/examples/src/bin/blinky.rs +++ b/examples/src/bin/blinky.rs @@ -20,8 +20,8 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); // 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, Level::High); + let io = Io::new(peripherals.IO_MUX); + let mut led = Output::new(peripherals.pins.gpio0, Level::High); let delay = Delay::new(); diff --git a/examples/src/bin/blinky_erased_pins.rs b/examples/src/bin/blinky_erased_pins.rs index 48d9309f088..8fd590b5ee2 100644 --- a/examples/src/bin/blinky_erased_pins.rs +++ b/examples/src/bin/blinky_erased_pins.rs @@ -22,18 +22,18 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Set LED GPIOs as an output: - let led1 = Output::new(io.pins.gpio2.degrade(), Level::Low); - let led2 = Output::new(io.pins.gpio4.degrade(), Level::Low); - let led3 = Output::new(io.pins.gpio5.degrade(), Level::Low); + let led1 = Output::new(peripherals.pins.gpio2.degrade(), Level::Low); + let led2 = Output::new(peripherals.pins.gpio4.degrade(), Level::Low); + let led3 = Output::new(peripherals.pins.gpio5.degrade(), Level::Low); // Use boot button as an input: #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] - let button = io.pins.gpio0.degrade(); + let button = peripherals.pins.gpio0.degrade(); #[cfg(not(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3")))] - let button = io.pins.gpio9.degrade(); + let button = peripherals.pins.gpio9.degrade(); let button = Input::new(button, Pull::Up); diff --git a/examples/src/bin/dac.rs b/examples/src/bin/dac.rs index d83740d97da..8d2c1528846 100644 --- a/examples/src/bin/dac.rs +++ b/examples/src/bin/dac.rs @@ -25,15 +25,15 @@ use esp_hal::{analog::dac::Dac, delay::Delay, gpio::Io, prelude::*}; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let dac1_pin = io.pins.gpio25; - let dac2_pin = io.pins.gpio26; + let dac1_pin = peripherals.pins.gpio25; + let dac2_pin = peripherals.pins.gpio26; } else if #[cfg(feature = "esp32s2")] { - let dac1_pin = io.pins.gpio17; - let dac2_pin = io.pins.gpio18; + let dac1_pin = peripherals.pins.gpio17; + let dac2_pin = peripherals.pins.gpio18; } } diff --git a/examples/src/bin/embassy_i2c.rs b/examples/src/bin/embassy_i2c.rs index 64c046695a7..344d1502bc9 100644 --- a/examples/src/bin/embassy_i2c.rs +++ b/examples/src/bin/embassy_i2c.rs @@ -34,15 +34,13 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let i2c0 = I2c::new(peripherals.I2C0, { let mut config = Config::default(); config.frequency = 400.kHz(); config }) - .with_sda(io.pins.gpio4) - .with_scl(io.pins.gpio5) + .with_sda(peripherals.pins.gpio4) + .with_scl(peripherals.pins.gpio5) .into_async(); let mut lis3dh = Lis3dh::new_i2c(i2c0, SlaveAddr::Alternate).await.unwrap(); diff --git a/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs b/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs index 204f9e61f38..fa08cdfa78a 100644 --- a/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs +++ b/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs @@ -34,15 +34,13 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let mut i2c = I2c::new(peripherals.I2C0, { let mut config = Config::default(); config.frequency = 400.kHz(); config }) - .with_sda(io.pins.gpio4) - .with_scl(io.pins.gpio5) + .with_sda(peripherals.pins.gpio4) + .with_scl(peripherals.pins.gpio5) .into_async(); loop { diff --git a/examples/src/bin/embassy_i2s_parallel.rs b/examples/src/bin/embassy_i2s_parallel.rs index 322b5e4a95b..fa76ac9f766 100644 --- a/examples/src/bin/embassy_i2s_parallel.rs +++ b/examples/src/bin/embassy_i2s_parallel.rs @@ -35,7 +35,7 @@ async fn main(_spawner: Spawner) { info!("Starting!"); let peripherals = esp_hal::init(esp_hal::Config::default()); let dma = Dma::new(peripherals.DMA); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let timg0 = TimerGroup::new(peripherals.TIMG0); @@ -44,17 +44,17 @@ async fn main(_spawner: Spawner) { let dma_channel = dma.i2s1channel; let i2s = peripherals.I2S1; - let clock = io.pins.gpio25; + let clock = peripherals.pins.gpio25; let pins = TxEightBits::new( - io.pins.gpio16, - io.pins.gpio4, - io.pins.gpio17, - io.pins.gpio18, - io.pins.gpio5, - io.pins.gpio19, - io.pins.gpio12, - io.pins.gpio14, + peripherals.pins.gpio16, + peripherals.pins.gpio4, + peripherals.pins.gpio17, + peripherals.pins.gpio18, + peripherals.pins.gpio5, + peripherals.pins.gpio19, + peripherals.pins.gpio12, + peripherals.pins.gpio14, ); let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, BUFFER_SIZE); diff --git a/examples/src/bin/embassy_i2s_read.rs b/examples/src/bin/embassy_i2s_read.rs index 196793e9c23..ba881eb47ab 100644 --- a/examples/src/bin/embassy_i2s_read.rs +++ b/examples/src/bin/embassy_i2s_read.rs @@ -37,7 +37,7 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] @@ -59,13 +59,13 @@ async fn main(_spawner: Spawner) { .into_async(); #[cfg(not(feature = "esp32"))] - let i2s = i2s.with_mclk(io.pins.gpio0); + let i2s = i2s.with_mclk(peripherals.pins.gpio0); let i2s_rx = i2s .i2s_rx - .with_bclk(io.pins.gpio2) - .with_ws(io.pins.gpio4) - .with_din(io.pins.gpio5) + .with_bclk(peripherals.pins.gpio2) + .with_ws(peripherals.pins.gpio4) + .with_din(peripherals.pins.gpio5) .build(); let buffer = rx_buffer; diff --git a/examples/src/bin/embassy_i2s_sound.rs b/examples/src/bin/embassy_i2s_sound.rs index dd48f782738..613f5a57e27 100644 --- a/examples/src/bin/embassy_i2s_sound.rs +++ b/examples/src/bin/embassy_i2s_sound.rs @@ -59,7 +59,7 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] @@ -82,9 +82,9 @@ async fn main(_spawner: Spawner) { let i2s_tx = i2s .i2s_tx - .with_bclk(io.pins.gpio2) - .with_ws(io.pins.gpio4) - .with_dout(io.pins.gpio5) + .with_bclk(peripherals.pins.gpio2) + .with_ws(peripherals.pins.gpio4) + .with_dout(peripherals.pins.gpio5) .build(); let data = diff --git a/examples/src/bin/embassy_multicore.rs b/examples/src/bin/embassy_multicore.rs index 741b196bb2c..96aad8a1cbc 100644 --- a/examples/src/bin/embassy_multicore.rs +++ b/examples/src/bin/embassy_multicore.rs @@ -53,7 +53,7 @@ async fn control_led( async fn main(_spawner: Spawner) { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let timg0 = TimerGroup::new(peripherals.TIMG0); let timer0: AnyTimer = timg0.timer0.into(); @@ -65,7 +65,7 @@ async fn main(_spawner: Spawner) { static LED_CTRL: StaticCell> = StaticCell::new(); let led_ctrl_signal = &*LED_CTRL.init(Signal::new()); - let led = Output::new(io.pins.gpio0, Level::Low); + let led = Output::new(peripherals.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 1b427ebe7b5..f60056b9121 100644 --- a/examples/src/bin/embassy_multicore_interrupt.rs +++ b/examples/src/bin/embassy_multicore_interrupt.rs @@ -75,7 +75,7 @@ fn main() -> ! { let sw_ints = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let timg0 = TimerGroup::new(peripherals.TIMG0); let timer0: AnyTimer = timg0.timer0.into(); @@ -87,7 +87,7 @@ fn main() -> ! { static LED_CTRL: StaticCell> = StaticCell::new(); let led_ctrl_signal = &*LED_CTRL.init(Signal::new()); - let led = Output::new(io.pins.gpio0, Level::Low); + let led = Output::new(peripherals.pins.gpio0, Level::Low); static EXECUTOR_CORE_1: StaticCell> = StaticCell::new(); let executor_core1 = InterruptExecutor::new(sw_ints.software_interrupt1); diff --git a/examples/src/bin/embassy_parl_io_rx.rs b/examples/src/bin/embassy_parl_io_rx.rs index 95e28f696ee..5fb4c89833e 100644 --- a/examples/src/bin/embassy_parl_io_rx.rs +++ b/examples/src/bin/embassy_parl_io_rx.rs @@ -31,14 +31,14 @@ async fn main(_spawner: Spawner) { let systimer = SystemTimer::new(peripherals.SYSTIMER).split::(); esp_hal_embassy::init(systimer.alarm0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32000, 0); let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; - let mut rx_pins = RxFourBits::new(io.pins.gpio1, io.pins.gpio2, io.pins.gpio3, io.pins.gpio4); + let mut rx_pins = RxFourBits::new(peripherals.pins.gpio1, peripherals.pins.gpio2, peripherals.pins.gpio3, peripherals.pins.gpio4); let parl_io = ParlIoRxOnly::new( peripherals.PARL_IO, diff --git a/examples/src/bin/embassy_parl_io_tx.rs b/examples/src/bin/embassy_parl_io_tx.rs index e177ad506d9..a4b0a884faf 100644 --- a/examples/src/bin/embassy_parl_io_tx.rs +++ b/examples/src/bin/embassy_parl_io_tx.rs @@ -42,16 +42,16 @@ async fn main(_spawner: Spawner) { let systimer = SystemTimer::new(peripherals.SYSTIMER).split::(); esp_hal_embassy::init(systimer.alarm0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000); let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; - let tx_pins = TxFourBits::new(io.pins.gpio1, io.pins.gpio2, io.pins.gpio3, io.pins.gpio4); + let tx_pins = TxFourBits::new(peripherals.pins.gpio1, peripherals.pins.gpio2, peripherals.pins.gpio3, peripherals.pins.gpio4); - let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, io.pins.gpio5); + let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, peripherals.pins.gpio5); let parl_io = ParlIoTxOnly::new( peripherals.PARL_IO, @@ -63,7 +63,7 @@ async fn main(_spawner: Spawner) { ) .unwrap(); - let mut clock_pin = ClkOutPin::new(io.pins.gpio8); + let mut clock_pin = ClkOutPin::new(peripherals.pins.gpio8); let mut parl_io_tx = parl_io .tx diff --git a/examples/src/bin/embassy_rmt_rx.rs b/examples/src/bin/embassy_rmt_rx.rs index 4ebfd23c56e..75be15a7462 100644 --- a/examples/src/bin/embassy_rmt_rx.rs +++ b/examples/src/bin/embassy_rmt_rx.rs @@ -44,7 +44,7 @@ async fn main(spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { @@ -63,16 +63,16 @@ async fn main(spawner: Spawner) { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2"))] { - let mut channel = rmt.channel0.configure(io.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel0.configure(peripherals.pins.gpio4, rx_config).unwrap(); } else if #[cfg(feature = "esp32s3")] { - let mut channel = rmt.channel7.configure(io.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel7.configure(peripherals.pins.gpio4, rx_config).unwrap(); } else { - let mut channel = rmt.channel2.configure(io.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel2.configure(peripherals.pins.gpio4, rx_config).unwrap(); } } spawner - .spawn(signal_task(Output::new(io.pins.gpio5, Level::Low))) + .spawn(signal_task(Output::new(peripherals.pins.gpio5, Level::Low))) .unwrap(); let mut data = [PulseCode { diff --git a/examples/src/bin/embassy_rmt_tx.rs b/examples/src/bin/embassy_rmt_tx.rs index 79413f3c8b6..7a5406d6d3a 100644 --- a/examples/src/bin/embassy_rmt_tx.rs +++ b/examples/src/bin/embassy_rmt_tx.rs @@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) { let mut channel = rmt .channel0 .configure( - io.pins.gpio4, + peripherals.pins.gpio4, TxChannelConfig { clk_divider: 255, ..TxChannelConfig::default() diff --git a/examples/src/bin/embassy_serial.rs b/examples/src/bin/embassy_serial.rs index 40d25ef0cfd..991b6b34a17 100644 --- a/examples/src/bin/embassy_serial.rs +++ b/examples/src/bin/embassy_serial.rs @@ -71,22 +71,22 @@ async fn main(spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let (tx_pin, rx_pin) = (io.pins.gpio1, io.pins.gpio3); + let (tx_pin, rx_pin) = (peripherals.pins.gpio1, peripherals.pins.gpio3); } else if #[cfg(feature = "esp32c2")] { - let (tx_pin, rx_pin) = (io.pins.gpio20, io.pins.gpio19); + let (tx_pin, rx_pin) = (peripherals.pins.gpio20, peripherals.pins.gpio19); } else if #[cfg(feature = "esp32c3")] { - let (tx_pin, rx_pin) = (io.pins.gpio21, io.pins.gpio20); + let (tx_pin, rx_pin) = (peripherals.pins.gpio21, peripherals.pins.gpio20); } else if #[cfg(feature = "esp32c6")] { - let (tx_pin, rx_pin) = (io.pins.gpio16, io.pins.gpio17); + let (tx_pin, rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); } else if #[cfg(feature = "esp32h2")] { - let (tx_pin, rx_pin) = (io.pins.gpio24, io.pins.gpio23); + let (tx_pin, rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let (tx_pin, rx_pin) = (io.pins.gpio43, io.pins.gpio44); + let (tx_pin, rx_pin) = (peripherals.pins.gpio43, peripherals.pins.gpio44); } } diff --git a/examples/src/bin/embassy_spi.rs b/examples/src/bin/embassy_spi.rs index 702b30046de..1370a5de6d8 100644 --- a/examples/src/bin/embassy_spi.rs +++ b/examples/src/bin/embassy_spi.rs @@ -41,11 +41,11 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio0; - let miso = io.pins.gpio2; - let mosi = io.pins.gpio4; - let cs = io.pins.gpio5; + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio0; + let miso = peripherals.pins.gpio2; + let mosi = peripherals.pins.gpio4; + let cs = peripherals.pins.gpio5; let dma = Dma::new(peripherals.DMA); diff --git a/examples/src/bin/embassy_touch.rs b/examples/src/bin/embassy_touch.rs index 808caf2a869..464683197c1 100644 --- a/examples/src/bin/embassy_touch.rs +++ b/examples/src/bin/embassy_touch.rs @@ -32,11 +32,11 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let mut rtc = Rtc::new(peripherals.LPWR); - let touch_pin0 = io.pins.gpio2; - let touch_pin1 = io.pins.gpio4; + let touch_pin0 = peripherals.pins.gpio2; + let touch_pin1 = peripherals.pins.gpio4; let touch_cfg = Some(TouchConfig { measurement_duration: Some(0x2000), diff --git a/examples/src/bin/embassy_twai.rs b/examples/src/bin/embassy_twai.rs index 36b94aa42b4..8debbb58aa6 100644 --- a/examples/src/bin/embassy_twai.rs +++ b/examples/src/bin/embassy_twai.rs @@ -92,13 +92,13 @@ async fn main(spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Without an external transceiver, we only need a single line between the two MCUs. - let (rx_pin, tx_pin) = io.pins.gpio2.split(); + let (rx_pin, tx_pin) = peripherals.pins.gpio2.split(); // Use these if you want to use an external transceiver: - // let tx_pin = io.pins.gpio2; - // let rx_pin = io.pins.gpio0; + // let tx_pin = peripherals.pins.gpio2; + // let rx_pin = peripherals.pins.gpio0; // The speed of the bus. const TWAI_BAUDRATE: twai::BaudRate = twai::BaudRate::B125K; diff --git a/examples/src/bin/embassy_usb_serial.rs b/examples/src/bin/embassy_usb_serial.rs index e2054358dd3..f021be5230e 100644 --- a/examples/src/bin/embassy_usb_serial.rs +++ b/examples/src/bin/embassy_usb_serial.rs @@ -37,9 +37,9 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let usb = Usb::new(peripherals.USB0, io.pins.gpio20, io.pins.gpio19); + let usb = Usb::new(peripherals.USB0, peripherals.pins.gpio20, peripherals.pins.gpio19); // Create the driver, from the HAL. let mut ep_out_buffer = [0u8; 1024]; diff --git a/examples/src/bin/embassy_wait.rs b/examples/src/bin/embassy_wait.rs index 9f80b2dbc9d..ce236d9098e 100644 --- a/examples/src/bin/embassy_wait.rs +++ b/examples/src/bin/embassy_wait.rs @@ -24,13 +24,13 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let mut input = Input::new(io.pins.gpio0, Pull::Down); + let mut input = Input::new(peripherals.pins.gpio0, Pull::Down); } else { - let mut input = Input::new(io.pins.gpio9, Pull::Down); + let mut input = Input::new(peripherals.pins.gpio9, Pull::Down); } } diff --git a/examples/src/bin/etm_blinky_systimer.rs b/examples/src/bin/etm_blinky_systimer.rs index 65b141bfb51..da8fb0785c0 100644 --- a/examples/src/bin/etm_blinky_systimer.rs +++ b/examples/src/bin/etm_blinky_systimer.rs @@ -31,8 +31,8 @@ fn main() -> ! { let mut alarm0 = syst_alarms.alarm0; alarm0.set_period(1u32.secs()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let mut led = io.pins.gpio1; + let io = Io::new(peripherals.IO_MUX); + let mut led = peripherals.pins.gpio1; // setup ETM let gpio_ext = Channels::new(peripherals.GPIO_SD); diff --git a/examples/src/bin/etm_gpio.rs b/examples/src/bin/etm_gpio.rs index 83cf726c4ab..8ee061d0b6e 100644 --- a/examples/src/bin/etm_gpio.rs +++ b/examples/src/bin/etm_gpio.rs @@ -25,10 +25,10 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let mut led = Output::new(io.pins.gpio1, Level::Low); - let button = io.pins.gpio9; + let mut led = Output::new(peripherals.pins.gpio1, Level::Low); + let button = peripherals.pins.gpio9; led.set_high(); diff --git a/examples/src/bin/gpio_interrupt.rs b/examples/src/bin/gpio_interrupt.rs index 07e77725e12..33a66ae21b1 100644 --- a/examples/src/bin/gpio_interrupt.rs +++ b/examples/src/bin/gpio_interrupt.rs @@ -30,15 +30,15 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); // Set GPIO2 as an output, and set its state high initially. - let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let mut io = Io::new(peripherals.IO_MUX); io.set_interrupt_handler(handler); - let mut led = Output::new(io.pins.gpio2, Level::Low); + let mut led = Output::new(peripherals.pins.gpio2, Level::Low); cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let button = io.pins.gpio0; + let button = peripherals.pins.gpio0; } else { - let button = io.pins.gpio9; + let button = peripherals.pins.gpio9; } } diff --git a/examples/src/bin/hello_world.rs b/examples/src/bin/hello_world.rs index b4e280c1f0a..2ef151bae26 100644 --- a/examples/src/bin/hello_world.rs +++ b/examples/src/bin/hello_world.rs @@ -23,22 +23,22 @@ fn main() -> ! { let delay = Delay::new(); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio1, io.pins.gpio3); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio1, peripherals.pins.gpio3); } else if #[cfg(feature = "esp32c2")] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio20, io.pins.gpio19); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio20, peripherals.pins.gpio19); } else if #[cfg(feature = "esp32c3")] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio21, io.pins.gpio20); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio21, peripherals.pins.gpio20); } else if #[cfg(feature = "esp32c6")] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio16, io.pins.gpio17); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); } else if #[cfg(feature = "esp32h2")] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio24, io.pins.gpio23); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio43, io.pins.gpio44); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio43, peripherals.pins.gpio44); } } diff --git a/examples/src/bin/i2c_bmp180_calibration_data.rs b/examples/src/bin/i2c_bmp180_calibration_data.rs index 7d75aa73adc..b84536e7275 100644 --- a/examples/src/bin/i2c_bmp180_calibration_data.rs +++ b/examples/src/bin/i2c_bmp180_calibration_data.rs @@ -13,7 +13,6 @@ use esp_backtrace as _; use esp_hal::{ - gpio::Io, i2c::master::{Config, I2c}, prelude::*, }; @@ -23,13 +22,11 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - // Create a new peripheral object with the described wiring and standard // I2C clock speed: let mut i2c = I2c::new(peripherals.I2C0, Config::default()) - .with_sda(io.pins.gpio4) - .with_scl(io.pins.gpio5); + .with_sda(peripherals.pins.gpio4) + .with_scl(peripherals.pins.gpio5); loop { let mut data = [0u8; 22]; diff --git a/examples/src/bin/i2c_display.rs b/examples/src/bin/i2c_display.rs index cf17fa0a02e..401c31b9378 100644 --- a/examples/src/bin/i2c_display.rs +++ b/examples/src/bin/i2c_display.rs @@ -24,7 +24,6 @@ use embedded_graphics::{ use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::Io, i2c::master::{Config, I2c}, prelude::*, }; @@ -35,13 +34,12 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); let delay = Delay::new(); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); // Create a new peripheral object with the described wiring // and standard I2C clock speed let i2c = I2c::new(peripherals.I2C0, Config::default()) - .with_sda(io.pins.gpio4) - .with_scl(io.pins.gpio5); + .with_sda(peripherals.pins.gpio4) + .with_scl(peripherals.pins.gpio5); // Initialize display let interface = I2CDisplayInterface::new(i2c); diff --git a/examples/src/bin/i2s_parallel.rs b/examples/src/bin/i2s_parallel.rs index 4effbf654f0..f059df6ceb1 100644 --- a/examples/src/bin/i2s_parallel.rs +++ b/examples/src/bin/i2s_parallel.rs @@ -32,23 +32,23 @@ fn main() -> ! { info!("Starting!"); let peripherals = esp_hal::init(esp_hal::Config::default()); let dma = Dma::new(peripherals.DMA); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let delay = Delay::new(); let dma_channel = dma.i2s1channel; let i2s = peripherals.I2S1; - let clock = io.pins.gpio25; + let clock = peripherals.pins.gpio25; let pins = TxEightBits::new( - io.pins.gpio16, - io.pins.gpio4, - io.pins.gpio17, - io.pins.gpio18, - io.pins.gpio5, - io.pins.gpio19, - io.pins.gpio12, - io.pins.gpio14, + peripherals.pins.gpio16, + peripherals.pins.gpio4, + peripherals.pins.gpio17, + peripherals.pins.gpio18, + peripherals.pins.gpio5, + peripherals.pins.gpio19, + peripherals.pins.gpio12, + peripherals.pins.gpio14, ); let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, BUFFER_SIZE); diff --git a/examples/src/bin/i2s_read.rs b/examples/src/bin/i2s_read.rs index 4e2278ff632..e139dd5f691 100644 --- a/examples/src/bin/i2s_read.rs +++ b/examples/src/bin/i2s_read.rs @@ -30,7 +30,7 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] @@ -55,13 +55,13 @@ fn main() -> ! { ); #[cfg(not(feature = "esp32"))] - let i2s = i2s.with_mclk(io.pins.gpio0); + let i2s = i2s.with_mclk(peripherals.pins.gpio0); let mut i2s_rx = i2s .i2s_rx - .with_bclk(io.pins.gpio2) - .with_ws(io.pins.gpio4) - .with_din(io.pins.gpio5) + .with_bclk(peripherals.pins.gpio2) + .with_ws(peripherals.pins.gpio4) + .with_din(peripherals.pins.gpio5) .build(); let mut transfer = i2s_rx.read_dma_circular(&mut rx_buffer).unwrap(); diff --git a/examples/src/bin/i2s_sound.rs b/examples/src/bin/i2s_sound.rs index 8058ef82361..f38ebdd8dae 100644 --- a/examples/src/bin/i2s_sound.rs +++ b/examples/src/bin/i2s_sound.rs @@ -51,7 +51,7 @@ const SINE: [i16; 64] = [ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] @@ -73,9 +73,9 @@ fn main() -> ! { let mut i2s_tx = i2s .i2s_tx - .with_bclk(io.pins.gpio2) - .with_ws(io.pins.gpio4) - .with_dout(io.pins.gpio5) + .with_bclk(peripherals.pins.gpio2) + .with_ws(peripherals.pins.gpio4) + .with_dout(peripherals.pins.gpio5) .build(); let data = diff --git a/examples/src/bin/ieee802154_sniffer.rs b/examples/src/bin/ieee802154_sniffer.rs index f8789241c4a..b9deeb311fc 100644 --- a/examples/src/bin/ieee802154_sniffer.rs +++ b/examples/src/bin/ieee802154_sniffer.rs @@ -16,14 +16,14 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32c6")] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio16, io.pins.gpio17); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); } else if #[cfg(feature = "esp32h2")] { - let (mut tx_pin, mut rx_pin) = (io.pins.gpio24, io.pins.gpio23); + let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); } } diff --git a/examples/src/bin/lcd_cam_ov2640.rs b/examples/src/bin/lcd_cam_ov2640.rs index 6b9198f97bf..3a7f70486ad 100644 --- a/examples/src/bin/lcd_cam_ov2640.rs +++ b/examples/src/bin/lcd_cam_ov2640.rs @@ -46,7 +46,7 @@ use esp_println::{print, println}; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let dma = Dma::new(peripherals.DMA); let channel = dma.channel0; @@ -55,21 +55,21 @@ fn main() -> ! { let channel = channel.configure(false, DmaPriority::Priority0); - let cam_siod = io.pins.gpio4; - let cam_sioc = io.pins.gpio5; - let cam_xclk = io.pins.gpio15; - let cam_vsync = io.pins.gpio6; - let cam_href = io.pins.gpio7; - let cam_pclk = io.pins.gpio13; + let cam_siod = peripherals.pins.gpio4; + let cam_sioc = peripherals.pins.gpio5; + let cam_xclk = peripherals.pins.gpio15; + let cam_vsync = peripherals.pins.gpio6; + let cam_href = peripherals.pins.gpio7; + let cam_pclk = peripherals.pins.gpio13; let cam_data_pins = RxEightBits::new( - io.pins.gpio11, - io.pins.gpio9, - io.pins.gpio8, - io.pins.gpio10, - io.pins.gpio12, - io.pins.gpio18, - io.pins.gpio17, - io.pins.gpio16, + peripherals.pins.gpio11, + peripherals.pins.gpio9, + peripherals.pins.gpio8, + peripherals.pins.gpio10, + peripherals.pins.gpio12, + peripherals.pins.gpio18, + peripherals.pins.gpio17, + peripherals.pins.gpio16, ); let lcd_cam = LcdCam::new(peripherals.LCD_CAM); diff --git a/examples/src/bin/lcd_i8080.rs b/examples/src/bin/lcd_i8080.rs index 2937f427cae..17fb9603289 100644 --- a/examples/src/bin/lcd_i8080.rs +++ b/examples/src/bin/lcd_i8080.rs @@ -41,13 +41,13 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let lcd_backlight = io.pins.gpio45; - let lcd_reset = io.pins.gpio4; - let lcd_rs = io.pins.gpio0; // Command/Data selection - let lcd_wr = io.pins.gpio47; // Write clock - let lcd_te = io.pins.gpio48; // Frame sync + let lcd_backlight = peripherals.pins.gpio45; + let lcd_reset = peripherals.pins.gpio4; + let lcd_rs = peripherals.pins.gpio0; // Command/Data selection + let lcd_wr = peripherals.pins.gpio47; // Write clock + let lcd_te = peripherals.pins.gpio48; // Frame sync let dma = Dma::new(peripherals.DMA); let channel = dma.channel0; @@ -63,14 +63,14 @@ fn main() -> ! { let tear_effect = Input::new(lcd_te, Pull::None); let tx_pins = TxEightBits::new( - io.pins.gpio9, - io.pins.gpio46, - io.pins.gpio3, - io.pins.gpio8, - io.pins.gpio18, - io.pins.gpio17, - io.pins.gpio16, - io.pins.gpio15, + peripherals.pins.gpio9, + peripherals.pins.gpio46, + peripherals.pins.gpio3, + peripherals.pins.gpio8, + peripherals.pins.gpio18, + peripherals.pins.gpio17, + peripherals.pins.gpio16, + peripherals.pins.gpio15, ); let lcd_cam = LcdCam::new(peripherals.LCD_CAM); diff --git a/examples/src/bin/ledc.rs b/examples/src/bin/ledc.rs index a9e8225a290..0cdd354b936 100644 --- a/examples/src/bin/ledc.rs +++ b/examples/src/bin/ledc.rs @@ -26,8 +26,8 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let led = io.pins.gpio0; + let io = Io::new(peripherals.IO_MUX); + let led = peripherals.pins.gpio0; let mut ledc = Ledc::new(peripherals.LEDC); diff --git a/examples/src/bin/lp_core_basic.rs b/examples/src/bin/lp_core_basic.rs index d0f38c45e14..ae41125e62b 100644 --- a/examples/src/bin/lp_core_basic.rs +++ b/examples/src/bin/lp_core_basic.rs @@ -26,8 +26,8 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); // configure GPIO 1 as LP output pin - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let lp_pin = LowPowerOutput::new(io.pins.gpio1); + let io = Io::new(peripherals.IO_MUX); + let lp_pin = LowPowerOutput::new(peripherals.pins.gpio1); let mut lp_core = LpCore::new(peripherals.LP_CORE); lp_core.stop(); diff --git a/examples/src/bin/lp_core_i2c.rs b/examples/src/bin/lp_core_i2c.rs index 55aa731c1bd..1afb387774a 100644 --- a/examples/src/bin/lp_core_i2c.rs +++ b/examples/src/bin/lp_core_i2c.rs @@ -27,10 +27,10 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let lp_sda = LowPowerOutputOpenDrain::new(io.pins.gpio6); - let lp_scl = LowPowerOutputOpenDrain::new(io.pins.gpio7); + let lp_sda = LowPowerOutputOpenDrain::new(peripherals.pins.gpio6); + let lp_scl = LowPowerOutputOpenDrain::new(peripherals.pins.gpio7); let lp_i2c = LpI2c::new(peripherals.LP_I2C0, lp_sda, lp_scl, 100.kHz()); diff --git a/examples/src/bin/lp_core_uart.rs b/examples/src/bin/lp_core_uart.rs index 9ecb0de7507..1c0c616d038 100644 --- a/examples/src/bin/lp_core_uart.rs +++ b/examples/src/bin/lp_core_uart.rs @@ -30,21 +30,21 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Set up (HP) UART1: let mut uart1 = Uart::new_with_config( peripherals.UART1, Config::default(), - io.pins.gpio6, - io.pins.gpio7, + peripherals.pins.gpio6, + peripherals.pins.gpio7, ) .unwrap(); // Set up (LP) UART: - let lp_tx = LowPowerOutput::new(io.pins.gpio5); - let lp_rx = LowPowerInput::new(io.pins.gpio4); + let lp_tx = LowPowerOutput::new(peripherals.pins.gpio5); + let lp_rx = LowPowerInput::new(peripherals.pins.gpio4); let lp_uart = LpUart::new(peripherals.LP_UART, lp_tx, lp_rx); let mut lp_core = LpCore::new(peripherals.LP_CORE); diff --git a/examples/src/bin/mcpwm.rs b/examples/src/bin/mcpwm.rs index 17e08e8c801..c28905ad172 100644 --- a/examples/src/bin/mcpwm.rs +++ b/examples/src/bin/mcpwm.rs @@ -20,8 +20,8 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let pin = io.pins.gpio0; + let io = Io::new(peripherals.IO_MUX); + let pin = peripherals.pins.gpio0; // initialize peripheral cfg_if::cfg_if! { diff --git a/examples/src/bin/parl_io_rx.rs b/examples/src/bin/parl_io_rx.rs index 8f66c376ea4..2a97ecaf9c2 100644 --- a/examples/src/bin/parl_io_rx.rs +++ b/examples/src/bin/parl_io_rx.rs @@ -24,14 +24,19 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32000, 0); let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; - let mut rx_pins = RxFourBits::new(io.pins.gpio1, io.pins.gpio2, io.pins.gpio3, io.pins.gpio4); + let mut rx_pins = RxFourBits::new( + peripherals.pins.gpio1, + peripherals.pins.gpio2, + peripherals.pins.gpio3, + peripherals.pins.gpio4, + ); let parl_io = ParlIoRxOnly::new( peripherals.PARL_IO, diff --git a/examples/src/bin/parl_io_tx.rs b/examples/src/bin/parl_io_tx.rs index 0df17ad398e..894c5146294 100644 --- a/examples/src/bin/parl_io_tx.rs +++ b/examples/src/bin/parl_io_tx.rs @@ -35,16 +35,21 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000); let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; - let tx_pins = TxFourBits::new(io.pins.gpio1, io.pins.gpio2, io.pins.gpio3, io.pins.gpio4); + let tx_pins = TxFourBits::new( + peripherals.pins.gpio1, + peripherals.pins.gpio2, + peripherals.pins.gpio3, + peripherals.pins.gpio4, + ); - let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, io.pins.gpio5); + let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, peripherals.pins.gpio5); let parl_io = ParlIoTxOnly::new( peripherals.PARL_IO, @@ -54,7 +59,7 @@ fn main() -> ! { ) .unwrap(); - let mut clock_pin = ClkOutPin::new(io.pins.gpio6); + let mut clock_pin = ClkOutPin::new(peripherals.pins.gpio6); let mut parl_io_tx = parl_io .tx diff --git a/examples/src/bin/pcnt_encoder.rs b/examples/src/bin/pcnt_encoder.rs index bf1b1394144..58733e5b93c 100644 --- a/examples/src/bin/pcnt_encoder.rs +++ b/examples/src/bin/pcnt_encoder.rs @@ -35,7 +35,7 @@ static VALUE: AtomicI32 = AtomicI32::new(0); fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Set up a pulse counter: println!("setup pulse counter unit 0"); @@ -50,8 +50,8 @@ fn main() -> ! { println!("setup channel 0"); let ch0 = &u0.channel0; - let pin_a = Input::new(io.pins.gpio4, Pull::Up); - let pin_b = Input::new(io.pins.gpio5, Pull::Up); + let pin_a = Input::new(peripherals.pins.gpio4, Pull::Up); + let pin_b = Input::new(peripherals.pins.gpio5, Pull::Up); let (input_a, _) = pin_a.split(); let (input_b, _) = pin_b.split(); diff --git a/examples/src/bin/qspi_flash.rs b/examples/src/bin/qspi_flash.rs index cd901df7c31..021642ad71f 100644 --- a/examples/src/bin/qspi_flash.rs +++ b/examples/src/bin/qspi_flash.rs @@ -46,22 +46,22 @@ use esp_println::{print, println}; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let sclk = io.pins.gpio0; - let miso = io.pins.gpio2; - let mosi = io.pins.gpio4; - let sio2 = io.pins.gpio5; - let sio3 = io.pins.gpio13; - let cs = io.pins.gpio14; + let sclk = peripherals.pins.gpio0; + let miso = peripherals.pins.gpio2; + let mosi = peripherals.pins.gpio4; + let sio2 = peripherals.pins.gpio5; + let sio3 = peripherals.pins.gpio13; + let cs = peripherals.pins.gpio14; } else { - let sclk = io.pins.gpio0; - let miso = io.pins.gpio1; - let mosi = io.pins.gpio2; - let sio2 = io.pins.gpio3; - let sio3 = io.pins.gpio4; - let cs = io.pins.gpio5; + let sclk = peripherals.pins.gpio0; + let miso = peripherals.pins.gpio1; + let mosi = peripherals.pins.gpio2; + let sio2 = peripherals.pins.gpio3; + let sio3 = peripherals.pins.gpio4; + let cs = peripherals.pins.gpio5; } } diff --git a/examples/src/bin/rmt_rx.rs b/examples/src/bin/rmt_rx.rs index 948b6c8c6ef..c3fa61ccb1a 100644 --- a/examples/src/bin/rmt_rx.rs +++ b/examples/src/bin/rmt_rx.rs @@ -26,8 +26,8 @@ const WIDTH: usize = 80; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let mut out = Output::new(io.pins.gpio5, Level::Low); + let io = Io::new(peripherals.IO_MUX); + let mut out = Output::new(peripherals.pins.gpio5, Level::Low); cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { @@ -47,11 +47,11 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2"))] { - let mut channel = rmt.channel0.configure(io.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel0.configure(peripherals.pins.gpio4, rx_config).unwrap(); } else if #[cfg(feature = "esp32s3")] { - let mut channel = rmt.channel7.configure(io.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel7.configure(peripherals.pins.gpio4, rx_config).unwrap(); } else { - let mut channel = rmt.channel2.configure(io.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel2.configure(peripherals.pins.gpio4, rx_config).unwrap(); } } diff --git a/examples/src/bin/rmt_tx.rs b/examples/src/bin/rmt_tx.rs index 6d16c26298f..58403846e69 100644 --- a/examples/src/bin/rmt_tx.rs +++ b/examples/src/bin/rmt_tx.rs @@ -22,7 +22,7 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { @@ -39,7 +39,10 @@ fn main() -> ! { ..TxChannelConfig::default() }; - let mut channel = rmt.channel0.configure(io.pins.gpio4, tx_config).unwrap(); + let mut channel = rmt + .channel0 + .configure(peripherals.pins.gpio4, tx_config) + .unwrap(); let delay = Delay::new(); diff --git a/examples/src/bin/serial_interrupts.rs b/examples/src/bin/serial_interrupts.rs index daabb9ff27f..548fabe0bf5 100644 --- a/examples/src/bin/serial_interrupts.rs +++ b/examples/src/bin/serial_interrupts.rs @@ -27,22 +27,22 @@ fn main() -> ! { let delay = Delay::new(); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let (tx_pin, rx_pin) = (io.pins.gpio1, io.pins.gpio3); + let (tx_pin, rx_pin) = (peripherals.pins.gpio1, peripherals.pins.gpio3); } else if #[cfg(feature = "esp32c2")] { - let (tx_pin, rx_pin) = (io.pins.gpio20, io.pins.gpio19); + let (tx_pin, rx_pin) = (peripherals.pins.gpio20, peripherals.pins.gpio19); } else if #[cfg(feature = "esp32c3")] { - let (tx_pin, rx_pin) = (io.pins.gpio21, io.pins.gpio20); + let (tx_pin, rx_pin) = (peripherals.pins.gpio21, peripherals.pins.gpio20); } else if #[cfg(feature = "esp32c6")] { - let (tx_pin, rx_pin) = (io.pins.gpio16, io.pins.gpio17); + let (tx_pin, rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); } else if #[cfg(feature = "esp32h2")] { - let (tx_pin, rx_pin) = (io.pins.gpio24, io.pins.gpio23); + let (tx_pin, rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let (tx_pin, rx_pin) = (io.pins.gpio43, io.pins.gpio44); + let (tx_pin, rx_pin) = (peripherals.pins.gpio43, peripherals.pins.gpio44); } } let config = Config::default().rx_fifo_full_threshold(30); diff --git a/examples/src/bin/sleep_timer_ext0.rs b/examples/src/bin/sleep_timer_ext0.rs index 8803d2b4955..bf2ac3b0db3 100644 --- a/examples/src/bin/sleep_timer_ext0.rs +++ b/examples/src/bin/sleep_timer_ext0.rs @@ -32,8 +32,8 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let ext0_pin = Input::new(io.pins.gpio4, Pull::None); + let io = Io::new(peripherals.IO_MUX); + let ext0_pin = Input::new(peripherals.pins.gpio4, Pull::None); println!("up and runnning!"); let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn); diff --git a/examples/src/bin/sleep_timer_ext1.rs b/examples/src/bin/sleep_timer_ext1.rs index 83a046c6e3b..1ae33fe6975 100644 --- a/examples/src/bin/sleep_timer_ext1.rs +++ b/examples/src/bin/sleep_timer_ext1.rs @@ -33,9 +33,9 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let pin_0 = Input::new(io.pins.gpio4, Pull::None); - let mut pin_2 = io.pins.gpio2; + let io = Io::new(peripherals.IO_MUX); + let pin_0 = Input::new(peripherals.pins.gpio4, Pull::None); + let mut pin_2 = peripherals.pins.gpio2; println!("up and runnning!"); let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn); diff --git a/examples/src/bin/sleep_timer_lpio.rs b/examples/src/bin/sleep_timer_lpio.rs index 73e6a8f7a75..950ab8436fc 100644 --- a/examples/src/bin/sleep_timer_lpio.rs +++ b/examples/src/bin/sleep_timer_lpio.rs @@ -34,9 +34,9 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let pin2 = Input::new(io.pins.gpio2, Pull::None); - let mut pin3 = io.pins.gpio3; + let io = Io::new(peripherals.IO_MUX); + let pin2 = Input::new(peripherals.pins.gpio2, Pull::None); + let mut pin3 = peripherals.pins.gpio3; println!("up and runnning!"); let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn); diff --git a/examples/src/bin/sleep_timer_rtcio.rs b/examples/src/bin/sleep_timer_rtcio.rs index d857d4a06f8..e3c4a19b74b 100644 --- a/examples/src/bin/sleep_timer_rtcio.rs +++ b/examples/src/bin/sleep_timer_rtcio.rs @@ -36,7 +36,7 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let mut rtc = Rtc::new(peripherals.LPWR); println!("up and runnning!"); @@ -50,16 +50,16 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32c3", feature = "esp32c2"))] { - let pin2 = Input::new(io.pins.gpio2, Pull::None); - let mut pin3 = io.pins.gpio3; + let pin2 = Input::new(peripherals.pins.gpio2, Pull::None); + let mut pin3 = peripherals.pins.gpio3; let wakeup_pins: &mut [(&mut dyn gpio::RtcPinWithResistors, WakeupLevel)] = &mut [ (&mut *pin2.into_ref(), WakeupLevel::Low), (&mut pin3, WakeupLevel::High), ]; } else if #[cfg(feature = "esp32s3")] { - let pin17 = Input::new(io.pins.gpio17, Pull::None); - let mut pin18 = io.pins.gpio18; + let pin17 = Input::new(peripherals.pins.gpio17, Pull::None); + let mut pin18 = peripherals.pins.gpio18; let wakeup_pins: &mut [(&mut dyn gpio::RtcPin, WakeupLevel)] = &mut [ (&mut *pin17.into_ref(), WakeupLevel::Low), diff --git a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs index 28266b67e93..4c446af19b4 100644 --- a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs +++ b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs @@ -44,22 +44,22 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let sclk = io.pins.gpio0; - let miso = io.pins.gpio2; - let mosi = io.pins.gpio4; - let sio2 = io.pins.gpio5; - let sio3 = io.pins.gpio13; - let cs = io.pins.gpio14; + let sclk = peripherals.pins.gpio0; + let miso = peripherals.pins.gpio2; + let mosi = peripherals.pins.gpio4; + let sio2 = peripherals.pins.gpio5; + let sio3 = peripherals.pins.gpio13; + let cs = peripherals.pins.gpio14; } else { - let sclk = io.pins.gpio0; - let miso = io.pins.gpio1; - let mosi = io.pins.gpio2; - let sio2 = io.pins.gpio3; - let sio3 = io.pins.gpio4; - let cs = io.pins.gpio5; + let sclk = peripherals.pins.gpio0; + let miso = peripherals.pins.gpio1; + let mosi = peripherals.pins.gpio2; + let sio2 = peripherals.pins.gpio3; + let sio3 = peripherals.pins.gpio4; + let cs = peripherals.pins.gpio5; } } diff --git a/examples/src/bin/spi_loopback.rs b/examples/src/bin/spi_loopback.rs index 38e9d6f1ed6..8b0e48ecce9 100644 --- a/examples/src/bin/spi_loopback.rs +++ b/examples/src/bin/spi_loopback.rs @@ -32,10 +32,10 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio0; - let miso_mosi = io.pins.gpio2; - let cs = io.pins.gpio5; + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio0; + let miso_mosi = peripherals.pins.gpio2; + let cs = peripherals.pins.gpio5; let miso = unsafe { miso_mosi.clone_unchecked() }; diff --git a/examples/src/bin/spi_loopback_dma.rs b/examples/src/bin/spi_loopback_dma.rs index e9bc827ff7a..6ae4b8ecb35 100644 --- a/examples/src/bin/spi_loopback_dma.rs +++ b/examples/src/bin/spi_loopback_dma.rs @@ -36,11 +36,11 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio0; - let miso = io.pins.gpio2; - let mosi = io.pins.gpio4; - let cs = io.pins.gpio5; + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio0; + let miso = peripherals.pins.gpio2; + let mosi = peripherals.pins.gpio4; + let cs = peripherals.pins.gpio5; let dma = Dma::new(peripherals.DMA); diff --git a/examples/src/bin/spi_loopback_dma_psram.rs b/examples/src/bin/spi_loopback_dma_psram.rs index 0ee76893cd8..dcdadca8ef1 100644 --- a/examples/src/bin/spi_loopback_dma_psram.rs +++ b/examples/src/bin/spi_loopback_dma_psram.rs @@ -63,11 +63,11 @@ fn main() -> ! { esp_alloc::psram_allocator!(peripherals.PSRAM, esp_hal::psram); let delay = Delay::new(); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio42; - let mosi = io.pins.gpio48; + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio42; + let mosi = peripherals.pins.gpio48; let miso = unsafe { mosi.clone_unchecked() }; - let cs = io.pins.gpio38; + let cs = peripherals.pins.gpio38; let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; diff --git a/examples/src/bin/touch.rs b/examples/src/bin/touch.rs index 22a324c28e7..5a15fb83f4b 100644 --- a/examples/src/bin/touch.rs +++ b/examples/src/bin/touch.rs @@ -49,13 +49,13 @@ fn main() -> ! { esp_println::logger::init_logger_from_env(); let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let mut rtc = Rtc::new(peripherals.LPWR); rtc.set_interrupt_handler(interrupt_handler); - let touch_pin0 = io.pins.gpio2; - let touch_pin1 = io.pins.gpio4; + let touch_pin0 = peripherals.pins.gpio2; + let touch_pin1 = peripherals.pins.gpio4; let touch_cfg = Some(TouchConfig { measurement_duration: Some(0x2000), diff --git a/examples/src/bin/twai.rs b/examples/src/bin/twai.rs index fa0bcf9ee8e..9327cb99625 100644 --- a/examples/src/bin/twai.rs +++ b/examples/src/bin/twai.rs @@ -40,13 +40,13 @@ use nb::block; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); // Without an external transceiver, we only need a single line between the two MCUs. - let (rx_pin, tx_pin) = io.pins.gpio2.split(); + let (rx_pin, tx_pin) = peripherals.pins.gpio2.split(); // Use these if you want to use an external transceiver: - // let tx_pin = io.pins.gpio2; - // let rx_pin = io.pins.gpio0; + // let tx_pin = peripherals.pins.gpio2; + // let rx_pin = peripherals.pins.gpio0; // The speed of the bus. const TWAI_BAUDRATE: twai::BaudRate = twai::BaudRate::B125K; diff --git a/examples/src/bin/ulp_riscv_core_basic.rs b/examples/src/bin/ulp_riscv_core_basic.rs index d89eda74521..4a3da26e0fd 100644 --- a/examples/src/bin/ulp_riscv_core_basic.rs +++ b/examples/src/bin/ulp_riscv_core_basic.rs @@ -23,8 +23,8 @@ use esp_println::{print, println}; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let pin = LowPowerOutput::new(io.pins.gpio1); + let io = Io::new(peripherals.IO_MUX); + let pin = LowPowerOutput::new(peripherals.pins.gpio1); let mut ulp_core = ulp_core::UlpCore::new(peripherals.ULP_RISCV_CORE); diff --git a/examples/src/bin/usb_serial.rs b/examples/src/bin/usb_serial.rs index aee87614333..1ef65bcb7dc 100644 --- a/examples/src/bin/usb_serial.rs +++ b/examples/src/bin/usb_serial.rs @@ -28,9 +28,13 @@ static mut EP_MEMORY: [u32; 1024] = [0; 1024]; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let usb = Usb::new(peripherals.USB0, io.pins.gpio20, io.pins.gpio19); + let usb = Usb::new( + peripherals.USB0, + peripherals.pins.gpio20, + peripherals.pins.gpio19, + ); let usb_bus = UsbBus::new(usb, unsafe { &mut *addr_of_mut!(EP_MEMORY) }); let mut serial = SerialPort::new(&usb_bus); diff --git a/examples/src/bin/wifi_ble.rs b/examples/src/bin/wifi_ble.rs index 26ac4f4becf..8509113934b 100644 --- a/examples/src/bin/wifi_ble.rs +++ b/examples/src/bin/wifi_ble.rs @@ -54,13 +54,13 @@ fn main() -> ! { ) .unwrap(); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let button = Input::new(io.pins.gpio0, Pull::Down); + let button = Input::new(peripherals.pins.gpio0, Pull::Down); } else { - let button = Input::new(io.pins.gpio9, Pull::Down); + let button = Input::new(peripherals.pins.gpio9, Pull::Down); } } diff --git a/examples/src/bin/wifi_embassy_ble.rs b/examples/src/bin/wifi_embassy_ble.rs index 5ba16b69863..823c63883d5 100644 --- a/examples/src/bin/wifi_embassy_ble.rs +++ b/examples/src/bin/wifi_embassy_ble.rs @@ -70,12 +70,12 @@ async fn main(_spawner: Spawner) -> ! { .unwrap() ); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let button = Input::new(io.pins.gpio0, Pull::Down); + let button = Input::new(peripherals.pins.gpio0, Pull::Down); } else { - let button = Input::new(io.pins.gpio9, Pull::Down); + let button = Input::new(peripherals.pins.gpio9, Pull::Down); } } diff --git a/hil-test/src/lib.rs b/hil-test/src/lib.rs index 8dbf121735e..04fd7f6e9c4 100644 --- a/hil-test/src/lib.rs +++ b/hil-test/src/lib.rs @@ -27,21 +27,21 @@ use esp_backtrace as _; #[macro_export] macro_rules! i2c_pins { - ($io:expr) => {{ + ($peripherals:expr) => {{ // Order: (SDA, SCL) cfg_if::cfg_if! { if #[cfg(any(esp32s2, esp32s3))] { - ($io.pins.gpio2, $io.pins.gpio3) + ($peripherals.pins.gpio2, $peripherals.pins.gpio3) } else if #[cfg(esp32)] { - ($io.pins.gpio32, $io.pins.gpio33) + ($peripherals.pins.gpio32, $peripherals.pins.gpio33) } else if #[cfg(esp32c6)] { - ($io.pins.gpio6, $io.pins.gpio7) + ($peripherals.pins.gpio6, $peripherals.pins.gpio7) } else if #[cfg(esp32h2)] { - ($io.pins.gpio12, $io.pins.gpio22) + ($peripherals.pins.gpio12, $peripherals.pins.gpio22) } else if #[cfg(esp32c2)] { - ($io.pins.gpio18, $io.pins.gpio9) + ($peripherals.pins.gpio18, $peripherals.pins.gpio9) } else { - ($io.pins.gpio4, $io.pins.gpio5) + ($peripherals.pins.gpio4, $peripherals.pins.gpio5) } } }}; @@ -49,14 +49,14 @@ macro_rules! i2c_pins { #[macro_export] macro_rules! common_test_pins { - ($io:expr) => {{ + ($peripherals:expr) => {{ cfg_if::cfg_if! { if #[cfg(any(esp32s2, esp32s3))] { - ($io.pins.gpio9, $io.pins.gpio10) + ($peripherals.pins.gpio9, $peripherals.pins.gpio10) } else if #[cfg(esp32)] { - ($io.pins.gpio26, $io.pins.gpio27) + ($peripherals.pins.gpio26, $peripherals.pins.gpio27) } else { - ($io.pins.gpio2, $io.pins.gpio3) + ($peripherals.pins.gpio2, $peripherals.pins.gpio3) } } }}; @@ -66,18 +66,18 @@ macro_rules! common_test_pins { // beware: it has a pullup. #[macro_export] macro_rules! unconnected_pin { - ($io:expr) => {{ + ($peripherals:expr) => {{ cfg_if::cfg_if! { if #[cfg(any(esp32, esp32s2, esp32s3))] { - $io.pins.gpio0 + $peripherals.pins.gpio0 } else if #[cfg(esp32c6)] { - $io.pins.gpio9 + $peripherals.pins.gpio9 } else if #[cfg(esp32h2)] { - $io.pins.gpio9 + $peripherals.pins.gpio9 } else if #[cfg(esp32c2)] { - $io.pins.gpio8 + $peripherals.pins.gpio8 } else { - $io.pins.gpio9 + $peripherals.pins.gpio9 } } }}; diff --git a/hil-test/tests/gpio.rs b/hil-test/tests/gpio.rs index eaed133de9e..1d999fbf3bf 100644 --- a/hil-test/tests/gpio.rs +++ b/hil-test/tests/gpio.rs @@ -51,12 +51,12 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let mut io = Io::new(peripherals.IO_MUX); io.set_interrupt_handler(interrupt_handler); let delay = Delay::new(); - let (gpio1, gpio2) = hil_test::common_test_pins!(io); + let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals); let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); diff --git a/hil-test/tests/i2c.rs b/hil-test/tests/i2c.rs index 09718abf151..4281b70ff3f 100644 --- a/hil-test/tests/i2c.rs +++ b/hil-test/tests/i2c.rs @@ -33,9 +33,9 @@ mod tests { #[init] fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (sda, scl) = hil_test::i2c_pins!(io); + let (sda, scl) = hil_test::i2c_pins!(peripherals); // Create a new peripheral object with the described wiring and standard // I2C clock speed: diff --git a/hil-test/tests/i2s.rs b/hil-test/tests/i2s.rs index 7610e7791ff..54b0f91ef29 100644 --- a/hil-test/tests/i2s.rs +++ b/hil-test/tests/i2s.rs @@ -112,7 +112,7 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let dma = Dma::new(peripherals.DMA); diff --git a/hil-test/tests/lcd_cam_i8080.rs b/hil-test/tests/lcd_cam_i8080.rs index 1d4555bfa52..0f7b47f91bd 100644 --- a/hil-test/tests/lcd_cam_i8080.rs +++ b/hil-test/tests/lcd_cam_i8080.rs @@ -44,7 +44,7 @@ mod tests { let dma = Dma::new(peripherals.DMA); let lcd_cam = LcdCam::new(peripherals.LCD_CAM); let pcnt = Pcnt::new(peripherals.PCNT); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, DATA_SIZE); let dma_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap(); @@ -102,11 +102,11 @@ mod tests { // issue with configuring pins as outputs after inputs have been sorted // out. See https://github.com/esp-rs/esp-hal/pull/2173#issue-2529323702 - let (unit_ctrl, cs_signal) = ctx.io.pins.gpio8.split(); - let (unit0_input, unit0_signal) = ctx.io.pins.gpio11.split(); - let (unit1_input, unit1_signal) = ctx.io.pins.gpio12.split(); - let (unit2_input, unit2_signal) = ctx.io.pins.gpio16.split(); - let (unit3_input, unit3_signal) = ctx.io.pins.gpio17.split(); + let (unit_ctrl, cs_signal) = ctx.peripherals.pins.gpio8.split(); + let (unit0_input, unit0_signal) = ctx.peripherals.pins.gpio11.split(); + let (unit1_input, unit1_signal) = ctx.peripherals.pins.gpio12.split(); + let (unit2_input, unit2_signal) = ctx.peripherals.pins.gpio16.split(); + let (unit3_input, unit3_signal) = ctx.peripherals.pins.gpio17.split(); let pcnt = ctx.pcnt; @@ -213,11 +213,11 @@ mod tests { // issue with configuring pins as outputs after inputs have been sorted // out. See https://github.com/esp-rs/esp-hal/pull/2173#issue-2529323702 - let (unit_ctrl, cs_signal) = ctx.io.pins.gpio8.split(); - let (unit0_input, unit0_signal) = ctx.io.pins.gpio11.split(); - let (unit1_input, unit1_signal) = ctx.io.pins.gpio12.split(); - let (unit2_input, unit2_signal) = ctx.io.pins.gpio16.split(); - let (unit3_input, unit3_signal) = ctx.io.pins.gpio17.split(); + let (unit_ctrl, cs_signal) = ctx.peripherals.pins.gpio8.split(); + let (unit0_input, unit0_signal) = ctx.peripherals.pins.gpio11.split(); + let (unit1_input, unit1_signal) = ctx.peripherals.pins.gpio12.split(); + let (unit2_input, unit2_signal) = ctx.peripherals.pins.gpio16.split(); + let (unit3_input, unit3_signal) = ctx.peripherals.pins.gpio17.split(); let pcnt = ctx.pcnt; diff --git a/hil-test/tests/parl_io_tx.rs b/hil-test/tests/parl_io_tx.rs index f2b2cceb559..2bbf0a4642d 100644 --- a/hil-test/tests/parl_io_tx.rs +++ b/hil-test/tests/parl_io_tx.rs @@ -52,9 +52,9 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let (clock, _) = hil_test::common_test_pins!(io); - let valid = hil_test::unconnected_pin!(io); + let io = Io::new(peripherals.IO_MUX); + let (clock, _) = hil_test::common_test_pins!(peripherals); + let valid = hil_test::unconnected_pin!(peripherals); let (clock_loopback, clock) = clock.split(); let (valid_loopback, valid) = valid.split(); let pcnt = Pcnt::new(peripherals.PCNT); diff --git a/hil-test/tests/parl_io_tx_async.rs b/hil-test/tests/parl_io_tx_async.rs index 2c4522f02cf..a345025be2a 100644 --- a/hil-test/tests/parl_io_tx_async.rs +++ b/hil-test/tests/parl_io_tx_async.rs @@ -54,9 +54,9 @@ mod tests { async fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let (clock, _) = hil_test::common_test_pins!(io); - let valid = hil_test::unconnected_pin!(io); + let io = Io::new(peripherals.IO_MUX); + let (clock, _) = hil_test::common_test_pins!(peripherals); + let valid = hil_test::unconnected_pin!(peripherals); let (clock_loopback, clock) = clock.split(); let (valid_loopback, valid) = valid.split(); let pcnt = Pcnt::new(peripherals.PCNT); diff --git a/hil-test/tests/pcnt.rs b/hil-test/tests/pcnt.rs index d1857be61a8..de93787a275 100644 --- a/hil-test/tests/pcnt.rs +++ b/hil-test/tests/pcnt.rs @@ -28,9 +28,9 @@ mod tests { fn init() -> Context<'static> { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (din, dout) = hil_test::common_test_pins!(io); + let (din, dout) = hil_test::common_test_pins!(peripherals); let din = din.degrade(); let dout = dout.degrade(); diff --git a/hil-test/tests/qspi.rs b/hil-test/tests/qspi.rs index 8b61a26dd57..125b1a69f92 100644 --- a/hil-test/tests/qspi.rs +++ b/hil-test/tests/qspi.rs @@ -184,10 +184,10 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (mut pin, mut pin_mirror) = hil_test::common_test_pins!(io); - let mut unconnected_pin = hil_test::unconnected_pin!(io); + let (mut pin, mut pin_mirror) = hil_test::common_test_pins!(peripherals); + let mut unconnected_pin = hil_test::unconnected_pin!(peripherals); // Make sure pins have no pullups let _ = Input::new(&mut pin, Pull::Down); diff --git a/hil-test/tests/rmt.rs b/hil-test/tests/rmt.rs index 5ad82d4af71..4d2df21d1f4 100644 --- a/hil-test/tests/rmt.rs +++ b/hil-test/tests/rmt.rs @@ -25,7 +25,7 @@ mod tests { fn rmt_loopback() { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { @@ -37,7 +37,7 @@ mod tests { let rmt = Rmt::new(peripherals.RMT, freq).unwrap(); - let (rx, tx) = hil_test::common_test_pins!(io); + let (rx, tx) = hil_test::common_test_pins!(peripherals); let tx_config = TxChannelConfig { clk_divider: 255, diff --git a/hil-test/tests/spi_full_duplex.rs b/hil-test/tests/spi_full_duplex.rs index 2b445303124..18ba0f78b4f 100644 --- a/hil-test/tests/spi_full_duplex.rs +++ b/hil-test/tests/spi_full_duplex.rs @@ -58,9 +58,9 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio0; - let (_, mosi) = hil_test::common_test_pins!(io); + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio0; + let (_, mosi) = hil_test::common_test_pins!(peripherals); let dma = Dma::new(peripherals.DMA); diff --git a/hil-test/tests/spi_half_duplex_read.rs b/hil-test/tests/spi_half_duplex_read.rs index dc83a638ce0..1630f5ef4e1 100644 --- a/hil-test/tests/spi_half_duplex_read.rs +++ b/hil-test/tests/spi_half_duplex_read.rs @@ -33,9 +33,9 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio0; - let (miso, miso_mirror) = hil_test::common_test_pins!(io); + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio0; + let (miso, miso_mirror) = hil_test::common_test_pins!(peripherals); let miso_mirror = Output::new(miso_mirror, Level::High); diff --git a/hil-test/tests/spi_half_duplex_write.rs b/hil-test/tests/spi_half_duplex_write.rs index 88a51641e41..f4f9c7970c2 100644 --- a/hil-test/tests/spi_half_duplex_write.rs +++ b/hil-test/tests/spi_half_duplex_write.rs @@ -35,9 +35,9 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio0; - let (mosi, _) = hil_test::common_test_pins!(io); + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio0; + let (mosi, _) = hil_test::common_test_pins!(peripherals); let pcnt = Pcnt::new(peripherals.PCNT); let dma = Dma::new(peripherals.DMA); diff --git a/hil-test/tests/spi_half_duplex_write_psram.rs b/hil-test/tests/spi_half_duplex_write_psram.rs index aaf9fb7b979..296466f277a 100644 --- a/hil-test/tests/spi_half_duplex_write_psram.rs +++ b/hil-test/tests/spi_half_duplex_write_psram.rs @@ -53,9 +53,9 @@ mod tests { let peripherals = esp_hal::init(esp_hal::Config::default()); esp_alloc::psram_allocator!(peripherals.PSRAM, esp_hal::psram); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let sclk = io.pins.gpio0; - let (mosi, _) = hil_test::common_test_pins!(io); + let io = Io::new(peripherals.IO_MUX); + let sclk = peripherals.pins.gpio0; + let (mosi, _) = hil_test::common_test_pins!(peripherals); let pcnt = Pcnt::new(peripherals.PCNT); let dma = Dma::new(peripherals.DMA); diff --git a/hil-test/tests/spi_slave.rs b/hil-test/tests/spi_slave.rs index 72cd12de3d6..6a0bbb877d0 100644 --- a/hil-test/tests/spi_slave.rs +++ b/hil-test/tests/spi_slave.rs @@ -103,11 +103,11 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (mosi_pin, miso_pin) = hil_test::i2c_pins!(io); - let (sclk_pin, _) = hil_test::common_test_pins!(io); - let cs_pin = hil_test::unconnected_pin!(io); + let (mosi_pin, miso_pin) = hil_test::i2c_pins!(peripherals); + let (sclk_pin, _) = hil_test::common_test_pins!(peripherals); + let cs_pin = hil_test::unconnected_pin!(peripherals); let dma = Dma::new(peripherals.DMA); diff --git a/hil-test/tests/twai.rs b/hil-test/tests/twai.rs index a1be5524ef9..a059ebc47da 100644 --- a/hil-test/tests/twai.rs +++ b/hil-test/tests/twai.rs @@ -28,9 +28,9 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (loopback_pin, _) = hil_test::common_test_pins!(io); + let (loopback_pin, _) = hil_test::common_test_pins!(peripherals); let (rx, tx) = loopback_pin.split(); diff --git a/hil-test/tests/uart.rs b/hil-test/tests/uart.rs index 00e8be5f739..b5ab16e4f72 100644 --- a/hil-test/tests/uart.rs +++ b/hil-test/tests/uart.rs @@ -28,9 +28,9 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (_, pin) = hil_test::common_test_pins!(io); + let (_, pin) = hil_test::common_test_pins!(peripherals); let (rx, tx) = pin.split(); diff --git a/hil-test/tests/uart_async.rs b/hil-test/tests/uart_async.rs index 5adcd854ac8..9cf525c4911 100644 --- a/hil-test/tests/uart_async.rs +++ b/hil-test/tests/uart_async.rs @@ -22,9 +22,9 @@ mod tests { async fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (rx, tx) = hil_test::common_test_pins!(io); + let (rx, tx) = hil_test::common_test_pins!(peripherals); let uart = Uart::new(peripherals.UART0, rx, tx).unwrap().into_async(); diff --git a/hil-test/tests/uart_regression.rs b/hil-test/tests/uart_regression.rs index 1892ddaeadf..9a1fdb6f806 100644 --- a/hil-test/tests/uart_regression.rs +++ b/hil-test/tests/uart_regression.rs @@ -21,9 +21,9 @@ mod tests { fn test_that_creating_tx_does_not_cause_a_pulse() { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (rx, mut tx) = hil_test::common_test_pins!(io); + let (rx, mut tx) = hil_test::common_test_pins!(peripherals); let mut rx = UartRx::new(peripherals.UART1, rx).unwrap(); diff --git a/hil-test/tests/uart_tx_rx.rs b/hil-test/tests/uart_tx_rx.rs index 7e99e5e9f70..9fb4db2f512 100644 --- a/hil-test/tests/uart_tx_rx.rs +++ b/hil-test/tests/uart_tx_rx.rs @@ -28,9 +28,9 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (rx, tx) = hil_test::common_test_pins!(io); + let (rx, tx) = hil_test::common_test_pins!(peripherals); let tx = UartTx::new(peripherals.UART0, tx).unwrap(); let rx = UartRx::new(peripherals.UART1, rx).unwrap(); diff --git a/hil-test/tests/uart_tx_rx_async.rs b/hil-test/tests/uart_tx_rx_async.rs index 4122d0963e9..6bd4b4a6808 100644 --- a/hil-test/tests/uart_tx_rx_async.rs +++ b/hil-test/tests/uart_tx_rx_async.rs @@ -27,9 +27,9 @@ mod tests { async fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let io = Io::new(peripherals.IO_MUX); - let (rx, tx) = hil_test::common_test_pins!(io); + let (rx, tx) = hil_test::common_test_pins!(peripherals); let tx = UartTx::new(peripherals.UART0, tx).unwrap().into_async(); let rx = UartRx::new(peripherals.UART1, rx).unwrap().into_async(); From da5393245e0f486effadbbbdc5fe7644c9e9e6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 8 Nov 2024 10:03:51 +0100 Subject: [PATCH 2/3] Remove the GPIO peripheral --- esp-hal/CHANGELOG.md | 2 ++ esp-hal/MIGRATING-0.21.md | 18 ++++++++++++ esp-hal/src/analog/adc/mod.rs | 7 +++-- esp-hal/src/analog/dac.rs | 3 -- esp-hal/src/dma/mod.rs | 2 -- esp-hal/src/etm.rs | 2 -- esp-hal/src/gpio/etm.rs | 2 -- esp-hal/src/gpio/lp_io.rs | 7 +++-- esp-hal/src/gpio/mod.rs | 7 ++--- esp-hal/src/gpio/rtc_io.rs | 2 -- esp-hal/src/i2c/master/mod.rs | 1 - esp-hal/src/i2s/master.rs | 2 -- esp-hal/src/lcd_cam/cam.rs | 2 -- esp-hal/src/lcd_cam/lcd/i8080.rs | 2 -- esp-hal/src/ledc/mod.rs | 2 -- esp-hal/src/lib.rs | 1 - esp-hal/src/mcpwm/mod.rs | 3 -- esp-hal/src/mcpwm/operator.rs | 2 -- esp-hal/src/rmt.rs | 2 -- esp-hal/src/rng.rs | 12 ++++---- esp-hal/src/rom/md5.rs | 4 --- esp-hal/src/soc/esp32/efuse/mod.rs | 2 -- esp-hal/src/soc/esp32/peripherals.rs | 1 - esp-hal/src/soc/esp32c2/efuse/mod.rs | 2 -- esp-hal/src/soc/esp32c2/peripherals.rs | 1 - esp-hal/src/soc/esp32c3/efuse/mod.rs | 2 -- esp-hal/src/soc/esp32c3/peripherals.rs | 1 - esp-hal/src/soc/esp32c6/efuse/mod.rs | 2 -- esp-hal/src/soc/esp32c6/peripherals.rs | 1 - esp-hal/src/soc/esp32h2/efuse/mod.rs | 2 -- esp-hal/src/soc/esp32h2/peripherals.rs | 1 - esp-hal/src/soc/esp32s2/efuse/mod.rs | 2 -- esp-hal/src/soc/esp32s2/peripherals.rs | 1 - esp-hal/src/soc/esp32s3/efuse/mod.rs | 2 -- esp-hal/src/soc/esp32s3/peripherals.rs | 1 - esp-hal/src/spi/master.rs | 2 -- esp-hal/src/spi/slave.rs | 10 +++---- esp-hal/src/touch.rs | 2 -- esp-hal/src/twai/mod.rs | 4 --- esp-hal/src/uart.rs | 13 --------- examples/src/bin/adc.rs | 2 -- examples/src/bin/adc_cal.rs | 2 -- examples/src/bin/advanced_serial.rs | 4 +-- examples/src/bin/blinky.rs | 4 +-- examples/src/bin/blinky_erased_pins.rs | 4 +-- examples/src/bin/dac.rs | 4 +-- examples/src/bin/embassy_i2c.rs | 1 - .../embassy_i2c_bmp180_calibration_data.rs | 1 - examples/src/bin/embassy_i2s_parallel.rs | 2 -- examples/src/bin/embassy_i2s_read.rs | 3 -- examples/src/bin/embassy_i2s_sound.rs | 3 -- examples/src/bin/embassy_multicore.rs | 4 +-- .../src/bin/embassy_multicore_interrupt.rs | 4 +-- examples/src/bin/embassy_parl_io_rx.rs | 10 ++++--- examples/src/bin/embassy_parl_io_tx.rs | 10 ++++--- examples/src/bin/embassy_rmt_rx.rs | 4 +-- examples/src/bin/embassy_rmt_tx.rs | 3 -- examples/src/bin/embassy_serial.rs | 3 -- examples/src/bin/embassy_spi.rs | 2 -- examples/src/bin/embassy_touch.rs | 2 -- examples/src/bin/embassy_twai.rs | 3 -- examples/src/bin/embassy_usb_serial.rs | 9 +++--- examples/src/bin/embassy_wait.rs | 4 +-- examples/src/bin/etm_blinky_systimer.rs | 2 -- examples/src/bin/etm_gpio.rs | 3 -- examples/src/bin/hello_world.rs | 4 +-- examples/src/bin/i2s_parallel.rs | 2 -- examples/src/bin/i2s_read.rs | 3 -- examples/src/bin/i2s_sound.rs | 3 -- examples/src/bin/ieee802154_sniffer.rs | 4 +-- examples/src/bin/lcd_cam_ov2640.rs | 3 -- examples/src/bin/lcd_i8080.rs | 4 +-- examples/src/bin/ledc.rs | 2 -- examples/src/bin/lp_core_basic.rs | 4 +-- examples/src/bin/lp_core_i2c.rs | 4 +-- examples/src/bin/lp_core_uart.rs | 7 +---- examples/src/bin/mcpwm.rs | 2 -- examples/src/bin/parl_io_rx.rs | 3 -- examples/src/bin/parl_io_tx.rs | 3 -- examples/src/bin/pcnt_encoder.rs | 4 +-- examples/src/bin/qspi_flash.rs | 2 -- examples/src/bin/rmt_rx.rs | 3 +- examples/src/bin/rmt_tx.rs | 3 -- examples/src/bin/serial_interrupts.rs | 3 -- examples/src/bin/sleep_timer_ext0.rs | 3 +- examples/src/bin/sleep_timer_ext1.rs | 3 +- examples/src/bin/sleep_timer_lpio.rs | 3 +- examples/src/bin/sleep_timer_rtcio.rs | 3 +- .../spi_halfduplex_read_manufacturer_id.rs | 2 -- examples/src/bin/spi_loopback.rs | 2 -- examples/src/bin/spi_loopback_dma.rs | 2 -- examples/src/bin/spi_loopback_dma_psram.rs | 2 -- examples/src/bin/spi_slave_dma.rs | 20 ++++++------- examples/src/bin/touch.rs | 4 +-- examples/src/bin/twai.rs | 3 -- examples/src/bin/ulp_riscv_core_basic.rs | 7 +---- examples/src/bin/usb_serial.rs | 3 -- examples/src/bin/wifi_ble.rs | 4 +-- examples/src/bin/wifi_embassy_ble.rs | 3 +- hil-test/tests/embassy_interrupt_spi_dma.rs | 3 +- hil-test/tests/gpio_custom_handler.rs | 8 ++---- hil-test/tests/i2c.rs | 2 -- hil-test/tests/i2s.rs | 28 ++++++------------- hil-test/tests/lcd_cam_i8080.rs | 28 +++++++++---------- hil-test/tests/parl_io_tx.rs | 2 -- hil-test/tests/parl_io_tx_async.rs | 2 -- hil-test/tests/pcnt.rs | 4 +-- hil-test/tests/qspi.rs | 4 +-- hil-test/tests/rmt.rs | 3 -- hil-test/tests/spi_full_duplex.rs | 3 +- hil-test/tests/spi_half_duplex_read.rs | 3 +- hil-test/tests/spi_half_duplex_write.rs | 3 +- hil-test/tests/spi_half_duplex_write_psram.rs | 1 - hil-test/tests/spi_slave.rs | 4 +-- hil-test/tests/twai.rs | 3 -- hil-test/tests/uart.rs | 3 -- hil-test/tests/uart_async.rs | 4 +-- hil-test/tests/uart_regression.rs | 3 -- hil-test/tests/uart_tx_rx.rs | 3 -- hil-test/tests/uart_tx_rx_async.rs | 3 -- 120 files changed, 127 insertions(+), 347 deletions(-) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 224d81239b0..e19c5d07ee7 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -171,6 +171,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SPI transactions are now cancelled if the transfer object (or async Future) is dropped. (#2216) - The DMA channel types have been removed from peripherals (#2261) - `I2C` driver renamed to `I2c` (#2320) +- The GPIO pins are now accessible via `Peripherals` and are no longer part of the `Io` struct (#2508) ### Fixed @@ -215,6 +216,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed `esp_hal::spi::slave::WithDmaSpiN` traits (#2260) - The `WithDmaAes` trait has been removed (#2261) - The `I2s::new_i2s1` constructor has been removed (#2261) +- `Peripherals.GPIO` has been removed (#2508) ## [0.20.1] - 2024-08-30 diff --git a/esp-hal/MIGRATING-0.21.md b/esp-hal/MIGRATING-0.21.md index 57460bd8037..0b74c31f1ea 100644 --- a/esp-hal/MIGRATING-0.21.md +++ b/esp-hal/MIGRATING-0.21.md @@ -1,5 +1,23 @@ # Migration Guide from 0.21.x to v0.22.x +## IO changes + +### GPIO pins are now accessible via `Peripherals` + +```diff + let peripherals = esp_hal::init(Default::default()); +-let io = Io::new(peripherals.GPIO, peripherals.IOMUX); +-let pin = io.pins.gpio5; ++let pin = peripherals.pins.gpio5; +``` + +### `Io` constructor changes + +- `new_with_priority` and `new_no_bind_interrupts` have been removed. + Use `set_priority` to configure the GPIO interrupt priority. + We no longer overwrite interrupt handlers set by user code during initialization. +- `new` no longer takes `peripherals.GPIO` + ## Removed `async`-specific constructors The following async-specific constuctors have been removed: diff --git a/esp-hal/src/analog/adc/mod.rs b/esp-hal/src/analog/adc/mod.rs index 159ab29cafb..053e0ae1f8d 100644 --- a/esp-hal/src/analog/adc/mod.rs +++ b/esp-hal/src/analog/adc/mod.rs @@ -31,10 +31,11 @@ //! # use esp_hal::analog::adc::Attenuation; //! # use esp_hal::analog::adc::Adc; //! # use esp_hal::delay::Delay; -//! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.IO_MUX); #![cfg_attr(esp32, doc = "let analog_pin = peripherals.pins.gpio32;")] -#![cfg_attr(any(esp32s2, esp32s3), doc = "let analog_pin = peripherals.pins.gpio3;")] +#![cfg_attr( + any(esp32s2, esp32s3), + doc = "let analog_pin = peripherals.pins.gpio3;" +)] #![cfg_attr( not(any(esp32, esp32s2, esp32s3)), doc = "let analog_pin = peripherals.pins.gpio2;" diff --git a/esp-hal/src/analog/dac.rs b/esp-hal/src/analog/dac.rs index 2b1c6a44c46..9956375d67c 100644 --- a/esp-hal/src/analog/dac.rs +++ b/esp-hal/src/analog/dac.rs @@ -17,12 +17,9 @@ //! ### Write a value to a DAC channel //! ```rust, no_run #![doc = crate::before_snippet!()] -//! # use esp_hal::gpio::Io; //! # use esp_hal::analog::dac::Dac; //! # use esp_hal::delay::Delay; //! # use embedded_hal::delay::DelayNs; -//! -//! let io = Io::new(peripherals.IO_MUX); #![cfg_attr(esp32, doc = "let dac1_pin = peripherals.pins.gpio25;")] #![cfg_attr(esp32s2, doc = "let dac1_pin = peripherals.pins.gpio17;")] //! let mut dac1 = Dac::new(peripherals.DAC1, dac1_pin); diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index 9710cdff97b..de519b3e3c1 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -18,13 +18,11 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::dma_buffers; -//! # use esp_hal::gpio::Io; //! # use esp_hal::spi::{master::{Config, Spi}, SpiMode}; //! # use esp_hal::dma::{Dma, DmaPriority}; //! let dma = Dma::new(peripherals.DMA); #![cfg_attr(any(esp32, esp32s2), doc = "let dma_channel = dma.spi2channel;")] #![cfg_attr(not(any(esp32, esp32s2)), doc = "let dma_channel = dma.channel0;")] -//! let io = Io::new(peripherals.IO_MUX); //! let sclk = peripherals.pins.gpio0; //! let miso = peripherals.pins.gpio2; //! let mosi = peripherals.pins.gpio4; diff --git a/esp-hal/src/etm.rs b/esp-hal/src/etm.rs index 95155a60fb1..c592978e73e 100644 --- a/esp-hal/src/etm.rs +++ b/esp-hal/src/etm.rs @@ -23,13 +23,11 @@ //! ## Examples //! ```rust, no_run #![doc = crate::before_snippet!()] -//! # use esp_hal::gpio::Io; //! # use esp_hal::gpio::etm::{Channels, InputConfig, OutputConfig}; //! # use esp_hal::etm::Etm; //! # use esp_hal::gpio::Pull; //! # use esp_hal::gpio::Level; //! -//! let io = Io::new(peripherals.IO_MUX); //! let mut led = peripherals.pins.gpio1; //! let button = peripherals.pins.gpio9; //! diff --git a/esp-hal/src/gpio/etm.rs b/esp-hal/src/gpio/etm.rs index 2ff09c0c90e..a3fe2d22448 100644 --- a/esp-hal/src/gpio/etm.rs +++ b/esp-hal/src/gpio/etm.rs @@ -25,7 +25,6 @@ //! ### Toggle an LED When a Button is Pressed //! ```rust, no_run #![doc = crate::before_snippet!()] -//! # use esp_hal::gpio::Io; //! # use esp_hal::gpio::etm::Channels; //! # use esp_hal::etm::Etm; //! # use esp_hal::gpio::etm::InputConfig; @@ -33,7 +32,6 @@ //! # use esp_hal::gpio::Pull; //! # use esp_hal::gpio::Level; //! # -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut led = peripherals.pins.gpio1; //! # let button = peripherals.pins.gpio9; //! diff --git a/esp-hal/src/gpio/lp_io.rs b/esp-hal/src/gpio/lp_io.rs index bee8f20fe01..f744f1916f2 100644 --- a/esp-hal/src/gpio/lp_io.rs +++ b/esp-hal/src/gpio/lp_io.rs @@ -15,15 +15,16 @@ //! chip from Deep-sleep. //! //! # Example +//! //! ## Configure a LP Pin as Output +//! //! ```rust, no_run #![doc = crate::before_snippet!()] -//! use esp_hal::gpio::Io; //! use esp_hal::gpio::lp_io::LowPowerOutput; -//! let io = Io::new(peripherals.IO_MUX); //! // configure GPIO 1 as LP output pin //! let lp_pin: LowPowerOutput<'_, 1> = -//! LowPowerOutput::new(peripherals.pins.gpio1); # } +//! LowPowerOutput::new(peripherals.pins.gpio1); +//! # } //! ``` use core::marker::PhantomData; diff --git a/esp-hal/src/gpio/mod.rs b/esp-hal/src/gpio/mod.rs index 521d2eb4f2b..d07c891d29d 100644 --- a/esp-hal/src/gpio/mod.rs +++ b/esp-hal/src/gpio/mod.rs @@ -18,9 +18,9 @@ //! GPIO interrupts. For more information, see the //! [`Io::set_interrupt_handler`]. //! -//! The pins are accessible via [`Io::pins`]. These pins can then be passed to -//! peripherals (such as SPI, UART, I2C, etc.), to pin drivers or can be -//! [`GpioPin::split`] into peripheral signals. +//! The pins are accessible via [`crate::Peripherals::pins`]. These pins can +//! then be passed to peripherals (such as SPI, UART, I2C, etc.), to pin drivers +//! or can be [`GpioPin::split`] into peripheral signals. //! //! Each pin is a different type initially. Internally, `esp-hal` will often //! erase their types automatically, but they can also be converted into @@ -52,7 +52,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::gpio::{Io, Level, Output}; -//! let io = Io::new(peripherals.IO_MUX); //! let mut led = Output::new(peripherals.pins.gpio5, Level::High); //! # } //! ``` diff --git a/esp-hal/src/gpio/rtc_io.rs b/esp-hal/src/gpio/rtc_io.rs index a265c2ecabb..be7aaf4f501 100644 --- a/esp-hal/src/gpio/rtc_io.rs +++ b/esp-hal/src/gpio/rtc_io.rs @@ -23,8 +23,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::gpio::rtc_io::LowPowerOutput; -//! # use esp_hal::gpio::Io; -//! let io = Io::new(peripherals.IO_MUX); //! // configure GPIO 1 as ULP output pin //! let lp_pin = LowPowerOutput::<'static, 1>::new(peripherals.pins.gpio1); //! # } diff --git a/esp-hal/src/i2c/master/mod.rs b/esp-hal/src/i2c/master/mod.rs index bd4a88b412f..f086982d53c 100644 --- a/esp-hal/src/i2c/master/mod.rs +++ b/esp-hal/src/i2c/master/mod.rs @@ -19,7 +19,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::i2c::master::{Config, I2c}; -//! # use esp_hal::gpio::Io; //! //! // Create a new peripheral object with the described wiring //! // and standard I2C clock speed. diff --git a/esp-hal/src/i2s/master.rs b/esp-hal/src/i2s/master.rs index 3499e5257e1..5da9e95ce26 100644 --- a/esp-hal/src/i2s/master.rs +++ b/esp-hal/src/i2s/master.rs @@ -30,10 +30,8 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::i2s::master::{I2s, Standard, DataFormat}; -//! # use esp_hal::gpio::Io; //! # use esp_hal::dma_buffers; //! # use esp_hal::dma::{Dma, DmaPriority}; -//! # let io = Io::new(peripherals.IO_MUX); //! let dma = Dma::new(peripherals.DMA); #![cfg_attr(any(esp32, esp32s2), doc = "let dma_channel = dma.i2s0channel;")] #![cfg_attr(not(any(esp32, esp32s2)), doc = "let dma_channel = dma.channel0;")] diff --git a/esp-hal/src/lcd_cam/cam.rs b/esp-hal/src/lcd_cam/cam.rs index be60e7ded67..905c8d47d0b 100644 --- a/esp-hal/src/lcd_cam/cam.rs +++ b/esp-hal/src/lcd_cam/cam.rs @@ -16,12 +16,10 @@ //! master mode. //! ```rust, no_run #![doc = crate::before_snippet!()] -//! # use esp_hal::gpio::Io; //! # use esp_hal::lcd_cam::{cam::{Camera, RxEightBits}, LcdCam}; //! # use fugit::RateExtU32; //! # use esp_hal::dma_rx_stream_buffer; //! # use esp_hal::dma::{Dma, DmaPriority}; -//! # let io = Io::new(peripherals.IO_MUX); //! //! # let dma = Dma::new(peripherals.DMA); //! # let channel = dma.channel0; diff --git a/esp-hal/src/lcd_cam/lcd/i8080.rs b/esp-hal/src/lcd_cam/lcd/i8080.rs index 3380a711759..ce4b9e2e6b4 100644 --- a/esp-hal/src/lcd_cam/lcd/i8080.rs +++ b/esp-hal/src/lcd_cam/lcd/i8080.rs @@ -15,11 +15,9 @@ //! //! ```rust, no_run #![doc = crate::before_snippet!()] -//! # use esp_hal::gpio::Io; //! # use esp_hal::lcd_cam::{LcdCam, lcd::i8080::{Config, I8080, TxEightBits}}; //! # use esp_hal::dma_tx_buffer; //! # use esp_hal::dma::{Dma, DmaPriority, DmaTxBuf}; -//! # let io = Io::new(peripherals.IO_MUX); //! //! # let dma = Dma::new(peripherals.DMA); //! # let channel = dma.channel0; diff --git a/esp-hal/src/ledc/mod.rs b/esp-hal/src/ledc/mod.rs index 316b66adc76..fe414ff5677 100644 --- a/esp-hal/src/ledc/mod.rs +++ b/esp-hal/src/ledc/mod.rs @@ -29,8 +29,6 @@ //! # use esp_hal::ledc::timer; //! # use esp_hal::ledc::LowSpeed; //! # use esp_hal::ledc::channel; -//! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.IO_MUX); //! # let led = peripherals.pins.gpio0; //! //! let mut ledc = Ledc::new(peripherals.LEDC); diff --git a/esp-hal/src/lib.rs b/esp-hal/src/lib.rs index a537f6a2982..ff938a3907a 100644 --- a/esp-hal/src/lib.rs +++ b/esp-hal/src/lib.rs @@ -81,7 +81,6 @@ //! }); //! //! // Set GPIO0 as an output, and set its state high initially. -//! let io = Io::new(peripherals.IO_MUX); //! let mut led = Output::new(peripherals.pins.gpio0, Level::High); //! //! let delay = Delay::new(); diff --git a/esp-hal/src/mcpwm/mod.rs b/esp-hal/src/mcpwm/mod.rs index e47bdd1ac6c..8f53ea33e66 100644 --- a/esp-hal/src/mcpwm/mod.rs +++ b/esp-hal/src/mcpwm/mod.rs @@ -52,9 +52,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::mcpwm::{operator::{DeadTimeCfg, PWMStream, PwmPinConfig}, timer::PwmWorkingMode, McPwm, PeripheralClockConfig}; -//! # use esp_hal::gpio::Io; -//! -//! # let io = Io::new(peripherals.IO_MUX); //! # let pin = peripherals.pins.gpio0; //! //! // initialize peripheral diff --git a/esp-hal/src/mcpwm/operator.rs b/esp-hal/src/mcpwm/operator.rs index b14d915f7f3..1b580b72d60 100644 --- a/esp-hal/src/mcpwm/operator.rs +++ b/esp-hal/src/mcpwm/operator.rs @@ -479,8 +479,6 @@ impl embedded_hal::pwm::SetD /// # use esp_hal::{mcpwm, prelude::*}; /// # use esp_hal::mcpwm::{McPwm, PeripheralClockConfig}; /// # use esp_hal::mcpwm::operator::{DeadTimeCfg, PwmPinConfig, PWMStream}; -/// # use esp_hal::gpio::Io; -/// # let io = Io::new(peripherals.IO_MUX); /// // active high complementary using PWMA input /// let bridge_active = DeadTimeCfg::new_ahc(); /// // use PWMB as input for both outputs diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs index 17bf47089e2..67949ea1341 100644 --- a/esp-hal/src/rmt.rs +++ b/esp-hal/src/rmt.rs @@ -54,9 +54,7 @@ //! # use esp_hal::peripherals::Peripherals; //! # use esp_hal::rmt::TxChannelConfig; //! # use esp_hal::rmt::Rmt; -//! # use esp_hal::gpio::Io; //! # use crate::esp_hal::rmt::TxChannelCreator; -//! # let io = Io::new(peripherals.IO_MUX); #![cfg_attr(esp32h2, doc = "let freq = 32.MHz();")] #![cfg_attr(not(esp32h2), doc = "let freq = 80.MHz();")] //! let rmt = Rmt::new(peripherals.RMT, freq).unwrap(); diff --git a/esp-hal/src/rng.rs b/esp-hal/src/rng.rs index a25cd70d22e..d9666e300e3 100644 --- a/esp-hal/src/rng.rs +++ b/esp-hal/src/rng.rs @@ -138,9 +138,7 @@ impl rand_core::RngCore for Rng { /// # use esp_hal::peripherals::Peripherals; /// # use esp_hal::peripherals::ADC1; /// # use esp_hal::analog::adc::{AdcConfig, Attenuation, Adc}; -/// # use esp_hal::gpio::Io; /// -/// let io = Io::new(peripherals.IO_MUX); /// let mut buf = [0u8; 16]; /// /// // ADC is not available from now @@ -152,10 +150,12 @@ impl rand_core::RngCore for Rng { #[cfg_attr(esp32, doc = "let analog_pin = peripherals.pins.gpio32;")] #[cfg_attr(not(esp32), doc = "let analog_pin = peripherals.pins.gpio3;")] /// let mut adc1_config = AdcConfig::new(); -/// let mut adc1_pin = adc1_config.enable_pin(analog_pin, -/// Attenuation::Attenuation11dB); let mut adc1 = -/// Adc::::new(peripherals.ADC1, adc1_config); let pin_value: u16 = -/// nb::block!(adc1.read_oneshot(&mut adc1_pin)).unwrap(); +/// let mut adc1_pin = adc1_config.enable_pin( +/// analog_pin, +/// Attenuation::Attenuation11dB +/// ); +/// let mut adc1 = Adc::::new(peripherals.ADC1, adc1_config); +/// let pin_value: u16 = nb::block!(adc1.read_oneshot(&mut adc1_pin)).unwrap(); /// rng.read(&mut buf); /// true_rand = rng.random(); /// let pin_value: u16 = nb::block!(adc1.read_oneshot(&mut adc1_pin)).unwrap(); diff --git a/esp-hal/src/rom/md5.rs b/esp-hal/src/rom/md5.rs index fa00fb20658..2c249e226df 100644 --- a/esp-hal/src/rom/md5.rs +++ b/esp-hal/src/rom/md5.rs @@ -32,10 +32,8 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::rom::md5; //! # use esp_hal::uart::Uart; -//! # use esp_hal::gpio::Io; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.pins.gpio1, peripherals.pins.gpio2).unwrap(); //! # let data = "Dummy"; //! let d: md5::Digest = md5::compute(&data); @@ -48,10 +46,8 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::rom::md5; //! # use esp_hal::uart::Uart; -//! # use esp_hal::gpio::Io; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.pins.gpio1, peripherals.pins.gpio2).unwrap(); //! # let data0 = "Dummy"; //! # let data1 = "Dummy"; diff --git a/esp-hal/src/soc/esp32/efuse/mod.rs b/esp-hal/src/soc/esp32/efuse/mod.rs index 1ecd29cd15b..1ffb4263002 100644 --- a/esp-hal/src/soc/esp32/efuse/mod.rs +++ b/esp-hal/src/soc/esp32/efuse/mod.rs @@ -24,11 +24,9 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::efuse::Efuse; -//! # use esp_hal::gpio::Io; //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( diff --git a/esp-hal/src/soc/esp32/peripherals.rs b/esp-hal/src/soc/esp32/peripherals.rs index ab9b31ce6d1..172ff834cf9 100644 --- a/esp-hal/src/soc/esp32/peripherals.rs +++ b/esp-hal/src/soc/esp32/peripherals.rs @@ -33,7 +33,6 @@ crate::peripherals! { EFUSE <= EFUSE, FLASH_ENCRYPTION <= FLASH_ENCRYPTION, FRC_TIMER <= FRC_TIMER, - GPIO <= GPIO (GPIO,GPIO_NMI), GPIO_SD <= GPIO_SD, HINF <= HINF, I2C0 <= I2C0, diff --git a/esp-hal/src/soc/esp32c2/efuse/mod.rs b/esp-hal/src/soc/esp32c2/efuse/mod.rs index b330e4fcdd6..83c5f116763 100644 --- a/esp-hal/src/soc/esp32c2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c2/efuse/mod.rs @@ -21,11 +21,9 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::efuse::Efuse; -//! # use esp_hal::gpio::Io; //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( diff --git a/esp-hal/src/soc/esp32c2/peripherals.rs b/esp-hal/src/soc/esp32c2/peripherals.rs index 3cd86959d96..4685a536c21 100644 --- a/esp-hal/src/soc/esp32c2/peripherals.rs +++ b/esp-hal/src/soc/esp32c2/peripherals.rs @@ -28,7 +28,6 @@ crate::peripherals! { ECC <= ECC, EFUSE <= EFUSE, EXTMEM <= EXTMEM, - GPIO <= GPIO (GPIO,GPIO_NMI), I2C0 <= I2C0, INTERRUPT_CORE0 <= INTERRUPT_CORE0, IO_MUX <= IO_MUX, diff --git a/esp-hal/src/soc/esp32c3/efuse/mod.rs b/esp-hal/src/soc/esp32c3/efuse/mod.rs index 9f5d8eefdfe..5d4f4d7fc7c 100644 --- a/esp-hal/src/soc/esp32c3/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c3/efuse/mod.rs @@ -22,11 +22,9 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::efuse::Efuse; -//! # use esp_hal::gpio::Io; //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( diff --git a/esp-hal/src/soc/esp32c3/peripherals.rs b/esp-hal/src/soc/esp32c3/peripherals.rs index dd5308df0c2..611a3f13f8a 100644 --- a/esp-hal/src/soc/esp32c3/peripherals.rs +++ b/esp-hal/src/soc/esp32c3/peripherals.rs @@ -30,7 +30,6 @@ crate::peripherals! { DS <= DS, EFUSE <= EFUSE, EXTMEM <= EXTMEM, - GPIO <= GPIO (GPIO,GPIO_NMI), GPIO_SD <= GPIO_SD, HMAC <= HMAC, I2C0 <= I2C0, diff --git a/esp-hal/src/soc/esp32c6/efuse/mod.rs b/esp-hal/src/soc/esp32c6/efuse/mod.rs index 4a9464317e6..f5cd1105126 100644 --- a/esp-hal/src/soc/esp32c6/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c6/efuse/mod.rs @@ -22,11 +22,9 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::efuse::Efuse; -//! # use esp_hal::gpio::Io; //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( diff --git a/esp-hal/src/soc/esp32c6/peripherals.rs b/esp-hal/src/soc/esp32c6/peripherals.rs index ef74459ed22..c983c46b6fc 100644 --- a/esp-hal/src/soc/esp32c6/peripherals.rs +++ b/esp-hal/src/soc/esp32c6/peripherals.rs @@ -30,7 +30,6 @@ crate::peripherals! { ECC <= ECC, EFUSE <= EFUSE, EXTMEM <= EXTMEM, - GPIO <= GPIO (GPIO,GPIO_NMI), GPIO_SD <= GPIO_SD, HINF <= HINF, HMAC <= HMAC, diff --git a/esp-hal/src/soc/esp32h2/efuse/mod.rs b/esp-hal/src/soc/esp32h2/efuse/mod.rs index 858f4fb44c2..40ca4cee29d 100644 --- a/esp-hal/src/soc/esp32h2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32h2/efuse/mod.rs @@ -22,11 +22,9 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::efuse::Efuse; -//! # use esp_hal::gpio::Io; //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( diff --git a/esp-hal/src/soc/esp32h2/peripherals.rs b/esp-hal/src/soc/esp32h2/peripherals.rs index 7fbda39c981..9a2606c9700 100644 --- a/esp-hal/src/soc/esp32h2/peripherals.rs +++ b/esp-hal/src/soc/esp32h2/peripherals.rs @@ -28,7 +28,6 @@ crate::peripherals! { DS <= DS, ECC <= ECC, EFUSE <= EFUSE, - GPIO <= GPIO (GPIO,GPIO_NMI), GPIO_SD <= GPIO_SD, HMAC <= HMAC, HP_APM <= HP_APM, diff --git a/esp-hal/src/soc/esp32s2/efuse/mod.rs b/esp-hal/src/soc/esp32s2/efuse/mod.rs index f8524ad682c..523e2d92151 100644 --- a/esp-hal/src/soc/esp32s2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32s2/efuse/mod.rs @@ -24,11 +24,9 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::efuse::Efuse; -//! # use esp_hal::gpio::Io; //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( diff --git a/esp-hal/src/soc/esp32s2/peripherals.rs b/esp-hal/src/soc/esp32s2/peripherals.rs index c96d1c7b171..fc3634e17ee 100644 --- a/esp-hal/src/soc/esp32s2/peripherals.rs +++ b/esp-hal/src/soc/esp32s2/peripherals.rs @@ -30,7 +30,6 @@ crate::peripherals! { DS <= DS, EFUSE <= EFUSE, EXTMEM <= EXTMEM, - GPIO <= GPIO (GPIO,GPIO_NMI), GPIO_SD <= GPIO_SD, HMAC <= HMAC, I2C0 <= I2C0, diff --git a/esp-hal/src/soc/esp32s3/efuse/mod.rs b/esp-hal/src/soc/esp32s3/efuse/mod.rs index 85649fd74db..2c1ff3c9d3c 100644 --- a/esp-hal/src/soc/esp32s3/efuse/mod.rs +++ b/esp-hal/src/soc/esp32s3/efuse/mod.rs @@ -22,11 +22,9 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::efuse::Efuse; -//! # use esp_hal::gpio::Io; //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( diff --git a/esp-hal/src/soc/esp32s3/peripherals.rs b/esp-hal/src/soc/esp32s3/peripherals.rs index 9e0592abf52..ce061ae487e 100644 --- a/esp-hal/src/soc/esp32s3/peripherals.rs +++ b/esp-hal/src/soc/esp32s3/peripherals.rs @@ -31,7 +31,6 @@ crate::peripherals! { DS <= DS, EFUSE <= EFUSE, EXTMEM <= EXTMEM, - GPIO <= GPIO (GPIO,GPIO_NMI), GPIO_SD <= GPIO_SD, HMAC <= HMAC, I2C0 <= I2C0, diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index c26f5833190..3987bb3a749 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -40,8 +40,6 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::spi::SpiMode; //! # use esp_hal::spi::master::{Config, Spi}; -//! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.IO_MUX); //! let sclk = peripherals.pins.gpio0; //! let miso = peripherals.pins.gpio2; //! let mosi = peripherals.pins.gpio1; diff --git a/esp-hal/src/spi/slave.rs b/esp-hal/src/spi/slave.rs index 86a80ffdca4..a443ebf911a 100644 --- a/esp-hal/src/spi/slave.rs +++ b/esp-hal/src/spi/slave.rs @@ -20,15 +20,13 @@ //! # use esp_hal::spi::SpiMode; //! # use esp_hal::spi::slave::Spi; //! # use esp_hal::dma::Dma; -//! # use esp_hal::gpio::Io; //! let dma = Dma::new(peripherals.DMA); #![cfg_attr(pdma, doc = "let dma_channel = dma.spi2channel;")] #![cfg_attr(gdma, doc = "let dma_channel = dma.channel0;")] -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); -//! let sclk = io.pins.gpio0; -//! let miso = io.pins.gpio1; -//! let mosi = io.pins.gpio2; -//! let cs = io.pins.gpio3; +//! let sclk = peripherals.pins.gpio0; +//! let miso = peripherals.pins.gpio1; +//! let mosi = peripherals.pins.gpio2; +//! let cs = peripherals.pins.gpio3; //! //! let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = //! dma_buffers!(32000); diff --git a/esp-hal/src/touch.rs b/esp-hal/src/touch.rs index d1dee325822..d56e5d80825 100644 --- a/esp-hal/src/touch.rs +++ b/esp-hal/src/touch.rs @@ -10,8 +10,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::touch::{Touch, TouchPad}; -//! # use esp_hal::gpio::Io; -//! let io = Io::new(peripherals.IO_MUX); //! let touch_pin0 = peripherals.pins.gpio2; //! let touch = Touch::continuous_mode(peripherals.TOUCH, None); //! let mut touchpad = TouchPad::new(touch_pin0, &touch); diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs index 4d07b8e0b4d..3686dceeaa8 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -32,10 +32,8 @@ //! # use esp_hal::twai::TwaiConfiguration; //! # use esp_hal::twai::BaudRate; //! # use esp_hal::twai::TwaiMode; -//! # use esp_hal::gpio::Io; //! # use embedded_can::Frame; //! # use nb::block; -//! # let io = Io::new(peripherals.IO_MUX); //! // Use GPIO pins 2 and 3 to connect to the respective pins on the TWAI //! // transceiver. //! let can_rx_pin = peripherals.pins.gpio3; @@ -86,10 +84,8 @@ //! # use esp_hal::twai::EspTwaiFrame; //! # use esp_hal::twai::StandardId; //! # use esp_hal::twai::TwaiMode; -//! # use esp_hal::gpio::Io; //! # use embedded_can::Frame; //! # use nb::block; -//! # let io = Io::new(peripherals.IO_MUX); //! // Use GPIO pins 2 and 3 to connect to the respective pins on the TWAI //! // transceiver. //! let can_rx_pin = peripherals.pins.gpio3; diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index 621f7cd1b66..7ab5783e5f9 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -23,9 +23,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::uart::Uart; -//! use esp_hal::gpio::Io; -//! -//! let io = Io::new(peripherals.IO_MUX); //! //! let mut uart1 = Uart::new( //! peripherals.UART1, @@ -56,8 +53,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::uart::{Config, Uart}; -//! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut uart1 = Uart::new_with_config( //! # peripherals.UART1, //! # Config::default(), @@ -73,8 +68,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::uart::{Config, Uart}; -//! # use esp_hal::gpio::Io; -//! # let io = Io::new(peripherals.IO_MUX); //! # let mut uart1 = Uart::new_with_config( //! # peripherals.UART1, //! # Config::default(), @@ -94,9 +87,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::uart::Uart; -//! use esp_hal::gpio::Io; -//! -//! let io = Io::new(peripherals.IO_MUX); //! //! let (rx, _) = peripherals.pins.gpio2.split(); //! let (_, tx) = peripherals.pins.gpio1.split(); @@ -112,9 +102,6 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::uart::{UartTx, UartRx}; -//! use esp_hal::gpio::Io; -//! -//! let io = Io::new(peripherals.IO_MUX); //! //! let tx = UartTx::new(peripherals.UART0, peripherals.pins.gpio1).unwrap(); //! let rx = UartRx::new(peripherals.UART1, peripherals.pins.gpio2).unwrap(); diff --git a/examples/src/bin/adc.rs b/examples/src/bin/adc.rs index 9ea7dd1d247..83e6a3e01cc 100644 --- a/examples/src/bin/adc.rs +++ b/examples/src/bin/adc.rs @@ -20,7 +20,6 @@ use esp_backtrace as _; use esp_hal::{ analog::adc::{Adc, AdcConfig, Attenuation}, delay::Delay, - gpio::Io, prelude::*, }; use esp_println::println; @@ -29,7 +28,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { let analog_pin = peripherals.pins.gpio32; diff --git a/examples/src/bin/adc_cal.rs b/examples/src/bin/adc_cal.rs index 1fc3e4e85c1..2a7a7662963 100644 --- a/examples/src/bin/adc_cal.rs +++ b/examples/src/bin/adc_cal.rs @@ -16,7 +16,6 @@ use esp_backtrace as _; use esp_hal::{ analog::adc::{Adc, AdcConfig, Attenuation}, delay::Delay, - gpio::Io, prelude::*, }; use esp_println::println; @@ -25,7 +24,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32s3")] { let analog_pin = peripherals.pins.gpio3; diff --git a/examples/src/bin/advanced_serial.rs b/examples/src/bin/advanced_serial.rs index 1e62e78798e..475cc2646c2 100644 --- a/examples/src/bin/advanced_serial.rs +++ b/examples/src/bin/advanced_serial.rs @@ -13,7 +13,7 @@ #![no_main] use esp_backtrace as _; -use esp_hal::{delay::Delay, gpio::Io, prelude::*, uart::Uart}; +use esp_hal::{delay::Delay, prelude::*, uart::Uart}; use esp_println::println; use nb::block; @@ -21,8 +21,6 @@ use nb::block; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let mut serial1 = Uart::new( peripherals.UART1, peripherals.pins.gpio4, diff --git a/examples/src/bin/blinky.rs b/examples/src/bin/blinky.rs index 8f5cb4b0a7e..0f48cb83954 100644 --- a/examples/src/bin/blinky.rs +++ b/examples/src/bin/blinky.rs @@ -11,7 +11,7 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::{Io, Level, Output}, + gpio::{Level, Output}, prelude::*, }; @@ -20,7 +20,7 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); // Set GPIO0 as an output, and set its state high initially. - let io = Io::new(peripherals.IO_MUX); + let mut led = Output::new(peripherals.pins.gpio0, Level::High); let delay = Delay::new(); diff --git a/examples/src/bin/blinky_erased_pins.rs b/examples/src/bin/blinky_erased_pins.rs index 8fd590b5ee2..c3456bbbeb7 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::{ delay::Delay, - gpio::{Input, Io, Level, Output, Pin, Pull}, + gpio::{Input, Level, Output, Pin, Pull}, prelude::*, }; @@ -22,8 +22,6 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - // Set LED GPIOs as an output: let led1 = Output::new(peripherals.pins.gpio2.degrade(), Level::Low); let led2 = Output::new(peripherals.pins.gpio4.degrade(), Level::Low); diff --git a/examples/src/bin/dac.rs b/examples/src/bin/dac.rs index 8d2c1528846..903e8f6f30e 100644 --- a/examples/src/bin/dac.rs +++ b/examples/src/bin/dac.rs @@ -19,14 +19,12 @@ #![no_main] use esp_backtrace as _; -use esp_hal::{analog::dac::Dac, delay::Delay, gpio::Io, prelude::*}; +use esp_hal::{analog::dac::Dac, delay::Delay, prelude::*}; #[entry] fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { let dac1_pin = peripherals.pins.gpio25; diff --git a/examples/src/bin/embassy_i2c.rs b/examples/src/bin/embassy_i2c.rs index 344d1502bc9..6e1397fc20b 100644 --- a/examples/src/bin/embassy_i2c.rs +++ b/examples/src/bin/embassy_i2c.rs @@ -20,7 +20,6 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; use esp_backtrace as _; use esp_hal::{ - gpio::Io, i2c::master::{Config, I2c}, prelude::*, timer::timg::TimerGroup, diff --git a/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs b/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs index fa08cdfa78a..d3c9ddfc5ba 100644 --- a/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs +++ b/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs @@ -21,7 +21,6 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; use esp_backtrace as _; use esp_hal::{ - gpio::Io, i2c::master::{Config, I2c}, prelude::*, timer::timg::TimerGroup, diff --git a/examples/src/bin/embassy_i2s_parallel.rs b/examples/src/bin/embassy_i2s_parallel.rs index fa76ac9f766..f88b69c1d8b 100644 --- a/examples/src/bin/embassy_i2s_parallel.rs +++ b/examples/src/bin/embassy_i2s_parallel.rs @@ -20,7 +20,6 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority, DmaTxBuf}, dma_buffers, - gpio::Io, i2s::parallel::{I2sParallel, TxEightBits}, prelude::*, timer::timg::TimerGroup, @@ -35,7 +34,6 @@ async fn main(_spawner: Spawner) { info!("Starting!"); let peripherals = esp_hal::init(esp_hal::Config::default()); let dma = Dma::new(peripherals.DMA); - let io = Io::new(peripherals.IO_MUX); let timg0 = TimerGroup::new(peripherals.TIMG0); diff --git a/examples/src/bin/embassy_i2s_read.rs b/examples/src/bin/embassy_i2s_read.rs index ba881eb47ab..ae6a8e79233 100644 --- a/examples/src/bin/embassy_i2s_read.rs +++ b/examples/src/bin/embassy_i2s_read.rs @@ -22,7 +22,6 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, i2s::master::{DataFormat, I2s, Standard}, prelude::*, timer::timg::TimerGroup, @@ -37,8 +36,6 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] let dma_channel = dma.i2s0channel; diff --git a/examples/src/bin/embassy_i2s_sound.rs b/examples/src/bin/embassy_i2s_sound.rs index 613f5a57e27..4298c8b1ea9 100644 --- a/examples/src/bin/embassy_i2s_sound.rs +++ b/examples/src/bin/embassy_i2s_sound.rs @@ -36,7 +36,6 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, i2s::master::{DataFormat, I2s, Standard}, prelude::*, timer::timg::TimerGroup, @@ -59,8 +58,6 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] let dma_channel = dma.i2s0channel; diff --git a/examples/src/bin/embassy_multicore.rs b/examples/src/bin/embassy_multicore.rs index 96aad8a1cbc..0dddeed44ca 100644 --- a/examples/src/bin/embassy_multicore.rs +++ b/examples/src/bin/embassy_multicore.rs @@ -21,7 +21,7 @@ use esp_backtrace as _; use esp_hal::{ cpu_control::{CpuControl, Stack}, get_core, - gpio::{Io, Level, Output}, + gpio::{Level, Output}, timer::{timg::TimerGroup, AnyTimer}, }; use esp_hal_embassy::Executor; @@ -53,8 +53,6 @@ async fn control_led( async fn main(_spawner: Spawner) { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let timg0 = TimerGroup::new(peripherals.TIMG0); let timer0: AnyTimer = timg0.timer0.into(); let timer1: AnyTimer = timg0.timer1.into(); diff --git a/examples/src/bin/embassy_multicore_interrupt.rs b/examples/src/bin/embassy_multicore_interrupt.rs index f60056b9121..f87fb08fd7b 100644 --- a/examples/src/bin/embassy_multicore_interrupt.rs +++ b/examples/src/bin/embassy_multicore_interrupt.rs @@ -20,7 +20,7 @@ use esp_backtrace as _; use esp_hal::{ cpu_control::{CpuControl, Stack}, get_core, - gpio::{Io, Level, Output}, + gpio::{Level, Output}, interrupt::{software::SoftwareInterruptControl, Priority}, prelude::*, timer::{timg::TimerGroup, AnyTimer}, @@ -75,8 +75,6 @@ fn main() -> ! { let sw_ints = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); - let io = Io::new(peripherals.IO_MUX); - let timg0 = TimerGroup::new(peripherals.TIMG0); let timer0: AnyTimer = timg0.timer0.into(); let timer1: AnyTimer = timg0.timer1.into(); diff --git a/examples/src/bin/embassy_parl_io_rx.rs b/examples/src/bin/embassy_parl_io_rx.rs index 5fb4c89833e..aa896ad2d49 100644 --- a/examples/src/bin/embassy_parl_io_rx.rs +++ b/examples/src/bin/embassy_parl_io_rx.rs @@ -16,7 +16,6 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, parl_io::{no_clk_pin, BitPackOrder, ParlIoRxOnly, RxFourBits}, prelude::*, timer::systimer::{SystemTimer, Target}, @@ -31,14 +30,17 @@ async fn main(_spawner: Spawner) { let systimer = SystemTimer::new(peripherals.SYSTIMER).split::(); esp_hal_embassy::init(systimer.alarm0); - let io = Io::new(peripherals.IO_MUX); - let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32000, 0); let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; - let mut rx_pins = RxFourBits::new(peripherals.pins.gpio1, peripherals.pins.gpio2, peripherals.pins.gpio3, peripherals.pins.gpio4); + let mut rx_pins = RxFourBits::new( + peripherals.pins.gpio1, + peripherals.pins.gpio2, + peripherals.pins.gpio3, + peripherals.pins.gpio4, + ); let parl_io = ParlIoRxOnly::new( peripherals.PARL_IO, diff --git a/examples/src/bin/embassy_parl_io_tx.rs b/examples/src/bin/embassy_parl_io_tx.rs index a4b0a884faf..d538af55ec0 100644 --- a/examples/src/bin/embassy_parl_io_tx.rs +++ b/examples/src/bin/embassy_parl_io_tx.rs @@ -20,7 +20,6 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, parl_io::{ BitPackOrder, ClkOutPin, @@ -42,14 +41,17 @@ async fn main(_spawner: Spawner) { let systimer = SystemTimer::new(peripherals.SYSTIMER).split::(); esp_hal_embassy::init(systimer.alarm0); - let io = Io::new(peripherals.IO_MUX); - let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000); let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; - let tx_pins = TxFourBits::new(peripherals.pins.gpio1, peripherals.pins.gpio2, peripherals.pins.gpio3, peripherals.pins.gpio4); + let tx_pins = TxFourBits::new( + peripherals.pins.gpio1, + peripherals.pins.gpio2, + peripherals.pins.gpio3, + peripherals.pins.gpio4, + ); let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, peripherals.pins.gpio5); diff --git a/examples/src/bin/embassy_rmt_rx.rs b/examples/src/bin/embassy_rmt_rx.rs index 75be15a7462..d42f73d047a 100644 --- a/examples/src/bin/embassy_rmt_rx.rs +++ b/examples/src/bin/embassy_rmt_rx.rs @@ -13,7 +13,7 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; use esp_backtrace as _; use esp_hal::{ - gpio::{Io, Level, Output}, + gpio::{Level, Output}, prelude::*, rmt::{PulseCode, Rmt, RxChannelAsync, RxChannelConfig, RxChannelCreatorAsync}, timer::timg::TimerGroup, @@ -44,8 +44,6 @@ async fn main(spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { let freq = 32.MHz(); diff --git a/examples/src/bin/embassy_rmt_tx.rs b/examples/src/bin/embassy_rmt_tx.rs index 7a5406d6d3a..9d1000494ab 100644 --- a/examples/src/bin/embassy_rmt_tx.rs +++ b/examples/src/bin/embassy_rmt_tx.rs @@ -15,7 +15,6 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; use esp_backtrace as _; use esp_hal::{ - gpio::Io, prelude::*, rmt::{PulseCode, Rmt, TxChannelAsync, TxChannelConfig, TxChannelCreatorAsync}, timer::timg::TimerGroup, @@ -30,8 +29,6 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { let freq = 32.MHz(); diff --git a/examples/src/bin/embassy_serial.rs b/examples/src/bin/embassy_serial.rs index 991b6b34a17..a89ddef1372 100644 --- a/examples/src/bin/embassy_serial.rs +++ b/examples/src/bin/embassy_serial.rs @@ -13,7 +13,6 @@ use embassy_executor::Spawner; use embassy_sync::{blocking_mutex::raw::NoopRawMutex, signal::Signal}; use esp_backtrace as _; use esp_hal::{ - gpio::Io, timer::timg::TimerGroup, uart::{AtCmdConfig, Config, Uart, UartRx, UartTx}, Async, @@ -71,8 +70,6 @@ async fn main(spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { diff --git a/examples/src/bin/embassy_spi.rs b/examples/src/bin/embassy_spi.rs index 1370a5de6d8..fd2a7e6de7e 100644 --- a/examples/src/bin/embassy_spi.rs +++ b/examples/src/bin/embassy_spi.rs @@ -24,7 +24,6 @@ use esp_backtrace as _; use esp_hal::{ dma::*, dma_buffers, - gpio::Io, prelude::*, spi::{ master::{Config, Spi}, @@ -41,7 +40,6 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio0; let miso = peripherals.pins.gpio2; let mosi = peripherals.pins.gpio4; diff --git a/examples/src/bin/embassy_touch.rs b/examples/src/bin/embassy_touch.rs index 464683197c1..643f6684e00 100644 --- a/examples/src/bin/embassy_touch.rs +++ b/examples/src/bin/embassy_touch.rs @@ -17,7 +17,6 @@ use embassy_futures::select::{select, Either}; use embassy_time::{Duration, Timer}; use esp_backtrace as _; use esp_hal::{ - gpio::Io, rtc_cntl::Rtc, timer::timg::TimerGroup, touch::{Touch, TouchConfig, TouchPad}, @@ -32,7 +31,6 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); let mut rtc = Rtc::new(peripherals.LPWR); let touch_pin0 = peripherals.pins.gpio2; diff --git a/examples/src/bin/embassy_twai.rs b/examples/src/bin/embassy_twai.rs index 8debbb58aa6..ad672cc2d48 100644 --- a/examples/src/bin/embassy_twai.rs +++ b/examples/src/bin/embassy_twai.rs @@ -35,7 +35,6 @@ use embassy_sync::{blocking_mutex::raw::NoopRawMutex, channel::Channel}; use embedded_can::{Frame, Id}; use esp_backtrace as _; use esp_hal::{ - gpio::Io, timer::timg::TimerGroup, twai::{self, EspTwaiFrame, StandardId, TwaiMode, TwaiRx, TwaiTx}, }; @@ -92,8 +91,6 @@ async fn main(spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - // Without an external transceiver, we only need a single line between the two MCUs. let (rx_pin, tx_pin) = peripherals.pins.gpio2.split(); // Use these if you want to use an external transceiver: diff --git a/examples/src/bin/embassy_usb_serial.rs b/examples/src/bin/embassy_usb_serial.rs index f021be5230e..65601da8b9c 100644 --- a/examples/src/bin/embassy_usb_serial.rs +++ b/examples/src/bin/embassy_usb_serial.rs @@ -21,7 +21,6 @@ use embassy_usb::{ }; use esp_backtrace as _; use esp_hal::{ - gpio::Io, otg_fs::{ asynch::{Config, Driver}, Usb, @@ -37,9 +36,11 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - - let usb = Usb::new(peripherals.USB0, peripherals.pins.gpio20, peripherals.pins.gpio19); + let usb = Usb::new( + peripherals.USB0, + peripherals.pins.gpio20, + peripherals.pins.gpio19, + ); // Create the driver, from the HAL. let mut ep_out_buffer = [0u8; 1024]; diff --git a/examples/src/bin/embassy_wait.rs b/examples/src/bin/embassy_wait.rs index ce236d9098e..fa9a67dccde 100644 --- a/examples/src/bin/embassy_wait.rs +++ b/examples/src/bin/embassy_wait.rs @@ -12,7 +12,7 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; use esp_backtrace as _; use esp_hal::{ - gpio::{Input, Io, Pull}, + gpio::{Input, Pull}, timer::timg::TimerGroup, }; @@ -24,8 +24,6 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let io = Io::new(peripherals.IO_MUX); - cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { let mut input = Input::new(peripherals.pins.gpio0, Pull::Down); diff --git a/examples/src/bin/etm_blinky_systimer.rs b/examples/src/bin/etm_blinky_systimer.rs index da8fb0785c0..35a30566522 100644 --- a/examples/src/bin/etm_blinky_systimer.rs +++ b/examples/src/bin/etm_blinky_systimer.rs @@ -13,7 +13,6 @@ use esp_hal::{ etm::Etm, gpio::{ etm::{Channels, OutputConfig}, - Io, Level, Pull, }, @@ -31,7 +30,6 @@ fn main() -> ! { let mut alarm0 = syst_alarms.alarm0; alarm0.set_period(1u32.secs()); - let io = Io::new(peripherals.IO_MUX); let mut led = peripherals.pins.gpio1; // setup ETM diff --git a/examples/src/bin/etm_gpio.rs b/examples/src/bin/etm_gpio.rs index 8ee061d0b6e..cf5d5a9d2e0 100644 --- a/examples/src/bin/etm_gpio.rs +++ b/examples/src/bin/etm_gpio.rs @@ -13,7 +13,6 @@ use esp_hal::{ etm::Etm, gpio::{ etm::{Channels, InputConfig, OutputConfig}, - Io, Level, Output, Pull, @@ -25,8 +24,6 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let mut led = Output::new(peripherals.pins.gpio1, Level::Low); let button = peripherals.pins.gpio9; diff --git a/examples/src/bin/hello_world.rs b/examples/src/bin/hello_world.rs index 2ef151bae26..4e97c5d5353 100644 --- a/examples/src/bin/hello_world.rs +++ b/examples/src/bin/hello_world.rs @@ -15,7 +15,7 @@ use core::fmt::Write; use esp_backtrace as _; -use esp_hal::{delay::Delay, gpio::Io, prelude::*, uart::Uart}; +use esp_hal::{delay::Delay, prelude::*, uart::Uart}; #[entry] fn main() -> ! { @@ -23,8 +23,6 @@ fn main() -> ! { let delay = Delay::new(); - let io = Io::new(peripherals.IO_MUX); - // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { diff --git a/examples/src/bin/i2s_parallel.rs b/examples/src/bin/i2s_parallel.rs index f059df6ceb1..fcfe88e9135 100644 --- a/examples/src/bin/i2s_parallel.rs +++ b/examples/src/bin/i2s_parallel.rs @@ -18,7 +18,6 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority, DmaTxBuf}, dma_buffers, - gpio::Io, i2s::parallel::{I2sParallel, TxEightBits}, prelude::*, }; @@ -32,7 +31,6 @@ fn main() -> ! { info!("Starting!"); let peripherals = esp_hal::init(esp_hal::Config::default()); let dma = Dma::new(peripherals.DMA); - let io = Io::new(peripherals.IO_MUX); let delay = Delay::new(); diff --git a/examples/src/bin/i2s_read.rs b/examples/src/bin/i2s_read.rs index e139dd5f691..e9f1e3c7bdb 100644 --- a/examples/src/bin/i2s_read.rs +++ b/examples/src/bin/i2s_read.rs @@ -20,7 +20,6 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, i2s::master::{DataFormat, I2s, Standard}, prelude::*, }; @@ -30,8 +29,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] let dma_channel = dma.i2s0channel; diff --git a/examples/src/bin/i2s_sound.rs b/examples/src/bin/i2s_sound.rs index f38ebdd8dae..3d763490a04 100644 --- a/examples/src/bin/i2s_sound.rs +++ b/examples/src/bin/i2s_sound.rs @@ -34,7 +34,6 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, i2s::master::{DataFormat, I2s, Standard}, prelude::*, }; @@ -51,8 +50,6 @@ const SINE: [i16; 64] = [ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let dma = Dma::new(peripherals.DMA); #[cfg(any(feature = "esp32", feature = "esp32s2"))] let dma_channel = dma.i2s0channel; diff --git a/examples/src/bin/ieee802154_sniffer.rs b/examples/src/bin/ieee802154_sniffer.rs index b9deeb311fc..7e9663d2624 100644 --- a/examples/src/bin/ieee802154_sniffer.rs +++ b/examples/src/bin/ieee802154_sniffer.rs @@ -8,7 +8,7 @@ #![no_main] use esp_backtrace as _; -use esp_hal::{gpio::Io, prelude::*, reset::software_reset, uart::Uart}; +use esp_hal::{prelude::*, reset::software_reset, uart::Uart}; use esp_ieee802154::{Config, Ieee802154}; use esp_println::println; @@ -16,8 +16,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32c6")] { diff --git a/examples/src/bin/lcd_cam_ov2640.rs b/examples/src/bin/lcd_cam_ov2640.rs index 3a7f70486ad..705ae915184 100644 --- a/examples/src/bin/lcd_cam_ov2640.rs +++ b/examples/src/bin/lcd_cam_ov2640.rs @@ -28,7 +28,6 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority}, dma_rx_stream_buffer, - gpio::Io, i2c::{ self, master::{Config, I2c}, @@ -46,8 +45,6 @@ use esp_println::{print, println}; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let dma = Dma::new(peripherals.DMA); let channel = dma.channel0; diff --git a/examples/src/bin/lcd_i8080.rs b/examples/src/bin/lcd_i8080.rs index 17fb9603289..9c2c9c96921 100644 --- a/examples/src/bin/lcd_i8080.rs +++ b/examples/src/bin/lcd_i8080.rs @@ -27,7 +27,7 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority, DmaTxBuf}, dma_tx_buffer, - gpio::{Input, Io, Level, Output, Pull}, + gpio::{Input, Level, Output, Pull}, lcd_cam::{ lcd::i8080::{Config, TxEightBits, I8080}, LcdCam, @@ -41,8 +41,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let lcd_backlight = peripherals.pins.gpio45; let lcd_reset = peripherals.pins.gpio4; let lcd_rs = peripherals.pins.gpio0; // Command/Data selection diff --git a/examples/src/bin/ledc.rs b/examples/src/bin/ledc.rs index 0cdd354b936..396065fb5ac 100644 --- a/examples/src/bin/ledc.rs +++ b/examples/src/bin/ledc.rs @@ -11,7 +11,6 @@ use esp_backtrace as _; use esp_hal::{ - gpio::Io, ledc::{ channel::{self, ChannelIFace}, timer::{self, TimerIFace}, @@ -26,7 +25,6 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let led = peripherals.pins.gpio0; let mut ledc = Ledc::new(peripherals.LEDC); diff --git a/examples/src/bin/lp_core_basic.rs b/examples/src/bin/lp_core_basic.rs index ae41125e62b..56925e18adf 100644 --- a/examples/src/bin/lp_core_basic.rs +++ b/examples/src/bin/lp_core_basic.rs @@ -15,7 +15,7 @@ use esp_backtrace as _; use esp_hal::{ - gpio::{lp_io::LowPowerOutput, Io}, + gpio::lp_io::LowPowerOutput, lp_core::{LpCore, LpCoreWakeupSource}, prelude::*, }; @@ -26,7 +26,7 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); // configure GPIO 1 as LP output pin - let io = Io::new(peripherals.IO_MUX); + let lp_pin = LowPowerOutput::new(peripherals.pins.gpio1); let mut lp_core = LpCore::new(peripherals.LP_CORE); diff --git a/examples/src/bin/lp_core_i2c.rs b/examples/src/bin/lp_core_i2c.rs index 1afb387774a..303b13a4499 100644 --- a/examples/src/bin/lp_core_i2c.rs +++ b/examples/src/bin/lp_core_i2c.rs @@ -16,7 +16,7 @@ use esp_backtrace as _; use esp_hal::{ - gpio::{lp_io::LowPowerOutputOpenDrain, Io}, + gpio::lp_io::LowPowerOutputOpenDrain, i2c::lp_i2c::LpI2c, lp_core::{LpCore, LpCoreWakeupSource}, prelude::*, @@ -27,8 +27,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let lp_sda = LowPowerOutputOpenDrain::new(peripherals.pins.gpio6); let lp_scl = LowPowerOutputOpenDrain::new(peripherals.pins.gpio7); diff --git a/examples/src/bin/lp_core_uart.rs b/examples/src/bin/lp_core_uart.rs index 1c0c616d038..b3cbc7df67c 100644 --- a/examples/src/bin/lp_core_uart.rs +++ b/examples/src/bin/lp_core_uart.rs @@ -16,10 +16,7 @@ use esp_backtrace as _; use esp_hal::{ - gpio::{ - lp_io::{LowPowerInput, LowPowerOutput}, - Io, - }, + gpio::lp_io::{LowPowerInput, LowPowerOutput}, lp_core::{LpCore, LpCoreWakeupSource}, prelude::*, uart::{lp_uart::LpUart, Config, Uart}, @@ -30,8 +27,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - // Set up (HP) UART1: let mut uart1 = Uart::new_with_config( diff --git a/examples/src/bin/mcpwm.rs b/examples/src/bin/mcpwm.rs index c28905ad172..98d42bdeb99 100644 --- a/examples/src/bin/mcpwm.rs +++ b/examples/src/bin/mcpwm.rs @@ -11,7 +11,6 @@ use esp_backtrace as _; use esp_hal::{ - gpio::Io, mcpwm::{operator::PwmPinConfig, timer::PwmWorkingMode, McPwm, PeripheralClockConfig}, prelude::*, }; @@ -20,7 +19,6 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let pin = peripherals.pins.gpio0; // initialize peripheral diff --git a/examples/src/bin/parl_io_rx.rs b/examples/src/bin/parl_io_rx.rs index 2a97ecaf9c2..22937190c2c 100644 --- a/examples/src/bin/parl_io_rx.rs +++ b/examples/src/bin/parl_io_rx.rs @@ -14,7 +14,6 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, parl_io::{no_clk_pin, BitPackOrder, ParlIoRxOnly, RxFourBits}, prelude::*, }; @@ -24,8 +23,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32000, 0); let dma = Dma::new(peripherals.DMA); diff --git a/examples/src/bin/parl_io_tx.rs b/examples/src/bin/parl_io_tx.rs index 894c5146294..97184a339fd 100644 --- a/examples/src/bin/parl_io_tx.rs +++ b/examples/src/bin/parl_io_tx.rs @@ -18,7 +18,6 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority}, dma_buffers, - gpio::Io, parl_io::{ BitPackOrder, ClkOutPin, @@ -35,8 +34,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000); let dma = Dma::new(peripherals.DMA); diff --git a/examples/src/bin/pcnt_encoder.rs b/examples/src/bin/pcnt_encoder.rs index 58733e5b93c..4c5ee1cf0ee 100644 --- a/examples/src/bin/pcnt_encoder.rs +++ b/examples/src/bin/pcnt_encoder.rs @@ -20,7 +20,7 @@ use core::{cell::RefCell, cmp::min, sync::atomic::Ordering}; use critical_section::Mutex; use esp_backtrace as _; use esp_hal::{ - gpio::{Input, Io, Pull}, + gpio::{Input, Pull}, interrupt::Priority, pcnt::{channel, unit, Pcnt}, prelude::*, @@ -35,8 +35,6 @@ static VALUE: AtomicI32 = AtomicI32::new(0); fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - // Set up a pulse counter: println!("setup pulse counter unit 0"); let mut pcnt = Pcnt::new(peripherals.PCNT); diff --git a/examples/src/bin/qspi_flash.rs b/examples/src/bin/qspi_flash.rs index 021642ad71f..e2bea23632c 100644 --- a/examples/src/bin/qspi_flash.rs +++ b/examples/src/bin/qspi_flash.rs @@ -32,7 +32,6 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, - gpio::Io, prelude::*, spi::{ master::{Address, Command, Config, Spi}, @@ -46,7 +45,6 @@ use esp_println::{print, println}; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { let sclk = peripherals.pins.gpio0; diff --git a/examples/src/bin/rmt_rx.rs b/examples/src/bin/rmt_rx.rs index c3fa61ccb1a..1e35cea7ade 100644 --- a/examples/src/bin/rmt_rx.rs +++ b/examples/src/bin/rmt_rx.rs @@ -14,7 +14,7 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::{Io, Level, Output}, + gpio::{Level, Output}, prelude::*, rmt::{PulseCode, Rmt, RxChannel, RxChannelConfig, RxChannelCreator}, }; @@ -26,7 +26,6 @@ const WIDTH: usize = 80; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let mut out = Output::new(peripherals.pins.gpio5, Level::Low); cfg_if::cfg_if! { diff --git a/examples/src/bin/rmt_tx.rs b/examples/src/bin/rmt_tx.rs index 58403846e69..c3ae58e996e 100644 --- a/examples/src/bin/rmt_tx.rs +++ b/examples/src/bin/rmt_tx.rs @@ -13,7 +13,6 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::Io, prelude::*, rmt::{PulseCode, Rmt, TxChannel, TxChannelConfig, TxChannelCreator}, }; @@ -22,8 +21,6 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { let freq = 32.MHz(); diff --git a/examples/src/bin/serial_interrupts.rs b/examples/src/bin/serial_interrupts.rs index 548fabe0bf5..a8dec11dcb7 100644 --- a/examples/src/bin/serial_interrupts.rs +++ b/examples/src/bin/serial_interrupts.rs @@ -13,7 +13,6 @@ use critical_section::Mutex; use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::Io, prelude::*, uart::{AtCmdConfig, Config, Uart, UartInterrupt}, Blocking, @@ -27,8 +26,6 @@ fn main() -> ! { let delay = Delay::new(); - let io = Io::new(peripherals.IO_MUX); - // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { diff --git a/examples/src/bin/sleep_timer_ext0.rs b/examples/src/bin/sleep_timer_ext0.rs index bf2ac3b0db3..77d0bfab3b2 100644 --- a/examples/src/bin/sleep_timer_ext0.rs +++ b/examples/src/bin/sleep_timer_ext0.rs @@ -14,7 +14,7 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, entry, - gpio::{Input, Io, Pull}, + gpio::{Input, Pull}, rtc_cntl::{ get_reset_reason, get_wakeup_cause, @@ -32,7 +32,6 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let io = Io::new(peripherals.IO_MUX); let ext0_pin = Input::new(peripherals.pins.gpio4, Pull::None); println!("up and runnning!"); diff --git a/examples/src/bin/sleep_timer_ext1.rs b/examples/src/bin/sleep_timer_ext1.rs index 1ae33fe6975..ba764fac968 100644 --- a/examples/src/bin/sleep_timer_ext1.rs +++ b/examples/src/bin/sleep_timer_ext1.rs @@ -14,7 +14,7 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, entry, - gpio::{Input, Io, Pull, RtcPin}, + gpio::{Input, Pull, RtcPin}, peripheral::Peripheral, rtc_cntl::{ get_reset_reason, @@ -33,7 +33,6 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let io = Io::new(peripherals.IO_MUX); let pin_0 = Input::new(peripherals.pins.gpio4, Pull::None); let mut pin_2 = peripherals.pins.gpio2; diff --git a/examples/src/bin/sleep_timer_lpio.rs b/examples/src/bin/sleep_timer_lpio.rs index 950ab8436fc..cc449228a35 100644 --- a/examples/src/bin/sleep_timer_lpio.rs +++ b/examples/src/bin/sleep_timer_lpio.rs @@ -15,7 +15,7 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, entry, - gpio::{Input, Io, Pull, RtcPinWithResistors}, + gpio::{Input, Pull, RtcPinWithResistors}, peripheral::Peripheral, rtc_cntl::{ get_reset_reason, @@ -34,7 +34,6 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let io = Io::new(peripherals.IO_MUX); let pin2 = Input::new(peripherals.pins.gpio2, Pull::None); let mut pin3 = peripherals.pins.gpio3; diff --git a/examples/src/bin/sleep_timer_rtcio.rs b/examples/src/bin/sleep_timer_rtcio.rs index e3c4a19b74b..c87f22eba86 100644 --- a/examples/src/bin/sleep_timer_rtcio.rs +++ b/examples/src/bin/sleep_timer_rtcio.rs @@ -19,7 +19,7 @@ use esp_hal::{ delay::Delay, entry, gpio, - gpio::{Input, Io, Pull}, + gpio::{Input, Pull}, peripheral::Peripheral, rtc_cntl::{ get_reset_reason, @@ -36,7 +36,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let mut rtc = Rtc::new(peripherals.LPWR); println!("up and runnning!"); diff --git a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs index 4c446af19b4..5ee15877be3 100644 --- a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs +++ b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs @@ -30,7 +30,6 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::Io, prelude::*, spi::{ master::{Address, Command, Config, Spi}, @@ -44,7 +43,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { let sclk = peripherals.pins.gpio0; diff --git a/examples/src/bin/spi_loopback.rs b/examples/src/bin/spi_loopback.rs index 8b0e48ecce9..577b1a821c0 100644 --- a/examples/src/bin/spi_loopback.rs +++ b/examples/src/bin/spi_loopback.rs @@ -18,7 +18,6 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::Io, peripheral::Peripheral, prelude::*, spi::{ @@ -32,7 +31,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio0; let miso_mosi = peripherals.pins.gpio2; let cs = peripherals.pins.gpio5; diff --git a/examples/src/bin/spi_loopback_dma.rs b/examples/src/bin/spi_loopback_dma.rs index 6ae4b8ecb35..8dcb339078a 100644 --- a/examples/src/bin/spi_loopback_dma.rs +++ b/examples/src/bin/spi_loopback_dma.rs @@ -23,7 +23,6 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, - gpio::Io, prelude::*, spi::{ master::{Config, Spi}, @@ -36,7 +35,6 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio0; let miso = peripherals.pins.gpio2; let mosi = peripherals.pins.gpio4; diff --git a/examples/src/bin/spi_loopback_dma_psram.rs b/examples/src/bin/spi_loopback_dma_psram.rs index dcdadca8ef1..10c077b9420 100644 --- a/examples/src/bin/spi_loopback_dma_psram.rs +++ b/examples/src/bin/spi_loopback_dma_psram.rs @@ -26,7 +26,6 @@ use esp_backtrace as _; use esp_hal::{ delay::Delay, dma::{Dma, DmaBufBlkSize, DmaPriority, DmaRxBuf, DmaTxBuf}, - gpio::Io, peripheral::Peripheral, prelude::*, spi::{ @@ -63,7 +62,6 @@ fn main() -> ! { esp_alloc::psram_allocator!(peripherals.PSRAM, esp_hal::psram); let delay = Delay::new(); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio42; let mosi = peripherals.pins.gpio48; let miso = unsafe { mosi.clone_unchecked() }; diff --git a/examples/src/bin/spi_slave_dma.rs b/examples/src/bin/spi_slave_dma.rs index 44b2d4871fd..29c64356373 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, Level, Output, Pull}, + gpio::{Input, Level, Output, Pull}, prelude::*, spi::{slave::Spi, SpiMode}, }; @@ -44,17 +44,15 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let mut master_sclk = Output::new(peripherals.pins.gpio4, Level::Low); + let master_miso = Input::new(peripherals.pins.gpio5, Pull::None); + let mut master_mosi = Output::new(peripherals.pins.gpio8, Level::Low); + let mut master_cs = Output::new(peripherals.pins.gpio9, Level::High); - let mut master_sclk = Output::new(io.pins.gpio4, Level::Low); - let master_miso = Input::new(io.pins.gpio5, Pull::None); - let mut master_mosi = Output::new(io.pins.gpio8, Level::Low); - let mut master_cs = Output::new(io.pins.gpio9, Level::High); - - let slave_sclk = io.pins.gpio0; - let slave_miso = io.pins.gpio1; - let slave_mosi = io.pins.gpio2; - let slave_cs = io.pins.gpio3; + let slave_sclk = peripherals.pins.gpio0; + let slave_miso = peripherals.pins.gpio1; + let slave_mosi = peripherals.pins.gpio2; + let slave_cs = peripherals.pins.gpio3; let dma = Dma::new(peripherals.DMA); cfg_if::cfg_if! { diff --git a/examples/src/bin/touch.rs b/examples/src/bin/touch.rs index 5a15fb83f4b..d82a794df70 100644 --- a/examples/src/bin/touch.rs +++ b/examples/src/bin/touch.rs @@ -17,7 +17,7 @@ use critical_section::Mutex; use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::{GpioPin, Io}, + gpio::GpioPin, macros::ram, prelude::*, rtc_cntl::Rtc, @@ -49,8 +49,6 @@ fn main() -> ! { esp_println::logger::init_logger_from_env(); let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let mut rtc = Rtc::new(peripherals.LPWR); rtc.set_interrupt_handler(interrupt_handler); diff --git a/examples/src/bin/twai.rs b/examples/src/bin/twai.rs index 9327cb99625..063d6c1d7bb 100644 --- a/examples/src/bin/twai.rs +++ b/examples/src/bin/twai.rs @@ -29,7 +29,6 @@ const IS_FIRST_SENDER: bool = true; use esp_backtrace as _; use esp_hal::{ delay::Delay, - gpio::Io, prelude::*, twai::{self, filter::SingleStandardFilter, EspTwaiFrame, StandardId, TwaiMode}, }; @@ -40,8 +39,6 @@ use nb::block; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - // Without an external transceiver, we only need a single line between the two MCUs. let (rx_pin, tx_pin) = peripherals.pins.gpio2.split(); // Use these if you want to use an external transceiver: diff --git a/examples/src/bin/ulp_riscv_core_basic.rs b/examples/src/bin/ulp_riscv_core_basic.rs index 4a3da26e0fd..98087c84d54 100644 --- a/examples/src/bin/ulp_riscv_core_basic.rs +++ b/examples/src/bin/ulp_riscv_core_basic.rs @@ -12,18 +12,13 @@ #![no_main] use esp_backtrace as _; -use esp_hal::{ - gpio::{rtc_io::*, Io}, - prelude::*, - ulp_core, -}; +use esp_hal::{gpio::rtc_io::*, prelude::*, ulp_core}; use esp_println::{print, println}; #[entry] fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let pin = LowPowerOutput::new(peripherals.pins.gpio1); let mut ulp_core = ulp_core::UlpCore::new(peripherals.ULP_RISCV_CORE); diff --git a/examples/src/bin/usb_serial.rs b/examples/src/bin/usb_serial.rs index 1ef65bcb7dc..8f29eaa71ca 100644 --- a/examples/src/bin/usb_serial.rs +++ b/examples/src/bin/usb_serial.rs @@ -15,7 +15,6 @@ use core::ptr::addr_of_mut; use esp_backtrace as _; use esp_hal::{ - gpio::Io, otg_fs::{Usb, UsbBus}, prelude::*, }; @@ -28,8 +27,6 @@ static mut EP_MEMORY: [u32; 1024] = [0; 1024]; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let usb = Usb::new( peripherals.USB0, peripherals.pins.gpio20, diff --git a/examples/src/bin/wifi_ble.rs b/examples/src/bin/wifi_ble.rs index 8509113934b..4927f6d0fde 100644 --- a/examples/src/bin/wifi_ble.rs +++ b/examples/src/bin/wifi_ble.rs @@ -25,7 +25,7 @@ use bleps::{ use esp_alloc as _; use esp_backtrace as _; use esp_hal::{ - gpio::{Input, Io, Pull}, + gpio::{Input, Pull}, prelude::*, rng::Rng, time, @@ -54,8 +54,6 @@ fn main() -> ! { ) .unwrap(); - let io = Io::new(peripherals.IO_MUX); - cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { let button = Input::new(peripherals.pins.gpio0, Pull::Down); diff --git a/examples/src/bin/wifi_embassy_ble.rs b/examples/src/bin/wifi_embassy_ble.rs index 823c63883d5..a303c2b7cc9 100644 --- a/examples/src/bin/wifi_embassy_ble.rs +++ b/examples/src/bin/wifi_embassy_ble.rs @@ -28,7 +28,7 @@ use embassy_executor::Spawner; use esp_alloc as _; use esp_backtrace as _; use esp_hal::{ - gpio::{Input, Io, Pull}, + gpio::{Input, Pull}, prelude::*, rng::Rng, time, @@ -70,7 +70,6 @@ async fn main(_spawner: Spawner) -> ! { .unwrap() ); - let io = Io::new(peripherals.IO_MUX); cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { let button = Input::new(peripherals.pins.gpio0, Pull::Down); diff --git a/hil-test/tests/embassy_interrupt_spi_dma.rs b/hil-test/tests/embassy_interrupt_spi_dma.rs index d5394ff9ba5..46c91be1914 100644 --- a/hil-test/tests/embassy_interrupt_spi_dma.rs +++ b/hil-test/tests/embassy_interrupt_spi_dma.rs @@ -118,8 +118,7 @@ mod test { let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap(); let dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap(); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - let (_, mosi) = hil_test::common_test_pins!(io); + let (_, mosi) = hil_test::common_test_pins!(peripherals); let mut spi = Spi::new_with_config( peripherals.SPI2, diff --git a/hil-test/tests/gpio_custom_handler.rs b/hil-test/tests/gpio_custom_handler.rs index 334c9f53101..67f2d529870 100644 --- a/hil-test/tests/gpio_custom_handler.rs +++ b/hil-test/tests/gpio_custom_handler.rs @@ -66,9 +66,7 @@ mod tests { async fn default_handler_does_not_run_because_gpio_is_defined() { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - - let (gpio1, gpio2) = hil_test::common_test_pins!(io); + let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals); let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); @@ -83,10 +81,10 @@ mod tests { async fn default_handler_runs_because_handler_is_set() { let peripherals = esp_hal::init(esp_hal::Config::default()); - let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX); + let mut io = Io::new(peripherals.IO_MUX); io.set_interrupt_handler(interrupt_handler); - let (gpio1, gpio2) = hil_test::common_test_pins!(io); + let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals); let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); diff --git a/hil-test/tests/i2c.rs b/hil-test/tests/i2c.rs index 4281b70ff3f..9ea9f267c6b 100644 --- a/hil-test/tests/i2c.rs +++ b/hil-test/tests/i2c.rs @@ -6,7 +6,6 @@ #![no_main] use esp_hal::{ - gpio::Io, i2c::master::{Config, I2c, Operation}, Async, Blocking, @@ -33,7 +32,6 @@ mod tests { #[init] fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let (sda, scl) = hil_test::i2c_pins!(peripherals); diff --git a/hil-test/tests/i2s.rs b/hil-test/tests/i2s.rs index 54b0f91ef29..5fd85ca9e5f 100644 --- a/hil-test/tests/i2s.rs +++ b/hil-test/tests/i2s.rs @@ -14,7 +14,7 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority}, dma_buffers, - gpio::{Io, NoPin}, + gpio::{AnyPin, NoPin, Pin}, i2s::master::{DataFormat, I2s, I2sTx, Standard}, peripherals::I2S0, prelude::*, @@ -103,7 +103,7 @@ mod tests { use super::*; struct Context { - io: Io, + dout: AnyPin, dma_channel: DmaChannel0Creator, i2s: I2S0, } @@ -112,8 +112,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let dma = Dma::new(peripherals.DMA); cfg_if::cfg_if! { @@ -124,8 +122,10 @@ mod tests { } } + let (_, dout) = hil_test::common_test_pins!(peripherals); + Context { - io, + dout: dout.degrade(), dma_channel, i2s: peripherals.I2S0, } @@ -149,9 +149,7 @@ mod tests { ) .into_async(); - let (_, dout) = hil_test::common_test_pins!(ctx.io); - - let (din, dout) = dout.split(); + let (din, dout) = ctx.dout.split(); let i2s_tx = i2s .i2s_tx @@ -203,9 +201,7 @@ mod tests { tx_descriptors, ); - let (_, dout) = hil_test::common_test_pins!(ctx.io); - - let (din, dout) = dout.split(); + let (din, dout) = ctx.dout.split(); let mut i2s_tx = i2s .i2s_tx @@ -314,13 +310,11 @@ mod tests { tx_descriptors, ); - let (_, dout) = hil_test::common_test_pins!(ctx.io); - let mut i2s_tx = i2s .i2s_tx .with_bclk(NoPin) .with_ws(NoPin) - .with_dout(dout) + .with_dout(ctx.dout) .build(); let mut tx_transfer = i2s_tx.write_dma_circular(tx_buffer).unwrap(); @@ -346,15 +340,11 @@ mod tests { tx_descriptors, ); - let (_, dout) = hil_test::common_test_pins!(ctx.io); - - let (din, dout) = dout.split(); - let mut i2s_rx = i2s .i2s_rx .with_bclk(NoPin) .with_ws(NoPin) - .with_din(din) + .with_din(ctx.dout) // not a typo .build(); let mut buffer = [0u8; 1024]; diff --git a/hil-test/tests/lcd_cam_i8080.rs b/hil-test/tests/lcd_cam_i8080.rs index 0f7b47f91bd..2c7d761ddbf 100644 --- a/hil-test/tests/lcd_cam_i8080.rs +++ b/hil-test/tests/lcd_cam_i8080.rs @@ -8,7 +8,7 @@ use esp_hal::{ dma::{Dma, DmaPriority, DmaTxBuf}, dma_buffers, - gpio::{Io, NoPin}, + gpio::{Io, NoPin, Pins}, lcd_cam::{ lcd::i8080::{Command, Config, TxEightBits, TxSixteenBits, I8080}, BitOrder, @@ -28,7 +28,7 @@ const DATA_SIZE: usize = 1024 * 10; struct Context<'d> { lcd_cam: LcdCam<'d, Blocking>, pcnt: Pcnt<'d>, - io: Io, + pins: Pins, dma: Dma<'d>, dma_buf: DmaTxBuf, } @@ -44,7 +44,7 @@ mod tests { let dma = Dma::new(peripherals.DMA); let lcd_cam = LcdCam::new(peripherals.LCD_CAM); let pcnt = Pcnt::new(peripherals.PCNT); - let io = Io::new(peripherals.IO_MUX); + let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, DATA_SIZE); let dma_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap(); @@ -52,7 +52,7 @@ mod tests { lcd_cam, dma, pcnt, - io, + pins: peripherals.pins, dma_buf, } } @@ -102,11 +102,11 @@ mod tests { // issue with configuring pins as outputs after inputs have been sorted // out. See https://github.com/esp-rs/esp-hal/pull/2173#issue-2529323702 - let (unit_ctrl, cs_signal) = ctx.peripherals.pins.gpio8.split(); - let (unit0_input, unit0_signal) = ctx.peripherals.pins.gpio11.split(); - let (unit1_input, unit1_signal) = ctx.peripherals.pins.gpio12.split(); - let (unit2_input, unit2_signal) = ctx.peripherals.pins.gpio16.split(); - let (unit3_input, unit3_signal) = ctx.peripherals.pins.gpio17.split(); + let (unit_ctrl, cs_signal) = ctx.pins.gpio8.split(); + let (unit0_input, unit0_signal) = ctx.pins.gpio11.split(); + let (unit1_input, unit1_signal) = ctx.pins.gpio12.split(); + let (unit2_input, unit2_signal) = ctx.pins.gpio16.split(); + let (unit3_input, unit3_signal) = ctx.pins.gpio17.split(); let pcnt = ctx.pcnt; @@ -213,11 +213,11 @@ mod tests { // issue with configuring pins as outputs after inputs have been sorted // out. See https://github.com/esp-rs/esp-hal/pull/2173#issue-2529323702 - let (unit_ctrl, cs_signal) = ctx.peripherals.pins.gpio8.split(); - let (unit0_input, unit0_signal) = ctx.peripherals.pins.gpio11.split(); - let (unit1_input, unit1_signal) = ctx.peripherals.pins.gpio12.split(); - let (unit2_input, unit2_signal) = ctx.peripherals.pins.gpio16.split(); - let (unit3_input, unit3_signal) = ctx.peripherals.pins.gpio17.split(); + let (unit_ctrl, cs_signal) = ctx.pins.gpio8.split(); + let (unit0_input, unit0_signal) = ctx.pins.gpio11.split(); + let (unit1_input, unit1_signal) = ctx.pins.gpio12.split(); + let (unit2_input, unit2_signal) = ctx.pins.gpio16.split(); + let (unit3_input, unit3_signal) = ctx.pins.gpio17.split(); let pcnt = ctx.pcnt; diff --git a/hil-test/tests/parl_io_tx.rs b/hil-test/tests/parl_io_tx.rs index 2bbf0a4642d..8924c11ada8 100644 --- a/hil-test/tests/parl_io_tx.rs +++ b/hil-test/tests/parl_io_tx.rs @@ -10,7 +10,6 @@ use esp_hal::{ dma::{ChannelCreator, Dma, DmaPriority}, gpio::{ interconnect::{InputSignal, OutputSignal}, - Io, NoPin, }, parl_io::{ @@ -52,7 +51,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let (clock, _) = hil_test::common_test_pins!(peripherals); let valid = hil_test::unconnected_pin!(peripherals); let (clock_loopback, clock) = clock.split(); diff --git a/hil-test/tests/parl_io_tx_async.rs b/hil-test/tests/parl_io_tx_async.rs index a345025be2a..a38719ec7e6 100644 --- a/hil-test/tests/parl_io_tx_async.rs +++ b/hil-test/tests/parl_io_tx_async.rs @@ -12,7 +12,6 @@ use esp_hal::{ dma::{ChannelCreator, Dma, DmaPriority}, gpio::{ interconnect::{InputSignal, OutputSignal}, - Io, NoPin, }, parl_io::{ @@ -54,7 +53,6 @@ mod tests { async fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let (clock, _) = hil_test::common_test_pins!(peripherals); let valid = hil_test::unconnected_pin!(peripherals); let (clock_loopback, clock) = clock.split(); diff --git a/hil-test/tests/pcnt.rs b/hil-test/tests/pcnt.rs index de93787a275..7c18e62b1b9 100644 --- a/hil-test/tests/pcnt.rs +++ b/hil-test/tests/pcnt.rs @@ -7,7 +7,7 @@ use esp_hal::{ delay::Delay, - gpio::{AnyPin, Input, Io, Level, Output, Pin, Pull}, + gpio::{AnyPin, Input, Level, Output, Pin, Pull}, pcnt::{channel::EdgeMode, Pcnt}, }; use hil_test as _; @@ -28,8 +28,6 @@ mod tests { fn init() -> Context<'static> { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (din, dout) = hil_test::common_test_pins!(peripherals); let din = din.degrade(); diff --git a/hil-test/tests/qspi.rs b/hil-test/tests/qspi.rs index 125b1a69f92..0123e32d01a 100644 --- a/hil-test/tests/qspi.rs +++ b/hil-test/tests/qspi.rs @@ -10,7 +10,7 @@ use esp_hal::pcnt::{channel::EdgeMode, unit::Unit, Pcnt}; use esp_hal::{ dma::{Channel, Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, - gpio::{AnyPin, Input, Io, Level, Output, Pull}, + gpio::{AnyPin, Input, Level, Output, Pull}, prelude::*, spi::{ master::{Address, Command, Config, Spi, SpiDma}, @@ -184,8 +184,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (mut pin, mut pin_mirror) = hil_test::common_test_pins!(peripherals); let mut unconnected_pin = hil_test::unconnected_pin!(peripherals); diff --git a/hil-test/tests/rmt.rs b/hil-test/tests/rmt.rs index 4d2df21d1f4..c7c9db6d28e 100644 --- a/hil-test/tests/rmt.rs +++ b/hil-test/tests/rmt.rs @@ -6,7 +6,6 @@ #![no_main] use esp_hal::{ - gpio::Io, prelude::*, rmt::{PulseCode, Rmt, RxChannel, RxChannelConfig, TxChannel, TxChannelConfig}, }; @@ -25,8 +24,6 @@ mod tests { fn rmt_loopback() { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { let freq = 32.MHz(); diff --git a/hil-test/tests/spi_full_duplex.rs b/hil-test/tests/spi_full_duplex.rs index 18ba0f78b4f..7a0b0ea9570 100644 --- a/hil-test/tests/spi_full_duplex.rs +++ b/hil-test/tests/spi_full_duplex.rs @@ -14,7 +14,7 @@ use embedded_hal_async::spi::SpiBus as SpiBusAsync; use esp_hal::{ dma::{Dma, DmaDescriptor, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, - gpio::{Io, Level, NoPin}, + gpio::{Level, NoPin}, peripheral::Peripheral, prelude::*, spi::master::{Config, Spi}, @@ -58,7 +58,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio0; let (_, mosi) = hil_test::common_test_pins!(peripherals); diff --git a/hil-test/tests/spi_half_duplex_read.rs b/hil-test/tests/spi_half_duplex_read.rs index 1630f5ef4e1..8192850293e 100644 --- a/hil-test/tests/spi_half_duplex_read.rs +++ b/hil-test/tests/spi_half_duplex_read.rs @@ -8,7 +8,7 @@ use esp_hal::{ dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, - gpio::{Io, Level, Output}, + gpio::{Level, Output}, prelude::*, spi::{ master::{Address, Command, Config, Spi, SpiDma}, @@ -33,7 +33,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio0; let (miso, miso_mirror) = hil_test::common_test_pins!(peripherals); diff --git a/hil-test/tests/spi_half_duplex_write.rs b/hil-test/tests/spi_half_duplex_write.rs index f4f9c7970c2..7ec44286c4b 100644 --- a/hil-test/tests/spi_half_duplex_write.rs +++ b/hil-test/tests/spi_half_duplex_write.rs @@ -8,7 +8,7 @@ use esp_hal::{ dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, - gpio::{interconnect::InputSignal, Io}, + gpio::interconnect::InputSignal, pcnt::{channel::EdgeMode, unit::Unit, Pcnt}, prelude::*, spi::{ @@ -35,7 +35,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio0; let (mosi, _) = hil_test::common_test_pins!(peripherals); diff --git a/hil-test/tests/spi_half_duplex_write_psram.rs b/hil-test/tests/spi_half_duplex_write_psram.rs index 296466f277a..6968ecb32f5 100644 --- a/hil-test/tests/spi_half_duplex_write_psram.rs +++ b/hil-test/tests/spi_half_duplex_write_psram.rs @@ -53,7 +53,6 @@ mod tests { let peripherals = esp_hal::init(esp_hal::Config::default()); esp_alloc::psram_allocator!(peripherals.PSRAM, esp_hal::psram); - let io = Io::new(peripherals.IO_MUX); let sclk = peripherals.pins.gpio0; let (mosi, _) = hil_test::common_test_pins!(peripherals); diff --git a/hil-test/tests/spi_slave.rs b/hil-test/tests/spi_slave.rs index 6a0bbb877d0..6045f1d4d12 100644 --- a/hil-test/tests/spi_slave.rs +++ b/hil-test/tests/spi_slave.rs @@ -11,7 +11,7 @@ use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - gpio::{Input, Io, Level, Output, Pull}, + gpio::{Input, Level, Output, Pull}, peripheral::Peripheral, spi::{slave::Spi, SpiMode}, Blocking, @@ -103,8 +103,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (mosi_pin, miso_pin) = hil_test::i2c_pins!(peripherals); let (sclk_pin, _) = hil_test::common_test_pins!(peripherals); let cs_pin = hil_test::unconnected_pin!(peripherals); diff --git a/hil-test/tests/twai.rs b/hil-test/tests/twai.rs index a059ebc47da..14a871d7b36 100644 --- a/hil-test/tests/twai.rs +++ b/hil-test/tests/twai.rs @@ -7,7 +7,6 @@ use embedded_hal_02::can::Frame; use esp_hal::{ - gpio::Io, prelude::*, twai::{self, filter::SingleStandardFilter, EspTwaiFrame, StandardId, TwaiMode}, Blocking, @@ -28,8 +27,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (loopback_pin, _) = hil_test::common_test_pins!(peripherals); let (rx, tx) = loopback_pin.split(); diff --git a/hil-test/tests/uart.rs b/hil-test/tests/uart.rs index b5ab16e4f72..d9cddaa4180 100644 --- a/hil-test/tests/uart.rs +++ b/hil-test/tests/uart.rs @@ -7,7 +7,6 @@ use embedded_hal_02::serial::{Read, Write}; use esp_hal::{ - gpio::Io, prelude::*, uart::{self, ClockSource, Uart}, Blocking, @@ -28,8 +27,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (_, pin) = hil_test::common_test_pins!(peripherals); let (rx, tx) = pin.split(); diff --git a/hil-test/tests/uart_async.rs b/hil-test/tests/uart_async.rs index 9cf525c4911..7a36307c80d 100644 --- a/hil-test/tests/uart_async.rs +++ b/hil-test/tests/uart_async.rs @@ -6,7 +6,7 @@ #![no_std] #![no_main] -use esp_hal::{gpio::Io, uart::Uart, Async}; +use esp_hal::{uart::Uart, Async}; use hil_test as _; struct Context { @@ -22,8 +22,6 @@ mod tests { async fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (rx, tx) = hil_test::common_test_pins!(peripherals); let uart = Uart::new(peripherals.UART0, rx, tx).unwrap().into_async(); diff --git a/hil-test/tests/uart_regression.rs b/hil-test/tests/uart_regression.rs index 9a1fdb6f806..f2118afaa26 100644 --- a/hil-test/tests/uart_regression.rs +++ b/hil-test/tests/uart_regression.rs @@ -9,7 +9,6 @@ #[embedded_test::tests] mod tests { use esp_hal::{ - gpio::Io, prelude::*, uart::{UartRx, UartTx}, }; @@ -21,8 +20,6 @@ mod tests { fn test_that_creating_tx_does_not_cause_a_pulse() { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (rx, mut tx) = hil_test::common_test_pins!(peripherals); let mut rx = UartRx::new(peripherals.UART1, rx).unwrap(); diff --git a/hil-test/tests/uart_tx_rx.rs b/hil-test/tests/uart_tx_rx.rs index 9fb4db2f512..8274a9043db 100644 --- a/hil-test/tests/uart_tx_rx.rs +++ b/hil-test/tests/uart_tx_rx.rs @@ -6,7 +6,6 @@ #![no_main] use esp_hal::{ - gpio::Io, prelude::*, uart::{UartRx, UartTx}, Blocking, @@ -28,8 +27,6 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (rx, tx) = hil_test::common_test_pins!(peripherals); let tx = UartTx::new(peripherals.UART0, tx).unwrap(); diff --git a/hil-test/tests/uart_tx_rx_async.rs b/hil-test/tests/uart_tx_rx_async.rs index 6bd4b4a6808..4f02cf63bda 100644 --- a/hil-test/tests/uart_tx_rx_async.rs +++ b/hil-test/tests/uart_tx_rx_async.rs @@ -7,7 +7,6 @@ #![no_main] use esp_hal::{ - gpio::Io, uart::{UartRx, UartTx}, Async, }; @@ -27,8 +26,6 @@ mod tests { async fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.IO_MUX); - let (rx, tx) = hil_test::common_test_pins!(peripherals); let tx = UartTx::new(peripherals.UART0, tx).unwrap().into_async(); From 7db5b6301320e288357c5e03633d4c06ffbf3a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Sat, 9 Nov 2024 13:34:41 +0100 Subject: [PATCH 3/3] p.GPIO --- esp-hal/CHANGELOG.md | 2 +- esp-hal/MIGRATING-0.21.md | 2 +- esp-hal/src/analog/adc/mod.rs | 9 +- esp-hal/src/analog/dac.rs | 4 +- esp-hal/src/dma/mod.rs | 8 +- esp-hal/src/etm.rs | 4 +- esp-hal/src/gpio/etm.rs | 4 +- esp-hal/src/gpio/lp_io.rs | 2 +- esp-hal/src/gpio/mod.rs | 94 ++++----- esp-hal/src/gpio/rtc_io.rs | 2 +- esp-hal/src/i2c/master/mod.rs | 4 +- esp-hal/src/i2s/master.rs | 8 +- esp-hal/src/lcd_cam/cam.rs | 24 +-- esp-hal/src/lcd_cam/lcd/i8080.rs | 18 +- esp-hal/src/ledc/mod.rs | 2 +- esp-hal/src/lib.rs | 2 +- esp-hal/src/mcpwm/mod.rs | 2 +- esp-hal/src/mcpwm/operator.rs | 4 +- esp-hal/src/peripheral.rs | 102 ++++++---- esp-hal/src/rmt.rs | 2 +- esp-hal/src/rng.rs | 4 +- esp-hal/src/rom/md5.rs | 4 +- esp-hal/src/rtc_cntl/sleep/esp32c6.rs | 34 ++-- esp-hal/src/soc/esp32/efuse/mod.rs | 2 +- esp-hal/src/soc/esp32/gpio.rs | 47 +---- esp-hal/src/soc/esp32/peripherals.rs | 146 +++++++++----- esp-hal/src/soc/esp32c2/efuse/mod.rs | 2 +- esp-hal/src/soc/esp32c2/gpio.rs | 17 -- esp-hal/src/soc/esp32c2/peripherals.rs | 88 +++++---- esp-hal/src/soc/esp32c3/efuse/mod.rs | 2 +- esp-hal/src/soc/esp32c3/gpio.rs | 25 --- esp-hal/src/soc/esp32c3/peripherals.rs | 106 ++++++---- esp-hal/src/soc/esp32c6/efuse/mod.rs | 2 +- esp-hal/src/soc/esp32c6/gpio.rs | 34 ---- esp-hal/src/soc/esp32c6/peripherals.rs | 187 +++++++++++------- esp-hal/src/soc/esp32h2/efuse/mod.rs | 2 +- esp-hal/src/soc/esp32h2/gpio.rs | 36 +--- esp-hal/src/soc/esp32h2/peripherals.rs | 164 ++++++++------- esp-hal/src/soc/esp32s2/efuse/mod.rs | 2 +- esp-hal/src/soc/esp32s2/gpio.rs | 47 ----- esp-hal/src/soc/esp32s2/peripherals.rs | 144 +++++++++----- esp-hal/src/soc/esp32s3/efuse/mod.rs | 2 +- esp-hal/src/soc/esp32s3/gpio.rs | 48 ----- esp-hal/src/soc/esp32s3/peripherals.rs | 165 ++++++++++------ esp-hal/src/spi/master.rs | 8 +- esp-hal/src/spi/slave.rs | 8 +- esp-hal/src/touch.rs | 2 +- esp-hal/src/twai/mod.rs | 8 +- esp-hal/src/uart.rs | 20 +- examples/src/bin/adc.rs | 6 +- examples/src/bin/adc_cal.rs | 4 +- examples/src/bin/advanced_serial.rs | 7 +- examples/src/bin/blinky.rs | 2 +- examples/src/bin/blinky_erased_pins.rs | 10 +- examples/src/bin/dac.rs | 8 +- examples/src/bin/embassy_i2c.rs | 4 +- .../embassy_i2c_bmp180_calibration_data.rs | 4 +- examples/src/bin/embassy_i2s_parallel.rs | 18 +- examples/src/bin/embassy_i2s_read.rs | 8 +- examples/src/bin/embassy_i2s_sound.rs | 6 +- examples/src/bin/embassy_multicore.rs | 2 +- .../src/bin/embassy_multicore_interrupt.rs | 2 +- examples/src/bin/embassy_parl_io_rx.rs | 8 +- examples/src/bin/embassy_parl_io_tx.rs | 12 +- examples/src/bin/embassy_rmt_rx.rs | 8 +- examples/src/bin/embassy_rmt_tx.rs | 2 +- examples/src/bin/embassy_serial.rs | 12 +- examples/src/bin/embassy_spi.rs | 8 +- examples/src/bin/embassy_touch.rs | 4 +- examples/src/bin/embassy_twai.rs | 6 +- examples/src/bin/embassy_usb_serial.rs | 6 +- examples/src/bin/embassy_wait.rs | 4 +- examples/src/bin/etm_blinky_systimer.rs | 2 +- examples/src/bin/etm_gpio.rs | 4 +- examples/src/bin/gpio_interrupt.rs | 6 +- examples/src/bin/hello_world.rs | 12 +- .../src/bin/i2c_bmp180_calibration_data.rs | 4 +- examples/src/bin/i2c_display.rs | 4 +- examples/src/bin/i2s_parallel.rs | 18 +- examples/src/bin/i2s_read.rs | 8 +- examples/src/bin/i2s_sound.rs | 6 +- examples/src/bin/ieee802154_sniffer.rs | 4 +- examples/src/bin/lcd_cam_ov2640.rs | 28 +-- examples/src/bin/lcd_i8080.rs | 26 +-- examples/src/bin/ledc.rs | 2 +- examples/src/bin/lp_core_basic.rs | 2 +- examples/src/bin/lp_core_i2c.rs | 4 +- examples/src/bin/lp_core_uart.rs | 8 +- examples/src/bin/mcpwm.rs | 2 +- examples/src/bin/parl_io_rx.rs | 8 +- examples/src/bin/parl_io_tx.rs | 12 +- examples/src/bin/pcnt_encoder.rs | 4 +- examples/src/bin/qspi_flash.rs | 24 +-- examples/src/bin/rmt_rx.rs | 8 +- examples/src/bin/rmt_tx.rs | 2 +- examples/src/bin/serial_interrupts.rs | 12 +- examples/src/bin/sleep_timer_ext0.rs | 2 +- examples/src/bin/sleep_timer_ext1.rs | 4 +- examples/src/bin/sleep_timer_lpio.rs | 4 +- examples/src/bin/sleep_timer_rtcio.rs | 8 +- .../spi_halfduplex_read_manufacturer_id.rs | 24 +-- examples/src/bin/spi_loopback.rs | 6 +- examples/src/bin/spi_loopback_dma.rs | 8 +- examples/src/bin/spi_loopback_dma_psram.rs | 6 +- examples/src/bin/spi_slave_dma.rs | 18 +- examples/src/bin/touch.rs | 4 +- examples/src/bin/twai.rs | 6 +- examples/src/bin/ulp_riscv_core_basic.rs | 2 +- examples/src/bin/usb_serial.rs | 6 +- examples/src/bin/wifi_ble.rs | 4 +- examples/src/bin/wifi_embassy_ble.rs | 4 +- hil-test/src/lib.rs | 28 +-- hil-test/tests/embassy_interrupt_spi_dma.rs | 1 - hil-test/tests/gpio.rs | 4 +- hil-test/tests/lcd_cam_i8080.rs | 39 ++-- hil-test/tests/spi_full_duplex.rs | 2 +- hil-test/tests/spi_half_duplex_read.rs | 2 +- hil-test/tests/spi_half_duplex_write.rs | 2 +- hil-test/tests/spi_half_duplex_write_psram.rs | 4 +- 119 files changed, 1101 insertions(+), 1103 deletions(-) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index e19c5d07ee7..b056d84a6de 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -171,7 +171,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SPI transactions are now cancelled if the transfer object (or async Future) is dropped. (#2216) - The DMA channel types have been removed from peripherals (#2261) - `I2C` driver renamed to `I2c` (#2320) -- The GPIO pins are now accessible via `Peripherals` and are no longer part of the `Io` struct (#2508) +- The GPIO pins are now accessible via `Peripherals` and are no longer part of the `Io` struct (#2508) ### Fixed diff --git a/esp-hal/MIGRATING-0.21.md b/esp-hal/MIGRATING-0.21.md index 0b74c31f1ea..9304bddd0b6 100644 --- a/esp-hal/MIGRATING-0.21.md +++ b/esp-hal/MIGRATING-0.21.md @@ -8,7 +8,7 @@ let peripherals = esp_hal::init(Default::default()); -let io = Io::new(peripherals.GPIO, peripherals.IOMUX); -let pin = io.pins.gpio5; -+let pin = peripherals.pins.gpio5; ++let pin = peripherals.GPIO5; ``` ### `Io` constructor changes diff --git a/esp-hal/src/analog/adc/mod.rs b/esp-hal/src/analog/adc/mod.rs index 053e0ae1f8d..0f8f76067c5 100644 --- a/esp-hal/src/analog/adc/mod.rs +++ b/esp-hal/src/analog/adc/mod.rs @@ -31,14 +31,11 @@ //! # use esp_hal::analog::adc::Attenuation; //! # use esp_hal::analog::adc::Adc; //! # use esp_hal::delay::Delay; -#![cfg_attr(esp32, doc = "let analog_pin = peripherals.pins.gpio32;")] -#![cfg_attr( - any(esp32s2, esp32s3), - doc = "let analog_pin = peripherals.pins.gpio3;" -)] +#![cfg_attr(esp32, doc = "let analog_pin = peripherals.GPIO32;")] +#![cfg_attr(any(esp32s2, esp32s3), doc = "let analog_pin = peripherals.GPIO3;")] #![cfg_attr( not(any(esp32, esp32s2, esp32s3)), - doc = "let analog_pin = peripherals.pins.gpio2;" + doc = "let analog_pin = peripherals.GPIO2;" )] //! let mut adc1_config = AdcConfig::new(); //! let mut pin = adc1_config.enable_pin( diff --git a/esp-hal/src/analog/dac.rs b/esp-hal/src/analog/dac.rs index 9956375d67c..246dfa796c0 100644 --- a/esp-hal/src/analog/dac.rs +++ b/esp-hal/src/analog/dac.rs @@ -20,8 +20,8 @@ //! # use esp_hal::analog::dac::Dac; //! # use esp_hal::delay::Delay; //! # use embedded_hal::delay::DelayNs; -#![cfg_attr(esp32, doc = "let dac1_pin = peripherals.pins.gpio25;")] -#![cfg_attr(esp32s2, doc = "let dac1_pin = peripherals.pins.gpio17;")] +#![cfg_attr(esp32, doc = "let dac1_pin = peripherals.GPIO25;")] +#![cfg_attr(esp32s2, doc = "let dac1_pin = peripherals.GPIO17;")] //! let mut dac1 = Dac::new(peripherals.DAC1, dac1_pin); //! //! let mut delay = Delay::new(); diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index de519b3e3c1..e88776e423b 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -23,10 +23,10 @@ //! let dma = Dma::new(peripherals.DMA); #![cfg_attr(any(esp32, esp32s2), doc = "let dma_channel = dma.spi2channel;")] #![cfg_attr(not(any(esp32, esp32s2)), doc = "let dma_channel = dma.channel0;")] -//! let sclk = peripherals.pins.gpio0; -//! let miso = peripherals.pins.gpio2; -//! let mosi = peripherals.pins.gpio4; -//! let cs = peripherals.pins.gpio5; +//! let sclk = peripherals.GPIO0; +//! let miso = peripherals.GPIO2; +//! let mosi = peripherals.GPIO4; +//! let cs = peripherals.GPIO5; //! //! let mut spi = Spi::new_with_config( //! peripherals.SPI2, diff --git a/esp-hal/src/etm.rs b/esp-hal/src/etm.rs index c592978e73e..5276eadcccf 100644 --- a/esp-hal/src/etm.rs +++ b/esp-hal/src/etm.rs @@ -28,8 +28,8 @@ //! # use esp_hal::gpio::Pull; //! # use esp_hal::gpio::Level; //! -//! let mut led = peripherals.pins.gpio1; -//! let button = peripherals.pins.gpio9; +//! let mut led = peripherals.GPIO1; +//! let button = peripherals.GPIO9; //! //! // setup ETM //! let gpio_ext = Channels::new(peripherals.GPIO_SD); diff --git a/esp-hal/src/gpio/etm.rs b/esp-hal/src/gpio/etm.rs index a3fe2d22448..4ff74e67804 100644 --- a/esp-hal/src/gpio/etm.rs +++ b/esp-hal/src/gpio/etm.rs @@ -32,8 +32,8 @@ //! # use esp_hal::gpio::Pull; //! # use esp_hal::gpio::Level; //! # -//! # let mut led = peripherals.pins.gpio1; -//! # let button = peripherals.pins.gpio9; +//! # let mut led = peripherals.GPIO1; +//! # let button = peripherals.GPIO9; //! //! let gpio_ext = Channels::new(peripherals.GPIO_SD); //! let led_task = gpio_ext.channel0_task.toggle( diff --git a/esp-hal/src/gpio/lp_io.rs b/esp-hal/src/gpio/lp_io.rs index f744f1916f2..947a9efc7e8 100644 --- a/esp-hal/src/gpio/lp_io.rs +++ b/esp-hal/src/gpio/lp_io.rs @@ -23,7 +23,7 @@ //! use esp_hal::gpio::lp_io::LowPowerOutput; //! // configure GPIO 1 as LP output pin //! let lp_pin: LowPowerOutput<'_, 1> = -//! LowPowerOutput::new(peripherals.pins.gpio1); +//! LowPowerOutput::new(peripherals.GPIO1); //! # } //! ``` diff --git a/esp-hal/src/gpio/mod.rs b/esp-hal/src/gpio/mod.rs index d07c891d29d..c15dacbe529 100644 --- a/esp-hal/src/gpio/mod.rs +++ b/esp-hal/src/gpio/mod.rs @@ -18,9 +18,10 @@ //! GPIO interrupts. For more information, see the //! [`Io::set_interrupt_handler`]. //! -//! The pins are accessible via [`crate::Peripherals::pins`]. These pins can -//! then be passed to peripherals (such as SPI, UART, I2C, etc.), to pin drivers -//! or can be [`GpioPin::split`] into peripheral signals. +//! The pins are accessible via the [`crate::Peripherals`] struct returned by +//! [`crate::init`]. These pins can then be passed to peripherals (such as +//! SPI, UART, I2C, etc.), to pin drivers or can be [`GpioPin::split`] into +//! peripheral signals. //! //! Each pin is a different type initially. Internally, `esp-hal` will often //! erase their types automatically, but they can also be converted into @@ -52,7 +53,7 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::gpio::{Io, Level, Output}; -//! let mut led = Output::new(peripherals.pins.gpio5, Level::High); +//! let mut led = Output::new(peripherals.GPIO5, Level::High); //! # } //! ``` //! @@ -70,11 +71,18 @@ use portable_atomic::{AtomicPtr, Ordering}; use procmacros::ram; +#[cfg(any(lp_io, rtc_cntl))] +use crate::peripherals::gpio::{handle_rtcio, handle_rtcio_with_resistors}; pub use crate::soc::gpio::*; use crate::{ interrupt::{self, InterruptHandler, Priority}, peripheral::{Peripheral, PeripheralRef}, - peripherals::{Interrupt, GPIO, IO_MUX}, + peripherals::{ + gpio::{handle_gpio_input, handle_gpio_output, AnyPinInner}, + Interrupt, + GPIO, + IO_MUX, + }, private::{self, Sealed}, InterruptConfigurable, DEFAULT_INTERRUPT_HANDLER, @@ -715,6 +723,9 @@ impl Bank1GpioRegisterAccess { /// GPIO pin pub struct GpioPin; +/// Type-erased GPIO pin +pub struct AnyPin(pub(crate) AnyPinInner); + impl GpioPin where Self: Pin, @@ -905,20 +916,20 @@ macro_rules! if_rtcio_pin { #[macro_export] macro_rules! io_type { (Input, $gpionum:literal) => { - impl $crate::gpio::InputPin for GpioPin<$gpionum> {} + impl $crate::gpio::InputPin for $crate::gpio::GpioPin<$gpionum> {} }; (Output, $gpionum:literal) => { - impl $crate::gpio::OutputPin for GpioPin<$gpionum> {} + impl $crate::gpio::OutputPin for $crate::gpio::GpioPin<$gpionum> {} }; (Analog, $gpionum:literal) => { // FIXME: the implementation shouldn't be in the GPIO module #[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2))] - impl $crate::gpio::AnalogPin for GpioPin<$gpionum> { + impl $crate::gpio::AnalogPin for $crate::gpio::GpioPin<$gpionum> { /// Configures the pin for analog mode. fn set_analog(&self, _: $crate::private::Internal) { use $crate::peripherals::GPIO; - get_io_mux_reg($gpionum).modify(|_, w| unsafe { + $crate::gpio::get_io_mux_reg($gpionum).modify(|_, w| unsafe { w.mcu_sel().bits(1); w.fun_ie().clear_bit(); w.fun_wpu().clear_bit(); @@ -950,91 +961,70 @@ macro_rules! gpio { )+ ) => { paste::paste! { - /// Pins available on this chip - pub struct Pins { - $( - #[doc = concat!("GPIO pin number ", $gpionum, ".")] - pub [< gpio $gpionum >] : GpioPin<$gpionum>, - )+ - } - - impl Pins { - /// Unsafely create GPIO pins. - /// - /// # Safety - /// - /// The caller must ensure that only one instance of a pin is in use at one time. - pub unsafe fn steal() -> Self { - Self { - $( - [< gpio $gpionum >]: GpioPin::steal(), - )+ - } - } - } - $( $( $crate::io_type!($type, $gpionum); )* - impl $crate::gpio::Pin for GpioPin<$gpionum> { + impl $crate::gpio::Pin for $crate::gpio::GpioPin<$gpionum> { fn number(&self) -> u8 { $gpionum } - fn degrade_pin(&self, _: $crate::private::Internal) -> AnyPin { - AnyPin($crate::gpio::AnyPinInner::[< Gpio $gpionum >](unsafe { Self::steal() })) + fn degrade_pin(&self, _: $crate::private::Internal) -> $crate::gpio::AnyPin { + $crate::gpio::AnyPin(AnyPinInner::[< Gpio $gpionum >](unsafe { Self::steal() })) } fn gpio_bank(&self, _: $crate::private::Internal) -> $crate::gpio::GpioRegisterAccess { $crate::gpio::GpioRegisterAccess::from($gpionum) } - fn output_signals(&self, _: $crate::private::Internal) -> &[(AlternateFunction, OutputSignal)] { + fn output_signals(&self, _: $crate::private::Internal) -> &[($crate::gpio::AlternateFunction, $crate::gpio::OutputSignal)] { &[ $( $( - (AlternateFunction::[< Function $af_output_num >], OutputSignal::$af_output_signal ), + ( + $crate::gpio::AlternateFunction::[< Function $af_output_num >], + $crate::gpio::OutputSignal::$af_output_signal + ), )* )? ] } - fn input_signals(&self, _: $crate::private::Internal) -> &[(AlternateFunction, InputSignal)] { + fn input_signals(&self, _: $crate::private::Internal) -> &[($crate::gpio::AlternateFunction, $crate::gpio::InputSignal)] { &[ $( $( - (AlternateFunction::[< Function $af_input_num >], InputSignal::$af_input_signal ), + ( + $crate::gpio::AlternateFunction::[< Function $af_input_num >], + $crate::gpio::InputSignal::$af_input_signal + ), )* )? ] } } - impl From> for AnyPin { - fn from(pin: GpioPin<$gpionum>) -> Self { - use $crate::gpio::Pin; - pin.degrade() + impl From<$crate::gpio::GpioPin<$gpionum>> for $crate::gpio::AnyPin { + fn from(pin: $crate::gpio::GpioPin<$gpionum>) -> Self { + $crate::gpio::Pin::degrade(pin) } } )+ pub(crate) enum AnyPinInner { $( - [](GpioPin<$gpionum>), + []($crate::gpio::GpioPin<$gpionum>), )+ } - /// Type-erased GPIO pin - pub struct AnyPin(pub(crate) AnyPinInner); - - impl $crate::peripheral::Peripheral for AnyPin { - type P = AnyPin; + impl $crate::peripheral::Peripheral for $crate::gpio::AnyPin { + type P = $crate::gpio::AnyPin; unsafe fn clone_unchecked(&self) -> Self { match self.0 { $(AnyPinInner::[](_) => { - Self(AnyPinInner::[< Gpio $gpionum >](unsafe { GpioPin::steal() })) + Self(AnyPinInner::[< Gpio $gpionum >](unsafe { $crate::gpio::GpioPin::steal() })) })+ } } @@ -1043,7 +1033,6 @@ macro_rules! gpio { // These macros call the code block on the actually contained GPIO pin. #[doc(hidden)] - #[macro_export] macro_rules! handle_gpio_output { ($this:expr, $inner:ident, $code:tt) => { match $this { @@ -1060,7 +1049,6 @@ macro_rules! gpio { } #[doc(hidden)] - #[macro_export] macro_rules! handle_gpio_input { ($this:expr, $inner:ident, $code:tt) => { match $this { @@ -1077,7 +1065,6 @@ macro_rules! gpio { cfg_if::cfg_if! { if #[cfg(any(lp_io, rtc_cntl))] { #[doc(hidden)] - #[macro_export] macro_rules! handle_rtcio { ($this:expr, $inner:ident, $code:tt) => { match $this { @@ -1094,7 +1081,6 @@ macro_rules! gpio { } #[doc(hidden)] - #[macro_export] macro_rules! handle_rtcio_with_resistors { ($this:expr, $inner:ident, $code:tt) => { match $this { diff --git a/esp-hal/src/gpio/rtc_io.rs b/esp-hal/src/gpio/rtc_io.rs index be7aaf4f501..beebc37e3d4 100644 --- a/esp-hal/src/gpio/rtc_io.rs +++ b/esp-hal/src/gpio/rtc_io.rs @@ -24,7 +24,7 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::gpio::rtc_io::LowPowerOutput; //! // configure GPIO 1 as ULP output pin -//! let lp_pin = LowPowerOutput::<'static, 1>::new(peripherals.pins.gpio1); +//! let lp_pin = LowPowerOutput::<'static, 1>::new(peripherals.GPIO1); //! # } //! ``` diff --git a/esp-hal/src/i2c/master/mod.rs b/esp-hal/src/i2c/master/mod.rs index f086982d53c..7515d2ed8c4 100644 --- a/esp-hal/src/i2c/master/mod.rs +++ b/esp-hal/src/i2c/master/mod.rs @@ -26,8 +26,8 @@ //! peripherals.I2C0, //! Config::default(), //! ) -//! .with_sda(peripherals.pins.gpio1) -//! .with_scl(peripherals.pins.gpio2); +//! .with_sda(peripherals.GPIO1) +//! .with_scl(peripherals.GPIO2); //! //! loop { //! let mut data = [0u8; 22]; diff --git a/esp-hal/src/i2s/master.rs b/esp-hal/src/i2s/master.rs index 5da9e95ce26..95a33d62399 100644 --- a/esp-hal/src/i2s/master.rs +++ b/esp-hal/src/i2s/master.rs @@ -50,11 +50,11 @@ //! rx_descriptors, //! tx_descriptors, //! ); -#![cfg_attr(not(esp32), doc = "let i2s = i2s.with_mclk(peripherals.pins.gpio0);")] +#![cfg_attr(not(esp32), doc = "let i2s = i2s.with_mclk(peripherals.GPIO0);")] //! let mut i2s_rx = i2s.i2s_rx -//! .with_bclk(peripherals.pins.gpio1) -//! .with_ws(peripherals.pins.gpio2) -//! .with_din(peripherals.pins.gpio5) +//! .with_bclk(peripherals.GPIO1) +//! .with_ws(peripherals.GPIO2) +//! .with_din(peripherals.GPIO5) //! .build(); //! //! let mut transfer = i2s_rx.read_dma_circular(&mut rx_buffer).unwrap(); diff --git a/esp-hal/src/lcd_cam/cam.rs b/esp-hal/src/lcd_cam/cam.rs index 905c8d47d0b..5125d8b343d 100644 --- a/esp-hal/src/lcd_cam/cam.rs +++ b/esp-hal/src/lcd_cam/cam.rs @@ -31,19 +31,19 @@ //! # DmaPriority::Priority0, //! # ); //! -//! let mclk_pin = peripherals.pins.gpio15; -//! let vsync_pin = peripherals.pins.gpio6; -//! let href_pin = peripherals.pins.gpio7; -//! let pclk_pin = peripherals.pins.gpio13; +//! let mclk_pin = peripherals.GPIO15; +//! let vsync_pin = peripherals.GPIO6; +//! let href_pin = peripherals.GPIO7; +//! let pclk_pin = peripherals.GPIO13; //! let data_pins = RxEightBits::new( -//! peripherals.pins.gpio11, -//! peripherals.pins.gpio9, -//! peripherals.pins.gpio8, -//! peripherals.pins.gpio10, -//! peripherals.pins.gpio12, -//! peripherals.pins.gpio18, -//! peripherals.pins.gpio17, -//! peripherals.pins.gpio16, +//! peripherals.GPIO11, +//! peripherals.GPIO9, +//! peripherals.GPIO8, +//! peripherals.GPIO10, +//! peripherals.GPIO12, +//! peripherals.GPIO18, +//! peripherals.GPIO17, +//! peripherals.GPIO16, //! ); //! //! let lcd_cam = LcdCam::new(peripherals.LCD_CAM); diff --git a/esp-hal/src/lcd_cam/lcd/i8080.rs b/esp-hal/src/lcd_cam/lcd/i8080.rs index ce4b9e2e6b4..109b658aa39 100644 --- a/esp-hal/src/lcd_cam/lcd/i8080.rs +++ b/esp-hal/src/lcd_cam/lcd/i8080.rs @@ -30,14 +30,14 @@ //! # ); //! //! let tx_pins = TxEightBits::new( -//! peripherals.pins.gpio9, -//! peripherals.pins.gpio46, -//! peripherals.pins.gpio3, -//! peripherals.pins.gpio8, -//! peripherals.pins.gpio18, -//! peripherals.pins.gpio17, -//! peripherals.pins.gpio16, -//! peripherals.pins.gpio15, +//! peripherals.GPIO9, +//! peripherals.GPIO46, +//! peripherals.GPIO3, +//! peripherals.GPIO8, +//! peripherals.GPIO18, +//! peripherals.GPIO17, +//! peripherals.GPIO16, +//! peripherals.GPIO15, //! ); //! let lcd_cam = LcdCam::new(peripherals.LCD_CAM); //! @@ -48,7 +48,7 @@ //! 20.MHz(), //! Config::default(), //! ) -//! .with_ctrl_pins(peripherals.pins.gpio0, peripherals.pins.gpio47); +//! .with_ctrl_pins(peripherals.GPIO0, peripherals.GPIO47); //! //! dma_buf.fill(&[0x55]); //! let transfer = i8080.send(0x3Au8, 0, dma_buf).unwrap(); // RGB565 diff --git a/esp-hal/src/ledc/mod.rs b/esp-hal/src/ledc/mod.rs index fe414ff5677..54797a42880 100644 --- a/esp-hal/src/ledc/mod.rs +++ b/esp-hal/src/ledc/mod.rs @@ -29,7 +29,7 @@ //! # use esp_hal::ledc::timer; //! # use esp_hal::ledc::LowSpeed; //! # use esp_hal::ledc::channel; -//! # let led = peripherals.pins.gpio0; +//! # let led = peripherals.GPIO0; //! //! let mut ledc = Ledc::new(peripherals.LEDC); //! ledc.set_global_slow_clock(LSGlobalClkSource::APBClk); diff --git a/esp-hal/src/lib.rs b/esp-hal/src/lib.rs index ff938a3907a..21e2c6cd0cc 100644 --- a/esp-hal/src/lib.rs +++ b/esp-hal/src/lib.rs @@ -81,7 +81,7 @@ //! }); //! //! // Set GPIO0 as an output, and set its state high initially. -//! let mut led = Output::new(peripherals.pins.gpio0, Level::High); +//! let mut led = Output::new(peripherals.GPIO0, Level::High); //! //! let delay = Delay::new(); //! diff --git a/esp-hal/src/mcpwm/mod.rs b/esp-hal/src/mcpwm/mod.rs index 8f53ea33e66..dc981794a96 100644 --- a/esp-hal/src/mcpwm/mod.rs +++ b/esp-hal/src/mcpwm/mod.rs @@ -52,7 +52,7 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::mcpwm::{operator::{DeadTimeCfg, PWMStream, PwmPinConfig}, timer::PwmWorkingMode, McPwm, PeripheralClockConfig}; -//! # let pin = peripherals.pins.gpio0; +//! # let pin = peripherals.GPIO0; //! //! // initialize peripheral #![cfg_attr( diff --git a/esp-hal/src/mcpwm/operator.rs b/esp-hal/src/mcpwm/operator.rs index 1b580b72d60..51a8d0349b8 100644 --- a/esp-hal/src/mcpwm/operator.rs +++ b/esp-hal/src/mcpwm/operator.rs @@ -495,9 +495,9 @@ impl embedded_hal::pwm::SetD /// let mut mcpwm = McPwm::new(peripherals.MCPWM0, clock_cfg); /// /// let mut pins = mcpwm.operator0.with_linked_pins( -/// peripherals.pins.gpio0, +/// peripherals.GPIO0, /// PwmPinConfig::UP_DOWN_ACTIVE_HIGH, // use PWMA as our main input -/// peripherals.pins.gpio1, +/// peripherals.GPIO1, /// PwmPinConfig::EMPTY, // keep PWMB "low" /// bridge_off, /// ); diff --git a/esp-hal/src/peripheral.rs b/esp-hal/src/peripheral.rs index 19639c72b92..c2c10a417fe 100644 --- a/esp-hal/src/peripheral.rs +++ b/esp-hal/src/peripheral.rs @@ -121,14 +121,14 @@ impl DerefMut for PeripheralRef<'_, T> { /// live forever (`'static`): /// /// ```rust, ignore -/// let mut uart: Uart<'static, ...> = Uart::new(p.UART0, pins.gpio0, pins.gpio1); +/// let mut uart: Uart<'static, ...> = Uart::new(p.UART0, p.GPIO0, p.GPIO1); /// ``` /// /// Or you may call it with borrowed peripherals, which yields an instance that /// can only live for as long as the borrows last: /// /// ```rust, ignore -/// let mut uart: Uart<'_, ...> = Uart::new(&mut p.UART0, &mut pins.gpio0, &mut pins.gpio1); +/// let mut uart: Uart<'_, ...> = Uart::new(&mut p.UART0, &mut p.GPIO0, &mut p.GPIO1); /// ``` /// /// # Implementation details, for HAL authors @@ -222,9 +222,14 @@ mod peripheral_macros { #[macro_export] macro_rules! peripherals { ( - $( - $name:ident <= $from_pac:tt $(($($interrupt:ident),*))? - ), *$(,)? + peripherals: [ + $( + $name:ident <= $from_pac:tt $(($($interrupt:ident),*))? + ), *$(,)? + ], + pins: [ + $( ( $pin:literal, $($pin_tokens:tt)* ) )* + ] ) => { /// Contains the generated peripherals which implement [`Peripheral`] @@ -235,45 +240,59 @@ mod peripheral_macros { )* } - /// The `Peripherals` struct provides access to all of the hardware peripherals on the chip. - #[allow(non_snake_case)] - pub struct Peripherals { - $( - /// Each field represents a hardware peripheral. - pub $name: peripherals::$name, - )* - /// The pins available on this chip - pub pins: $crate::gpio::Pins, + pub(crate) mod gpio { + $crate::gpio! { + $( ($pin, $($pin_tokens)* ) )* + } } - impl Peripherals { - /// Returns all the peripherals *once* - #[inline] - pub(crate) fn take() -> Self { - #[no_mangle] - static mut _ESP_HAL_DEVICE_PERIPHERALS: bool = false; - - critical_section::with(|_| unsafe { - if _ESP_HAL_DEVICE_PERIPHERALS { - panic!("init called more than once!") - } - _ESP_HAL_DEVICE_PERIPHERALS = true; - Self::steal() - }) + paste::paste! { + /// The `Peripherals` struct provides access to all of the hardware peripherals on the chip. + #[allow(non_snake_case)] + pub struct Peripherals { + $( + #[doc = concat!("The ", stringify!($name), " peripheral.")] + pub $name: peripherals::$name, + )* + + $( + #[doc = concat!("GPIO", stringify!($pin))] + pub []: $crate::gpio::GpioPin<$pin>, + )* } - /// Unsafely create an instance of this peripheral out of thin air. - /// - /// # Safety - /// - /// You must ensure that you're only using one instance of this type at a time. - #[inline] - pub unsafe fn steal() -> Self { - Self { - $( - $name: peripherals::$name::steal(), - )* - pins: $crate::gpio::Pins::steal(), + impl Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub(crate) fn take() -> Self { + #[no_mangle] + static mut _ESP_HAL_DEVICE_PERIPHERALS: bool = false; + + critical_section::with(|_| unsafe { + if _ESP_HAL_DEVICE_PERIPHERALS { + panic!("init called more than once!") + } + _ESP_HAL_DEVICE_PERIPHERALS = true; + Self::steal() + }) + } + + /// Unsafely create an instance of this peripheral out of thin air. + /// + /// # Safety + /// + /// You must ensure that you're only using one instance of this type at a time. + #[inline] + pub unsafe fn steal() -> Self { + Self { + $( + $name: peripherals::$name::steal(), + )* + + $( + []: $crate::gpio::GpioPin::<$pin>::steal(), + )* + } } } } @@ -297,8 +316,7 @@ mod peripheral_macros { } )* )* - - } + }; } #[doc(hidden)] diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs index 67949ea1341..ef6f4b1063a 100644 --- a/esp-hal/src/rmt.rs +++ b/esp-hal/src/rmt.rs @@ -61,7 +61,7 @@ //! let mut channel = rmt //! .channel0 //! .configure( -//! peripherals.pins.gpio1, +//! peripherals.GPIO1, //! TxChannelConfig { //! clk_divider: 1, //! idle_output_level: false, diff --git a/esp-hal/src/rng.rs b/esp-hal/src/rng.rs index d9666e300e3..6266b9fddc9 100644 --- a/esp-hal/src/rng.rs +++ b/esp-hal/src/rng.rs @@ -147,8 +147,8 @@ impl rand_core::RngCore for Rng { /// let mut true_rand = trng.random(); /// let mut rng = trng.downgrade(); /// // ADC is available now -#[cfg_attr(esp32, doc = "let analog_pin = peripherals.pins.gpio32;")] -#[cfg_attr(not(esp32), doc = "let analog_pin = peripherals.pins.gpio3;")] +#[cfg_attr(esp32, doc = "let analog_pin = peripherals.GPIO32;")] +#[cfg_attr(not(esp32), doc = "let analog_pin = peripherals.GPIO3;")] /// let mut adc1_config = AdcConfig::new(); /// let mut adc1_pin = adc1_config.enable_pin( /// analog_pin, diff --git a/esp-hal/src/rom/md5.rs b/esp-hal/src/rom/md5.rs index 2c249e226df..1eb3e9a7480 100644 --- a/esp-hal/src/rom/md5.rs +++ b/esp-hal/src/rom/md5.rs @@ -34,7 +34,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.pins.gpio1, peripherals.pins.gpio2).unwrap(); +//! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.GPIO1, peripherals.GPIO2).unwrap(); //! # let data = "Dummy"; //! let d: md5::Digest = md5::compute(&data); //! writeln!(uart0, "{}", d); @@ -48,7 +48,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.pins.gpio1, peripherals.pins.gpio2).unwrap(); +//! # let mut uart0 = Uart::new(peripherals.UART0, peripherals.GPIO1, peripherals.GPIO2).unwrap(); //! # let data0 = "Dummy"; //! # let data1 = "Dummy"; //! # diff --git a/esp-hal/src/rtc_cntl/sleep/esp32c6.rs b/esp-hal/src/rtc_cntl/sleep/esp32c6.rs index 19e737c487c..4692513c992 100644 --- a/esp-hal/src/rtc_cntl/sleep/esp32c6.rs +++ b/esp-hal/src/rtc_cntl/sleep/esp32c6.rs @@ -3,7 +3,7 @@ use core::ops::Not; use crate::{ clock::Clock, efuse::Efuse, - gpio::{Pins, RtcFunction}, + gpio::RtcFunction, rtc_cntl::{ rtc::{ rtc_clk_cpu_freq_set_xtal, @@ -71,10 +71,10 @@ impl Ext1WakeupSource<'_, '_> { unsafe { lp_aon().ext_wakeup_cntl().read().ext_wakeup_sel().bits() } } - fn wake_io_reset(pins: &mut Pins) { - use crate::gpio::RtcPin; + fn wake_io_reset() { + use crate::gpio::{GpioPin, RtcPin}; - fn uninit_pin(pin: &mut impl RtcPin, wakeup_pins: u8) { + fn uninit_pin(mut pin: impl RtcPin, wakeup_pins: u8) { if wakeup_pins & (1 << pin.number()) != 0 { pin.rtcio_pad_hold(false); pin.rtc_set_config(false, false, RtcFunction::Rtc); @@ -82,14 +82,14 @@ impl Ext1WakeupSource<'_, '_> { } let wakeup_pins = Ext1WakeupSource::wakeup_pins(); - uninit_pin(&mut pins.gpio0, wakeup_pins); - uninit_pin(&mut pins.gpio1, wakeup_pins); - uninit_pin(&mut pins.gpio2, wakeup_pins); - uninit_pin(&mut pins.gpio3, wakeup_pins); - uninit_pin(&mut pins.gpio4, wakeup_pins); - uninit_pin(&mut pins.gpio5, wakeup_pins); - uninit_pin(&mut pins.gpio6, wakeup_pins); - uninit_pin(&mut pins.gpio7, wakeup_pins); + uninit_pin(unsafe { GpioPin::<0>::steal() }, wakeup_pins); + uninit_pin(unsafe { GpioPin::<1>::steal() }, wakeup_pins); + uninit_pin(unsafe { GpioPin::<2>::steal() }, wakeup_pins); + uninit_pin(unsafe { GpioPin::<3>::steal() }, wakeup_pins); + uninit_pin(unsafe { GpioPin::<4>::steal() }, wakeup_pins); + uninit_pin(unsafe { GpioPin::<5>::steal() }, wakeup_pins); + uninit_pin(unsafe { GpioPin::<6>::steal() }, wakeup_pins); + uninit_pin(unsafe { GpioPin::<7>::steal() }, wakeup_pins); } } @@ -898,15 +898,7 @@ impl RtcSleepConfig { fn wake_io_reset() { // loosely based on esp_deep_sleep_wakeup_io_reset - - let mut pins = unsafe { - // We're stealing pins to do some uninitialization after waking up from - // deep sleep. We have to be careful to only touch settings that were enabled - // by deep sleep setup. - Pins::steal() - }; - - Ext1WakeupSource::wake_io_reset(&mut pins); + Ext1WakeupSource::wake_io_reset(); } /// Finalize power-down flags, apply configuration based on the flags. diff --git a/esp-hal/src/soc/esp32/efuse/mod.rs b/esp-hal/src/soc/esp32/efuse/mod.rs index 1ffb4263002..ff59b537f9e 100644 --- a/esp-hal/src/soc/esp32/efuse/mod.rs +++ b/esp-hal/src/soc/esp32/efuse/mod.rs @@ -27,7 +27,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.GPIO4, peripherals.GPIO5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32/gpio.rs b/esp-hal/src/soc/esp32/gpio.rs index b2e34a52ff3..9a7f8449fff 100644 --- a/esp-hal/src/soc/esp32/gpio.rs +++ b/esp-hal/src/soc/esp32/gpio.rs @@ -536,7 +536,7 @@ macro_rules! rtcio_analog { ( $pin_num:expr, $rtc_pin:expr, $pin_reg:expr, $prefix:pat, $hold:ident $(, $rue:literal)? ) => { - impl $crate::gpio::RtcPin for GpioPin<$pin_num> { + impl $crate::gpio::RtcPin for $crate::gpio::GpioPin<$pin_num> { fn rtc_number(&self) -> u8 { $rtc_pin } @@ -565,7 +565,7 @@ macro_rules! rtcio_analog { $( // FIXME: replace with $(ignore($rue)) once stable rtcio_analog!(@ignore $rue); - impl $crate::gpio::RtcPinWithResistors for GpioPin<$pin_num> { + impl $crate::gpio::RtcPinWithResistors for $crate::gpio::GpioPin<$pin_num> { fn rtcio_pullup(&mut self, enable: bool) { paste::paste! { unsafe { $crate::peripherals::RTC_IO::steal() } @@ -582,7 +582,7 @@ macro_rules! rtcio_analog { } )? - impl $crate::gpio::AnalogPin for GpioPin<$pin_num> { + impl $crate::gpio::AnalogPin for $crate::gpio::GpioPin<$pin_num> { /// Configures the pin for analog mode. fn set_analog(&self, _: $crate::private::Internal) { use $crate::gpio::RtcPin; @@ -629,7 +629,7 @@ macro_rules! rtcio_analog { rtcio_analog!($pin_num, $rtc_pin, $pin_reg, $prefix, $hold $(, $rue )?); )+ - pub(crate) fn errata36(mut pin: AnyPin, pull_up: bool, pull_down: bool) { + pub(crate) fn errata36(mut pin: $crate::gpio::AnyPin, pull_up: bool, pull_down: bool) { use $crate::gpio::{Pin, RtcPinWithResistors}; let has_pullups = match pin.number() { @@ -744,45 +744,6 @@ macro_rules! touch { }; } -crate::gpio! { - (0, [Input, Output, Analog, RtcIo, Touch] (5 => EMAC_TX_CLK) (1 => CLK_OUT1)) - (1, [Input, Output] (5 => EMAC_RXD2) (0 => U0TXD 1 => CLK_OUT3)) - (2, [Input, Output, Analog, RtcIo, Touch] (1 => HSPIWP 3 => HS2_DATA0 4 => SD_DATA0) (3 => HS2_DATA0 4 => SD_DATA0)) - (3, [Input, Output] (0 => U0RXD) (1 => CLK_OUT2)) - (4, [Input, Output, Analog, RtcIo, Touch] (1 => HSPIHD 3 => HS2_DATA1 4 => SD_DATA1 5 => EMAC_TX_ER) (3 => HS2_DATA1 4 => SD_DATA1)) - (5, [Input, Output] (1 => VSPICS0 3 => HS1_DATA6 5 => EMAC_RX_CLK) (3 => HS1_DATA6)) - (6, [Input, Output] (4 => U1CTS) (0 => SD_CLK 1 => SPICLK 3 => HS1_CLK)) - (7, [Input, Output] (0 => SD_DATA0 1 => SPIQ 3 => HS1_DATA0) (0 => SD_DATA0 1 => SPIQ 3 => HS1_DATA0 4 => U2RTS)) - (8, [Input, Output] (0 => SD_DATA1 1 => SPID 3 => HS1_DATA1 4 => U2CTS) (0 => SD_DATA1 1 => SPID 3 => HS1_DATA1)) - (9, [Input, Output] (0 => SD_DATA2 1 => SPIHD 3 => HS1_DATA2 4 => U1RXD) (0 => SD_DATA2 1 => SPIHD 3 => HS1_DATA2)) - (10, [Input, Output] ( 0 => SD_DATA3 1 => SPIWP 3 => HS1_DATA3) (0 => SD_DATA3 1 => SPIWP 3 => HS1_DATA3 4 => U1TXD)) - (11, [Input, Output] ( 1 => SPICS0) (0 => SD_CMD 1 => SPICS0 3 => HS1_CMD 4 => U1RTS)) - (12, [Input, Output, Analog, RtcIo, Touch] (0 => MTDI 1 => HSPIQ 3 => HS2_DATA2 4 => SD_DATA2) (1 => HSPIQ 3 => HS2_DATA2 4 => SD_DATA2 5 => EMAC_TXD3)) - (13, [Input, Output, Analog, RtcIo, Touch] (0 => MTCK 1 => HSPID 3 => HS2_DATA3 4 => SD_DATA3) (1 => HSPID 3 => HS2_DATA3 4 => SD_DATA3 5 => EMAC_RX_ER)) - (14, [Input, Output, Analog, RtcIo, Touch] (0 => MTMS 1 => HSPICLK) (1 => HSPICLK 3 => HS2_CLK 4 => SD_CLK 5 => EMAC_TXD2)) - (15, [Input, Output, Analog, RtcIo, Touch] (1 => HSPICS0 5 => EMAC_RXD3) (0 => MTDO 1 => HSPICS0 3 => HS2_CMD 4 => SD_CMD)) - (16, [Input, Output] (3 => HS1_DATA4 4 => U2RXD) (3 => HS1_DATA4 5 => EMAC_CLK_OUT)) - (17, [Input, Output] (3 => HS1_DATA5) (3 => HS1_DATA5 4 => U2TXD 5 => EMAC_CLK_180)) - (18, [Input, Output] (1 => VSPICLK 3 => HS1_DATA7) (1 => VSPICLK 3 => HS1_DATA7)) - (19, [Input, Output] (1 => VSPIQ 3 => U0CTS) (1 => VSPIQ 5 => EMAC_TXD0)) - (20, [Input, Output]) - (21, [Input, Output] (1 => VSPIHD) (1 => VSPIHD 5 => EMAC_TX_EN)) - (22, [Input, Output] (1 => VSPIWP) (1 => VSPIWP 3 => U0RTS 5 => EMAC_TXD1)) - (23, [Input, Output] (1 => VSPID) (1 => VSPID 3 => HS1_STROBE)) - (24, [Input, Output]) - (25, [Input, Output, Analog, RtcIo] (5 => EMAC_RXD0) ()) - (26, [Input, Output, Analog, RtcIo] (5 => EMAC_RXD1) ()) - (27, [Input, Output, Analog, RtcIo, Touch] (5 => EMAC_RX_DV) ()) - (32, [Input, Output, Analog, RtcIo, Touch]) - (33, [Input, Output, Analog, RtcIo, Touch]) - (34, [Input, Analog, RtcIoInput]) - (35, [Input, Analog, RtcIoInput]) - (36, [Input, Analog, RtcIoInput]) - (37, [Input, Analog, RtcIoInput]) - (38, [Input, Analog, RtcIoInput]) - (39, [Input, Analog, RtcIoInput]) -} - rtcio_analog! { (36, 0, sensor_pads(), sense1_, sense1_hold_force ) (37, 1, sensor_pads(), sense2_, sense2_hold_force ) diff --git a/esp-hal/src/soc/esp32/peripherals.rs b/esp-hal/src/soc/esp32/peripherals.rs index 172ff834cf9..2bfa72fc05e 100644 --- a/esp-hal/src/soc/esp32/peripherals.rs +++ b/esp-hal/src/soc/esp32/peripherals.rs @@ -20,57 +20,97 @@ pub(crate) use self::peripherals::*; // peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're // creating "virtual peripherals" for them. crate::peripherals! { - ADC1 <= virtual, - ADC2 <= virtual, - AES <= AES, - APB_CTRL <= APB_CTRL, - BB <= BB, - BT <= virtual, - CPU_CTRL <= virtual, - DAC1 <= virtual, - DAC2 <= virtual, - DMA <= virtual, - EFUSE <= EFUSE, - FLASH_ENCRYPTION <= FLASH_ENCRYPTION, - FRC_TIMER <= FRC_TIMER, - GPIO_SD <= GPIO_SD, - HINF <= HINF, - I2C0 <= I2C0, - I2C1 <= I2C1, - I2S0 <= I2S0 (I2S0), - I2S1 <= I2S1 (I2S1), - IO_MUX <= IO_MUX, - LEDC <= LEDC, - MCPWM0 <= MCPWM0, - MCPWM1 <= MCPWM1, - NRX <= NRX, - PCNT <= PCNT, - PSRAM <= virtual, - RMT <= RMT, - RNG <= RNG, - RSA <= RSA, - LPWR <= RTC_CNTL, - RADIO_CLK <= virtual, - RTC_IO <= RTC_IO, - RTC_I2C <= RTC_I2C, - SDHOST <= SDHOST, - SHA <= SHA, - SLC <= SLC, - SLCHOST <= SLCHOST, - SPI0 <= SPI0, - SPI1 <= SPI1, - SPI2 <= SPI2 (SPI2_DMA, SPI2), - SPI3 <= SPI3 (SPI3_DMA, SPI3), - SYSTEM <= DPORT, - SW_INTERRUPT <= virtual, - TIMG0 <= TIMG0, - TIMG1 <= TIMG1, - TOUCH <= virtual, - TWAI0 <= TWAI0, - UART0 <= UART0, - UART1 <= UART1, - UART2 <= UART2, - UHCI0 <= UHCI0, - UHCI1 <= UHCI1, - WIFI <= virtual, + peripherals: [ + ADC1 <= virtual, + ADC2 <= virtual, + AES <= AES, + APB_CTRL <= APB_CTRL, + BB <= BB, + BT <= virtual, + CPU_CTRL <= virtual, + DAC1 <= virtual, + DAC2 <= virtual, + DMA <= virtual, + EFUSE <= EFUSE, + FLASH_ENCRYPTION <= FLASH_ENCRYPTION, + FRC_TIMER <= FRC_TIMER, + GPIO_SD <= GPIO_SD, + HINF <= HINF, + I2C0 <= I2C0, + I2C1 <= I2C1, + I2S0 <= I2S0 (I2S0), + I2S1 <= I2S1 (I2S1), + IO_MUX <= IO_MUX, + LEDC <= LEDC, + MCPWM0 <= MCPWM0, + MCPWM1 <= MCPWM1, + NRX <= NRX, + PCNT <= PCNT, + PSRAM <= virtual, + RMT <= RMT, + RNG <= RNG, + RSA <= RSA, + LPWR <= RTC_CNTL, + RADIO_CLK <= virtual, + RTC_IO <= RTC_IO, + RTC_I2C <= RTC_I2C, + SDHOST <= SDHOST, + SHA <= SHA, + SLC <= SLC, + SLCHOST <= SLCHOST, + SPI0 <= SPI0, + SPI1 <= SPI1, + SPI2 <= SPI2 (SPI2_DMA, SPI2), + SPI3 <= SPI3 (SPI3_DMA, SPI3), + SYSTEM <= DPORT, + SW_INTERRUPT <= virtual, + TIMG0 <= TIMG0, + TIMG1 <= TIMG1, + TOUCH <= virtual, + TWAI0 <= TWAI0, + UART0 <= UART0, + UART1 <= UART1, + UART2 <= UART2, + UHCI0 <= UHCI0, + UHCI1 <= UHCI1, + WIFI <= virtual, + ], + pins: [ + (0, [Input, Output, Analog, RtcIo, Touch] (5 => EMAC_TX_CLK) (1 => CLK_OUT1)) + (1, [Input, Output] (5 => EMAC_RXD2) (0 => U0TXD 1 => CLK_OUT3)) + (2, [Input, Output, Analog, RtcIo, Touch] (1 => HSPIWP 3 => HS2_DATA0 4 => SD_DATA0) (3 => HS2_DATA0 4 => SD_DATA0)) + (3, [Input, Output] (0 => U0RXD) (1 => CLK_OUT2)) + (4, [Input, Output, Analog, RtcIo, Touch] (1 => HSPIHD 3 => HS2_DATA1 4 => SD_DATA1 5 => EMAC_TX_ER) (3 => HS2_DATA1 4 => SD_DATA1)) + (5, [Input, Output] (1 => VSPICS0 3 => HS1_DATA6 5 => EMAC_RX_CLK) (3 => HS1_DATA6)) + (6, [Input, Output] (4 => U1CTS) (0 => SD_CLK 1 => SPICLK 3 => HS1_CLK)) + (7, [Input, Output] (0 => SD_DATA0 1 => SPIQ 3 => HS1_DATA0) (0 => SD_DATA0 1 => SPIQ 3 => HS1_DATA0 4 => U2RTS)) + (8, [Input, Output] (0 => SD_DATA1 1 => SPID 3 => HS1_DATA1 4 => U2CTS) (0 => SD_DATA1 1 => SPID 3 => HS1_DATA1)) + (9, [Input, Output] (0 => SD_DATA2 1 => SPIHD 3 => HS1_DATA2 4 => U1RXD) (0 => SD_DATA2 1 => SPIHD 3 => HS1_DATA2)) + (10, [Input, Output] ( 0 => SD_DATA3 1 => SPIWP 3 => HS1_DATA3) (0 => SD_DATA3 1 => SPIWP 3 => HS1_DATA3 4 => U1TXD)) + (11, [Input, Output] ( 1 => SPICS0) (0 => SD_CMD 1 => SPICS0 3 => HS1_CMD 4 => U1RTS)) + (12, [Input, Output, Analog, RtcIo, Touch] (0 => MTDI 1 => HSPIQ 3 => HS2_DATA2 4 => SD_DATA2) (1 => HSPIQ 3 => HS2_DATA2 4 => SD_DATA2 5 => EMAC_TXD3)) + (13, [Input, Output, Analog, RtcIo, Touch] (0 => MTCK 1 => HSPID 3 => HS2_DATA3 4 => SD_DATA3) (1 => HSPID 3 => HS2_DATA3 4 => SD_DATA3 5 => EMAC_RX_ER)) + (14, [Input, Output, Analog, RtcIo, Touch] (0 => MTMS 1 => HSPICLK) (1 => HSPICLK 3 => HS2_CLK 4 => SD_CLK 5 => EMAC_TXD2)) + (15, [Input, Output, Analog, RtcIo, Touch] (1 => HSPICS0 5 => EMAC_RXD3) (0 => MTDO 1 => HSPICS0 3 => HS2_CMD 4 => SD_CMD)) + (16, [Input, Output] (3 => HS1_DATA4 4 => U2RXD) (3 => HS1_DATA4 5 => EMAC_CLK_OUT)) + (17, [Input, Output] (3 => HS1_DATA5) (3 => HS1_DATA5 4 => U2TXD 5 => EMAC_CLK_180)) + (18, [Input, Output] (1 => VSPICLK 3 => HS1_DATA7) (1 => VSPICLK 3 => HS1_DATA7)) + (19, [Input, Output] (1 => VSPIQ 3 => U0CTS) (1 => VSPIQ 5 => EMAC_TXD0)) + (20, [Input, Output]) + (21, [Input, Output] (1 => VSPIHD) (1 => VSPIHD 5 => EMAC_TX_EN)) + (22, [Input, Output] (1 => VSPIWP) (1 => VSPIWP 3 => U0RTS 5 => EMAC_TXD1)) + (23, [Input, Output] (1 => VSPID) (1 => VSPID 3 => HS1_STROBE)) + (24, [Input, Output]) + (25, [Input, Output, Analog, RtcIo] (5 => EMAC_RXD0) ()) + (26, [Input, Output, Analog, RtcIo] (5 => EMAC_RXD1) ()) + (27, [Input, Output, Analog, RtcIo, Touch] (5 => EMAC_RX_DV) ()) + (32, [Input, Output, Analog, RtcIo, Touch]) + (33, [Input, Output, Analog, RtcIo, Touch]) + (34, [Input, Analog, RtcIoInput]) + (35, [Input, Analog, RtcIoInput]) + (36, [Input, Analog, RtcIoInput]) + (37, [Input, Analog, RtcIoInput]) + (38, [Input, Analog, RtcIoInput]) + (39, [Input, Analog, RtcIoInput]) + ] } diff --git a/esp-hal/src/soc/esp32c2/efuse/mod.rs b/esp-hal/src/soc/esp32c2/efuse/mod.rs index 83c5f116763..bfd724fd459 100644 --- a/esp-hal/src/soc/esp32c2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c2/efuse/mod.rs @@ -24,7 +24,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.GPIO4, peripherals.GPIO5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32c2/gpio.rs b/esp-hal/src/soc/esp32c2/gpio.rs index 5304cc66c1b..f7080686beb 100644 --- a/esp-hal/src/soc/esp32c2/gpio.rs +++ b/esp-hal/src/soc/esp32c2/gpio.rs @@ -215,23 +215,6 @@ where } } -crate::gpio! { - (0, [Input, Output, Analog, RtcIo]) - (1, [Input, Output, Analog, RtcIo]) - (2, [Input, Output, Analog, RtcIo] (2 => FSPIQ) (2 => FSPIQ)) - (3, [Input, Output, Analog, RtcIo]) - (4, [Input, Output, Analog, RtcIo] (2 => FSPIHD) (2 => FSPIHD)) - (5, [Input, Output, Analog, RtcIo] (2 => FSPIWP) (2 => FSPIWP)) - (6, [Input, Output] (2 => FSPICLK) (2 => FSPICLK_MUX)) - (7, [Input, Output] (2 => FSPID) (2 => FSPID)) - (8, [Input, Output]) - (9, [Input, Output]) - (10, [Input, Output] (2 => FSPICS0) (2 => FSPICS0)) - (18, [Input, Output]) - (19, [Input, Output]) - (20, [Input, Output] (0 => U0RXD) ()) -} - rtc_pins! { 0 1 diff --git a/esp-hal/src/soc/esp32c2/peripherals.rs b/esp-hal/src/soc/esp32c2/peripherals.rs index 4685a536c21..6748f4e6ce5 100644 --- a/esp-hal/src/soc/esp32c2/peripherals.rs +++ b/esp-hal/src/soc/esp32c2/peripherals.rs @@ -20,39 +20,57 @@ pub(crate) use self::peripherals::*; // peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're // creating "virtual peripherals" for them. crate::peripherals! { - ADC1 <= virtual, - APB_CTRL <= APB_CTRL, - ASSIST_DEBUG <= ASSIST_DEBUG, - BT <= virtual, - DMA <= DMA (DMA_CH0), - ECC <= ECC, - EFUSE <= EFUSE, - EXTMEM <= EXTMEM, - I2C0 <= I2C0, - INTERRUPT_CORE0 <= INTERRUPT_CORE0, - IO_MUX <= IO_MUX, - LEDC <= LEDC, - LPWR <= RTC_CNTL, - RADIO_CLK <= virtual, - RNG <= RNG, - SENSITIVE <= SENSITIVE, - SHA <= SHA, - SPI0 <= SPI0, - SPI1 <= SPI1, - SPI2 <= SPI2 (SPI2), - SYSTEM <= SYSTEM, - SYSTIMER <= SYSTIMER, - SW_INTERRUPT <= virtual, - TIMG0 <= TIMG0, - UART0 <= UART0, - UART1 <= UART1, - WIFI <= virtual, - XTS_AES <= XTS_AES, - MEM2MEM1 <= virtual, - MEM2MEM2 <= virtual, - MEM2MEM3 <= virtual, - MEM2MEM4 <= virtual, - MEM2MEM5 <= virtual, - MEM2MEM6 <= virtual, - MEM2MEM8 <= virtual, + peripherals: [ + ADC1 <= virtual, + APB_CTRL <= APB_CTRL, + ASSIST_DEBUG <= ASSIST_DEBUG, + BT <= virtual, + DMA <= DMA (DMA_CH0), + ECC <= ECC, + EFUSE <= EFUSE, + EXTMEM <= EXTMEM, + I2C0 <= I2C0, + INTERRUPT_CORE0 <= INTERRUPT_CORE0, + IO_MUX <= IO_MUX, + LEDC <= LEDC, + LPWR <= RTC_CNTL, + RADIO_CLK <= virtual, + RNG <= RNG, + SENSITIVE <= SENSITIVE, + SHA <= SHA, + SPI0 <= SPI0, + SPI1 <= SPI1, + SPI2 <= SPI2 (SPI2), + SYSTEM <= SYSTEM, + SYSTIMER <= SYSTIMER, + SW_INTERRUPT <= virtual, + TIMG0 <= TIMG0, + UART0 <= UART0, + UART1 <= UART1, + WIFI <= virtual, + XTS_AES <= XTS_AES, + MEM2MEM1 <= virtual, + MEM2MEM2 <= virtual, + MEM2MEM3 <= virtual, + MEM2MEM4 <= virtual, + MEM2MEM5 <= virtual, + MEM2MEM6 <= virtual, + MEM2MEM8 <= virtual, + ], + pins: [ + (0, [Input, Output, Analog, RtcIo]) + (1, [Input, Output, Analog, RtcIo]) + (2, [Input, Output, Analog, RtcIo] (2 => FSPIQ) (2 => FSPIQ)) + (3, [Input, Output, Analog, RtcIo]) + (4, [Input, Output, Analog, RtcIo] (2 => FSPIHD) (2 => FSPIHD)) + (5, [Input, Output, Analog, RtcIo] (2 => FSPIWP) (2 => FSPIWP)) + (6, [Input, Output] (2 => FSPICLK) (2 => FSPICLK_MUX)) + (7, [Input, Output] (2 => FSPID) (2 => FSPID)) + (8, [Input, Output]) + (9, [Input, Output]) + (10, [Input, Output] (2 => FSPICS0) (2 => FSPICS0)) + (18, [Input, Output]) + (19, [Input, Output]) + (20, [Input, Output] (0 => U0RXD) ()) + ] } diff --git a/esp-hal/src/soc/esp32c3/efuse/mod.rs b/esp-hal/src/soc/esp32c3/efuse/mod.rs index 5d4f4d7fc7c..c7fae51caab 100644 --- a/esp-hal/src/soc/esp32c3/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c3/efuse/mod.rs @@ -25,7 +25,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.GPIO4, peripherals.GPIO5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32c3/gpio.rs b/esp-hal/src/soc/esp32c3/gpio.rs index 80af84bb36f..f6a4fd76fcb 100644 --- a/esp-hal/src/soc/esp32c3/gpio.rs +++ b/esp-hal/src/soc/esp32c3/gpio.rs @@ -243,31 +243,6 @@ where } } -crate::gpio! { - (0, [Input, Output, Analog, RtcIo]) - (1, [Input, Output, Analog, RtcIo]) - (2, [Input, Output, Analog, RtcIo] (2 => FSPIQ) (2 => FSPIQ)) - (3, [Input, Output, Analog, RtcIo]) - (4, [Input, Output, Analog, RtcIo] (2 => FSPIHD) (0 => USB_JTAG_TMS 2 => FSPIHD)) - (5, [Input, Output, Analog, RtcIo] (2 => FSPIWP) (0 => USB_JTAG_TDI 2 => FSPIWP)) - (6, [Input, Output] (2 => FSPICLK) (0 => USB_JTAG_TCK 2 => FSPICLK_MUX)) - (7, [Input, Output] (2 => FSPID) (0 => USB_JTAG_TDO 2 => FSPID)) - (8, [Input, Output]) - (9, [Input, Output]) - (10, [Input, Output] (2 => FSPICS0) (2 => FSPICS0)) - (11, [Input, Output]) - (12, [Input, Output] (0 => SPIHD) (0 => SPIHD)) - (13, [Input, Output] (0 => SPIWP) (0 => SPIWP)) - (14, [Input, Output] () (0 => SPICS0)) - (15, [Input, Output] () (0 => SPICLK_MUX)) - (16, [Input, Output] (0 => SPID) (0 => SPID)) - (17, [Input, Output] (0 => SPIQ) (0 => SPIQ)) - (18, [Input, Output]) - (19, [Input, Output]) - (20, [Input, Output] (0 => U0RXD) ()) - (21, [Input, Output] () (0 => U0TXD)) -} - // RTC pins 0 through 5 (inclusive) support GPIO wakeup rtc_pins! { 0 diff --git a/esp-hal/src/soc/esp32c3/peripherals.rs b/esp-hal/src/soc/esp32c3/peripherals.rs index 611a3f13f8a..f4a52d4fc08 100644 --- a/esp-hal/src/soc/esp32c3/peripherals.rs +++ b/esp-hal/src/soc/esp32c3/peripherals.rs @@ -20,44 +20,70 @@ pub(crate) use self::peripherals::*; // peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're // creating "virtual peripherals" for them. crate::peripherals! { - ADC1 <= virtual, - ADC2 <= virtual, - AES <= AES, - APB_CTRL <= APB_CTRL, - ASSIST_DEBUG <= ASSIST_DEBUG, - BT <= virtual, - DMA <= DMA (DMA_CH0,DMA_CH1,DMA_CH2), - DS <= DS, - EFUSE <= EFUSE, - EXTMEM <= EXTMEM, - GPIO_SD <= GPIO_SD, - HMAC <= HMAC, - I2C0 <= I2C0, - I2S0 <= I2S0 (I2S0), - INTERRUPT_CORE0 <= INTERRUPT_CORE0, - IO_MUX <= IO_MUX, - LEDC <= LEDC, - LPWR <= RTC_CNTL, - RADIO_CLK <= virtual, - RMT <= RMT, - RNG <= RNG, - RSA <= RSA, - SENSITIVE <= SENSITIVE, - SHA <= SHA, - SPI0 <= SPI0, - SPI1 <= SPI1, - SPI2 <= SPI2 (SPI2), - SYSTEM <= SYSTEM, - SYSTIMER <= SYSTIMER, - SW_INTERRUPT <= virtual, - TIMG0 <= TIMG0, - TIMG1 <= TIMG1, - TWAI0 <= TWAI0, - UART0 <= UART0, - UART1 <= UART1, - UHCI0 <= UHCI0, - UHCI1 <= UHCI1, - USB_DEVICE <= USB_DEVICE, - WIFI <= virtual, - XTS_AES <= XTS_AES, + peripherals: [ + ADC1 <= virtual, + ADC2 <= virtual, + AES <= AES, + APB_CTRL <= APB_CTRL, + ASSIST_DEBUG <= ASSIST_DEBUG, + BT <= virtual, + DMA <= DMA (DMA_CH0,DMA_CH1,DMA_CH2), + DS <= DS, + EFUSE <= EFUSE, + EXTMEM <= EXTMEM, + GPIO_SD <= GPIO_SD, + HMAC <= HMAC, + I2C0 <= I2C0, + I2S0 <= I2S0 (I2S0), + INTERRUPT_CORE0 <= INTERRUPT_CORE0, + IO_MUX <= IO_MUX, + LEDC <= LEDC, + LPWR <= RTC_CNTL, + RADIO_CLK <= virtual, + RMT <= RMT, + RNG <= RNG, + RSA <= RSA, + SENSITIVE <= SENSITIVE, + SHA <= SHA, + SPI0 <= SPI0, + SPI1 <= SPI1, + SPI2 <= SPI2 (SPI2), + SYSTEM <= SYSTEM, + SYSTIMER <= SYSTIMER, + SW_INTERRUPT <= virtual, + TIMG0 <= TIMG0, + TIMG1 <= TIMG1, + TWAI0 <= TWAI0, + UART0 <= UART0, + UART1 <= UART1, + UHCI0 <= UHCI0, + UHCI1 <= UHCI1, + USB_DEVICE <= USB_DEVICE, + WIFI <= virtual, + XTS_AES <= XTS_AES, + ], + pins: [ + (0, [Input, Output, Analog, RtcIo]) + (1, [Input, Output, Analog, RtcIo]) + (2, [Input, Output, Analog, RtcIo] (2 => FSPIQ) (2 => FSPIQ)) + (3, [Input, Output, Analog, RtcIo]) + (4, [Input, Output, Analog, RtcIo] (2 => FSPIHD) (0 => USB_JTAG_TMS 2 => FSPIHD)) + (5, [Input, Output, Analog, RtcIo] (2 => FSPIWP) (0 => USB_JTAG_TDI 2 => FSPIWP)) + (6, [Input, Output] (2 => FSPICLK) (0 => USB_JTAG_TCK 2 => FSPICLK_MUX)) + (7, [Input, Output] (2 => FSPID) (0 => USB_JTAG_TDO 2 => FSPID)) + (8, [Input, Output]) + (9, [Input, Output]) + (10, [Input, Output] (2 => FSPICS0) (2 => FSPICS0)) + (11, [Input, Output]) + (12, [Input, Output] (0 => SPIHD) (0 => SPIHD)) + (13, [Input, Output] (0 => SPIWP) (0 => SPIWP)) + (14, [Input, Output] () (0 => SPICS0)) + (15, [Input, Output] () (0 => SPICLK_MUX)) + (16, [Input, Output] (0 => SPID) (0 => SPID)) + (17, [Input, Output] (0 => SPIQ) (0 => SPIQ)) + (18, [Input, Output]) + (19, [Input, Output]) + (20, [Input, Output] (0 => U0RXD) ()) + (21, [Input, Output] () (0 => U0TXD)) + ] } diff --git a/esp-hal/src/soc/esp32c6/efuse/mod.rs b/esp-hal/src/soc/esp32c6/efuse/mod.rs index f5cd1105126..9e2906e2af7 100644 --- a/esp-hal/src/soc/esp32c6/efuse/mod.rs +++ b/esp-hal/src/soc/esp32c6/efuse/mod.rs @@ -25,7 +25,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.GPIO4, peripherals.GPIO5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32c6/gpio.rs b/esp-hal/src/soc/esp32c6/gpio.rs index 32c73525600..b7d84a403aa 100644 --- a/esp-hal/src/soc/esp32c6/gpio.rs +++ b/esp-hal/src/soc/esp32c6/gpio.rs @@ -287,40 +287,6 @@ pub enum OutputSignal { GPIO = 128, } -crate::gpio! { - (0, [Input, Output, Analog, RtcIo]) - (1, [Input, Output, Analog, RtcIo]) - (2, [Input, Output, Analog, RtcIo] (2 => FSPIQ) (2 => FSPIQ)) - (3, [Input, Output, Analog, RtcIo]) - (4, [Input, Output, Analog, RtcIo] (2 => FSPIHD) (0 => USB_JTAG_TMS 2 => FSPIHD)) - (5, [Input, Output, Analog, RtcIo] (2 => FSPIWP) (0 => USB_JTAG_TDI 2 => FSPIWP)) - (6, [Input, Output, Analog, RtcIo] (2 => FSPICLK) (0 => USB_JTAG_TCK 2 => FSPICLK_MUX)) - (7, [Input, Output, Analog, RtcIo] (2 => FSPID) (0 => USB_JTAG_TDO 2 => FSPID)) - (8, [Input, Output]) - (9, [Input, Output]) - (10, [Input, Output]) - (11, [Input, Output]) - (12, [Input, Output]) - (13, [Input, Output]) - (14, [Input, Output]) - (15, [Input, Output]) - (16, [Input, Output] (0 => U0RXD) (2 => FSPICS0)) - (17, [Input, Output] () (0 => U0TXD 2 => FSPICS1)) - (18, [Input, Output] () (2 => FSPICS2)) // 0 => SDIO_CMD but there are no signals since it's a fixed pin - (19, [Input, Output] () (2 => FSPICS3)) // 0 => SDIO_CLK but there are no signals since it's a fixed pin - (20, [Input, Output] () (2 => FSPICS4)) // 0 => SDIO_DATA0 but there are no signals since it's a fixed pin - (21, [Input, Output] () (2 => FSPICS5)) // 0 => SDIO_DATA1 but there are no signals since it's a fixed pin - (22, [Input, Output] () ()) // 0 => SDIO_DATA2 but there are no signals since it's a fixed pin - (23, [Input, Output] () ()) // 0 => SDIO_DATA3 but there are no signals since it's a fixed pin - (24, [Input, Output] () (0 => SPICS0)) - (25, [Input, Output] (0 => SPIQ) (0 => SPIQ)) - (26, [Input, Output] (0 => SPIWP) (0 => SPIWP)) - (27, [Input, Output]) - (28, [Input, Output] (0 => SPIHD) (0 => SPIHD)) - (29, [Input, Output] () (0 => SPICLK_MUX)) - (30, [Input, Output] (0 => SPID) (0 => SPID)) -} - crate::lp_gpio! { 0 1 diff --git a/esp-hal/src/soc/esp32c6/peripherals.rs b/esp-hal/src/soc/esp32c6/peripherals.rs index c983c46b6fc..b521161faf9 100644 --- a/esp-hal/src/soc/esp32c6/peripherals.rs +++ b/esp-hal/src/soc/esp32c6/peripherals.rs @@ -20,80 +20,115 @@ pub(crate) use self::peripherals::*; // peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're // creating "virtual peripherals" for them. crate::peripherals! { - ADC1 <= virtual, - AES <= AES, - ASSIST_DEBUG <= ASSIST_DEBUG, - ATOMIC <= ATOMIC, - BT <= virtual, - DMA <= DMA (DMA_IN_CH0,DMA_IN_CH1,DMA_IN_CH2,DMA_OUT_CH0,DMA_OUT_CH1,DMA_OUT_CH2), - DS <= DS, - ECC <= ECC, - EFUSE <= EFUSE, - EXTMEM <= EXTMEM, - GPIO_SD <= GPIO_SD, - HINF <= HINF, - HMAC <= HMAC, - HP_APM <= HP_APM, - HP_SYS <= HP_SYS, - I2C0 <= I2C0, - I2S0 <= I2S0 (I2S0), - IEEE802154 <= IEEE802154, - INTERRUPT_CORE0 <= INTERRUPT_CORE0, - INTPRI <= INTPRI, - IO_MUX <= IO_MUX, - LEDC <= LEDC, - LPWR <= LP_CLKRST, - LP_CORE <= virtual, - LP_PERI <= LP_PERI, - LP_ANA <= LP_ANA, - LP_AON <= LP_AON, - LP_APM <= LP_APM, - LP_APM0 <= LP_APM0, - LP_I2C0 <= LP_I2C0, - LP_I2C_ANA_MST <= LP_I2C_ANA_MST, - LP_IO <= LP_IO, - LP_TEE <= LP_TEE, - LP_TIMER <= LP_TIMER, - LP_UART <= LP_UART, - LP_WDT <= LP_WDT, - MCPWM0 <= MCPWM0, - MEM_MONITOR <= MEM_MONITOR, - OTP_DEBUG <= OTP_DEBUG, - PARL_IO <= PARL_IO (PARL_IO), - PAU <= PAU, - PCNT <= PCNT, - PMU <= PMU, - RADIO_CLK <= virtual, - RMT <= RMT, - RNG <= RNG, - RSA <= RSA, - SHA <= SHA, - SLCHOST <= SLCHOST, - SOC_ETM <= SOC_ETM, - SPI0 <= SPI0, - SPI1 <= SPI1, - SPI2 <= SPI2 (SPI2), - SYSTEM <= PCR, - SYSTIMER <= SYSTIMER, - SW_INTERRUPT <= virtual, - TEE <= TEE, - TIMG0 <= TIMG0, - TIMG1 <= TIMG1, - TRACE0 <= TRACE, - TWAI0 <= TWAI0, - TWAI1 <= TWAI1, - UART0 <= UART0, - UART1 <= UART1, - UHCI0 <= UHCI0, - USB_DEVICE <= USB_DEVICE, - WIFI <= virtual, - MEM2MEM1 <= virtual, - MEM2MEM4 <= virtual, - MEM2MEM5 <= virtual, - MEM2MEM10 <= virtual, - MEM2MEM11 <= virtual, - MEM2MEM12 <= virtual, - MEM2MEM13 <= virtual, - MEM2MEM14 <= virtual, - MEM2MEM15 <= virtual, + peripherals: [ + ADC1 <= virtual, + AES <= AES, + ASSIST_DEBUG <= ASSIST_DEBUG, + ATOMIC <= ATOMIC, + BT <= virtual, + DMA <= DMA (DMA_IN_CH0,DMA_IN_CH1,DMA_IN_CH2,DMA_OUT_CH0,DMA_OUT_CH1,DMA_OUT_CH2), + DS <= DS, + ECC <= ECC, + EFUSE <= EFUSE, + EXTMEM <= EXTMEM, + GPIO_SD <= GPIO_SD, + HINF <= HINF, + HMAC <= HMAC, + HP_APM <= HP_APM, + HP_SYS <= HP_SYS, + I2C0 <= I2C0, + I2S0 <= I2S0 (I2S0), + IEEE802154 <= IEEE802154, + INTERRUPT_CORE0 <= INTERRUPT_CORE0, + INTPRI <= INTPRI, + IO_MUX <= IO_MUX, + LEDC <= LEDC, + LPWR <= LP_CLKRST, + LP_CORE <= virtual, + LP_PERI <= LP_PERI, + LP_ANA <= LP_ANA, + LP_AON <= LP_AON, + LP_APM <= LP_APM, + LP_APM0 <= LP_APM0, + LP_I2C0 <= LP_I2C0, + LP_I2C_ANA_MST <= LP_I2C_ANA_MST, + LP_IO <= LP_IO, + LP_TEE <= LP_TEE, + LP_TIMER <= LP_TIMER, + LP_UART <= LP_UART, + LP_WDT <= LP_WDT, + MCPWM0 <= MCPWM0, + MEM_MONITOR <= MEM_MONITOR, + OTP_DEBUG <= OTP_DEBUG, + PARL_IO <= PARL_IO (PARL_IO), + PAU <= PAU, + PCNT <= PCNT, + PMU <= PMU, + RADIO_CLK <= virtual, + RMT <= RMT, + RNG <= RNG, + RSA <= RSA, + SHA <= SHA, + SLCHOST <= SLCHOST, + SOC_ETM <= SOC_ETM, + SPI0 <= SPI0, + SPI1 <= SPI1, + SPI2 <= SPI2 (SPI2), + SYSTEM <= PCR, + SYSTIMER <= SYSTIMER, + SW_INTERRUPT <= virtual, + TEE <= TEE, + TIMG0 <= TIMG0, + TIMG1 <= TIMG1, + TRACE0 <= TRACE, + TWAI0 <= TWAI0, + TWAI1 <= TWAI1, + UART0 <= UART0, + UART1 <= UART1, + UHCI0 <= UHCI0, + USB_DEVICE <= USB_DEVICE, + WIFI <= virtual, + MEM2MEM1 <= virtual, + MEM2MEM4 <= virtual, + MEM2MEM5 <= virtual, + MEM2MEM10 <= virtual, + MEM2MEM11 <= virtual, + MEM2MEM12 <= virtual, + MEM2MEM13 <= virtual, + MEM2MEM14 <= virtual, + MEM2MEM15 <= virtual, + ], + pins: [ + (0, [Input, Output, Analog, RtcIo]) + (1, [Input, Output, Analog, RtcIo]) + (2, [Input, Output, Analog, RtcIo] (2 => FSPIQ) (2 => FSPIQ)) + (3, [Input, Output, Analog, RtcIo]) + (4, [Input, Output, Analog, RtcIo] (2 => FSPIHD) (0 => USB_JTAG_TMS 2 => FSPIHD)) + (5, [Input, Output, Analog, RtcIo] (2 => FSPIWP) (0 => USB_JTAG_TDI 2 => FSPIWP)) + (6, [Input, Output, Analog, RtcIo] (2 => FSPICLK) (0 => USB_JTAG_TCK 2 => FSPICLK_MUX)) + (7, [Input, Output, Analog, RtcIo] (2 => FSPID) (0 => USB_JTAG_TDO 2 => FSPID)) + (8, [Input, Output]) + (9, [Input, Output]) + (10, [Input, Output]) + (11, [Input, Output]) + (12, [Input, Output]) + (13, [Input, Output]) + (14, [Input, Output]) + (15, [Input, Output]) + (16, [Input, Output] (0 => U0RXD) (2 => FSPICS0)) + (17, [Input, Output] () (0 => U0TXD 2 => FSPICS1)) + (18, [Input, Output] () (2 => FSPICS2)) // 0 => SDIO_CMD but there are no signals since it's a fixed pin + (19, [Input, Output] () (2 => FSPICS3)) // 0 => SDIO_CLK but there are no signals since it's a fixed pin + (20, [Input, Output] () (2 => FSPICS4)) // 0 => SDIO_DATA0 but there are no signals since it's a fixed pin + (21, [Input, Output] () (2 => FSPICS5)) // 0 => SDIO_DATA1 but there are no signals since it's a fixed pin + (22, [Input, Output] () ()) // 0 => SDIO_DATA2 but there are no signals since it's a fixed pin + (23, [Input, Output] () ()) // 0 => SDIO_DATA3 but there are no signals since it's a fixed pin + (24, [Input, Output] () (0 => SPICS0)) + (25, [Input, Output] (0 => SPIQ) (0 => SPIQ)) + (26, [Input, Output] (0 => SPIWP) (0 => SPIWP)) + (27, [Input, Output]) + (28, [Input, Output] (0 => SPIHD) (0 => SPIHD)) + (29, [Input, Output] () (0 => SPICLK_MUX)) + (30, [Input, Output] (0 => SPID) (0 => SPID)) + ] } diff --git a/esp-hal/src/soc/esp32h2/efuse/mod.rs b/esp-hal/src/soc/esp32h2/efuse/mod.rs index 40ca4cee29d..eaf75d21d5c 100644 --- a/esp-hal/src/soc/esp32h2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32h2/efuse/mod.rs @@ -25,7 +25,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.GPIO4, peripherals.GPIO5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32h2/gpio.rs b/esp-hal/src/soc/esp32h2/gpio.rs index fba6b839dd2..ffff2e84797 100644 --- a/esp-hal/src/soc/esp32h2/gpio.rs +++ b/esp-hal/src/soc/esp32h2/gpio.rs @@ -36,10 +36,7 @@ //! registers for both the `PRO CPU` and `APP CPU`. The implementation uses the //! `gpio` peripheral to access the appropriate registers. -use crate::{ - gpio::{AlternateFunction, GpioPin}, - peripherals::GPIO, -}; +use crate::{gpio::AlternateFunction, peripherals::GPIO}; // https://github.com/espressif/esp-idf/blob/df9310a/components/soc/esp32h2/gpio_periph.c#L42 /// The total number of GPIO pins available. @@ -252,37 +249,6 @@ pub enum OutputSignal { GPIO = 128, } -crate::gpio! { - (0, [Input, Output, Analog] (2 => FSPIQ) (2 => FSPIQ)) - (1, [Input, Output, Analog] (2 => FSPICS0) (2 => FSPICS0)) - (2, [Input, Output, Analog] (2 => FSPIWP) (2 => FSPIWP)) - (3, [Input, Output, Analog] (2 => FSPIHD) (2 => FSPIHD)) - (4, [Input, Output, Analog] (2 => FSPICLK) (2 => FSPICLK_MUX)) - (5, [Input, Output, Analog] (2 => FSPID) (2 => FSPID)) - (6, [Input, Output]) - (7, [Input, Output]) - (8, [Input, Output]) - (9, [Input, Output]) - (10, [Input, Output]) - (11, [Input, Output]) - (12, [Input, Output]) - (13, [Input, Output]) - (14, [Input, Output]) - (15, [Input, Output] () (0 => SPICS0)) - (16, [Input, Output] (0 => SPIQ) (0 => SPIQ)) - (17, [Input, Output] (0 => SPIWP) (0 => SPIWP)) - (18, [Input, Output] (0 => SPIHD) (0 => SPIHD)) - (19, [Input, Output] () (0 => SPICLK)) - (20, [Input, Output] (0 => SPID) (0 => SPID)) - (21, [Input, Output]) - (22, [Input, Output]) - (23, [Input, Output] () (2 => FSPICS1)) - (24, [Input, Output] () (2 => FSPICS2)) - (25, [Input, Output] () (2 => FSPICS3)) - (26, [Input, Output] () (2 => FSPICS4)) - (27, [Input, Output] () (2 => FSPICS5)) -} - #[derive(Clone, Copy)] pub(crate) enum InterruptStatusRegisterAccess { Bank0, diff --git a/esp-hal/src/soc/esp32h2/peripherals.rs b/esp-hal/src/soc/esp32h2/peripherals.rs index 9a2606c9700..9f2c0cdb7df 100644 --- a/esp-hal/src/soc/esp32h2/peripherals.rs +++ b/esp-hal/src/soc/esp32h2/peripherals.rs @@ -20,70 +20,102 @@ pub(crate) use self::peripherals::*; // peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're // creating "virtual peripherals" for them. crate::peripherals! { - ADC1 <= virtual, - AES <= AES, - ASSIST_DEBUG <= ASSIST_DEBUG, - BT <= virtual, - DMA <= DMA (DMA_IN_CH0,DMA_IN_CH1,DMA_IN_CH2,DMA_OUT_CH0,DMA_OUT_CH1,DMA_OUT_CH2), - DS <= DS, - ECC <= ECC, - EFUSE <= EFUSE, - GPIO_SD <= GPIO_SD, - HMAC <= HMAC, - HP_APM <= HP_APM, - HP_SYS <= HP_SYS, - I2C0 <= I2C0, - I2C1 <= I2C1, - I2S0 <= I2S0 (I2S0), - IEEE802154 <= IEEE802154, - INTERRUPT_CORE0 <= INTERRUPT_CORE0, - INTPRI <= INTPRI, - IO_MUX <= IO_MUX, - LEDC <= LEDC, - LPWR <= LP_CLKRST, - LP_ANA <= LP_ANA, - LP_AON <= LP_AON, - LP_APM <= LP_APM, - LP_PERI <= LP_PERI, - LP_TIMER <= LP_TIMER, - LP_WDT <= LP_WDT, - MCPWM0 <= MCPWM0, - MEM_MONITOR <= MEM_MONITOR, - MODEM_LPCON <= MODEM_LPCON, - MODEM_SYSCON <= MODEM_SYSCON, - OTP_DEBUG <= OTP_DEBUG, - PARL_IO <= PARL_IO (PARL_IO_TX, PARL_IO_RX), - PAU <= PAU, - PCNT <= PCNT, - PMU <= PMU, - RADIO_CLK <= virtual, - RMT <= RMT, - RNG <= RNG, - RSA <= RSA, - SHA <= SHA, - SOC_ETM <= SOC_ETM, - SPI0 <= SPI0, - SPI1 <= SPI1, - SPI2 <= SPI2 (SPI2), - SYSTEM <= PCR, - SYSTIMER <= SYSTIMER, - SW_INTERRUPT <= virtual, - TEE <= TEE, - TIMG0 <= TIMG0, - TIMG1 <= TIMG1, - TRACE0 <= TRACE, - TWAI0 <= TWAI0, - UART0 <= UART0, - UART1 <= UART1, - UHCI0 <= UHCI0, - USB_DEVICE <= USB_DEVICE, - MEM2MEM1 <= virtual, - MEM2MEM4 <= virtual, - MEM2MEM5 <= virtual, - MEM2MEM10 <= virtual, - MEM2MEM11 <= virtual, - MEM2MEM12 <= virtual, - MEM2MEM13 <= virtual, - MEM2MEM14 <= virtual, - MEM2MEM15 <= virtual, + peripherals: [ + ADC1 <= virtual, + AES <= AES, + ASSIST_DEBUG <= ASSIST_DEBUG, + BT <= virtual, + DMA <= DMA (DMA_IN_CH0,DMA_IN_CH1,DMA_IN_CH2,DMA_OUT_CH0,DMA_OUT_CH1,DMA_OUT_CH2), + DS <= DS, + ECC <= ECC, + EFUSE <= EFUSE, + GPIO_SD <= GPIO_SD, + HMAC <= HMAC, + HP_APM <= HP_APM, + HP_SYS <= HP_SYS, + I2C0 <= I2C0, + I2C1 <= I2C1, + I2S0 <= I2S0 (I2S0), + IEEE802154 <= IEEE802154, + INTERRUPT_CORE0 <= INTERRUPT_CORE0, + INTPRI <= INTPRI, + IO_MUX <= IO_MUX, + LEDC <= LEDC, + LPWR <= LP_CLKRST, + LP_ANA <= LP_ANA, + LP_AON <= LP_AON, + LP_APM <= LP_APM, + LP_PERI <= LP_PERI, + LP_TIMER <= LP_TIMER, + LP_WDT <= LP_WDT, + MCPWM0 <= MCPWM0, + MEM_MONITOR <= MEM_MONITOR, + MODEM_LPCON <= MODEM_LPCON, + MODEM_SYSCON <= MODEM_SYSCON, + OTP_DEBUG <= OTP_DEBUG, + PARL_IO <= PARL_IO (PARL_IO_TX, PARL_IO_RX), + PAU <= PAU, + PCNT <= PCNT, + PMU <= PMU, + RADIO_CLK <= virtual, + RMT <= RMT, + RNG <= RNG, + RSA <= RSA, + SHA <= SHA, + SOC_ETM <= SOC_ETM, + SPI0 <= SPI0, + SPI1 <= SPI1, + SPI2 <= SPI2 (SPI2), + SYSTEM <= PCR, + SYSTIMER <= SYSTIMER, + SW_INTERRUPT <= virtual, + TEE <= TEE, + TIMG0 <= TIMG0, + TIMG1 <= TIMG1, + TRACE0 <= TRACE, + TWAI0 <= TWAI0, + UART0 <= UART0, + UART1 <= UART1, + UHCI0 <= UHCI0, + USB_DEVICE <= USB_DEVICE, + MEM2MEM1 <= virtual, + MEM2MEM4 <= virtual, + MEM2MEM5 <= virtual, + MEM2MEM10 <= virtual, + MEM2MEM11 <= virtual, + MEM2MEM12 <= virtual, + MEM2MEM13 <= virtual, + MEM2MEM14 <= virtual, + MEM2MEM15 <= virtual, + ], + pins: [ + (0, [Input, Output, Analog] (2 => FSPIQ) (2 => FSPIQ)) + (1, [Input, Output, Analog] (2 => FSPICS0) (2 => FSPICS0)) + (2, [Input, Output, Analog] (2 => FSPIWP) (2 => FSPIWP)) + (3, [Input, Output, Analog] (2 => FSPIHD) (2 => FSPIHD)) + (4, [Input, Output, Analog] (2 => FSPICLK) (2 => FSPICLK_MUX)) + (5, [Input, Output, Analog] (2 => FSPID) (2 => FSPID)) + (6, [Input, Output]) + (7, [Input, Output]) + (8, [Input, Output]) + (9, [Input, Output]) + (10, [Input, Output]) + (11, [Input, Output]) + (12, [Input, Output]) + (13, [Input, Output]) + (14, [Input, Output]) + (15, [Input, Output] () (0 => SPICS0)) + (16, [Input, Output] (0 => SPIQ) (0 => SPIQ)) + (17, [Input, Output] (0 => SPIWP) (0 => SPIWP)) + (18, [Input, Output] (0 => SPIHD) (0 => SPIHD)) + (19, [Input, Output] () (0 => SPICLK)) + (20, [Input, Output] (0 => SPID) (0 => SPID)) + (21, [Input, Output]) + (22, [Input, Output]) + (23, [Input, Output] () (2 => FSPICS1)) + (24, [Input, Output] () (2 => FSPICS2)) + (25, [Input, Output] () (2 => FSPICS3)) + (26, [Input, Output] () (2 => FSPICS4)) + (27, [Input, Output] () (2 => FSPICS5)) + ] } diff --git a/esp-hal/src/soc/esp32s2/efuse/mod.rs b/esp-hal/src/soc/esp32s2/efuse/mod.rs index 523e2d92151..99e168dbdea 100644 --- a/esp-hal/src/soc/esp32s2/efuse/mod.rs +++ b/esp-hal/src/soc/esp32s2/efuse/mod.rs @@ -27,7 +27,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.GPIO4, peripherals.GPIO5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32s2/gpio.rs b/esp-hal/src/soc/esp32s2/gpio.rs index faa6b8bcd6d..58355676851 100644 --- a/esp-hal/src/soc/esp32s2/gpio.rs +++ b/esp-hal/src/soc/esp32s2/gpio.rs @@ -415,53 +415,6 @@ macro_rules! rtcio_analog { }; } -crate::gpio! { - (0, [Input, Output, Analog, RtcIo]) - (1, [Input, Output, Analog, RtcIo]) - (2, [Input, Output, Analog, RtcIo]) - (3, [Input, Output, Analog, RtcIo]) - (4, [Input, Output, Analog, RtcIo]) - (5, [Input, Output, Analog, RtcIo]) - (6, [Input, Output, Analog, RtcIo]) - (7, [Input, Output, Analog, RtcIo]) - (8, [Input, Output, Analog, RtcIo]) - (9, [Input, Output, Analog, RtcIo]) - (10, [Input, Output, Analog, RtcIo]) - (11, [Input, Output, Analog, RtcIo]) - (12, [Input, Output, Analog, RtcIo]) - (13, [Input, Output, Analog, RtcIo]) - (14, [Input, Output, Analog, RtcIo]) - (15, [Input, Output, Analog, RtcIo]) - (16, [Input, Output, Analog, RtcIo]) - (17, [Input, Output, Analog, RtcIo]) - (18, [Input, Output, Analog, RtcIo]) - (19, [Input, Output, Analog, RtcIo]) - (20, [Input, Output, Analog, RtcIo]) - (21, [Input, Output, Analog, RtcIo]) - - (26, [Input, Output]) - (27, [Input, Output]) - (28, [Input, Output]) - (29, [Input, Output]) - (30, [Input, Output]) - (31, [Input, Output]) - (32, [Input, Output]) - (33, [Input, Output]) - (34, [Input, Output]) - (35, [Input, Output]) - (36, [Input, Output]) - (37, [Input, Output]) - (38, [Input, Output]) - (39, [Input, Output]) - (40, [Input, Output]) - (41, [Input, Output]) - (42, [Input, Output]) - (43, [Input, Output]) - (44, [Input, Output]) - (45, [Input, Output]) - (46, [Input, Output]) -} - rtcio_analog! { ( 0, touch_pad(0), "", touch_pad0_hold ) ( 1, touch_pad(1), "", touch_pad1_hold ) diff --git a/esp-hal/src/soc/esp32s2/peripherals.rs b/esp-hal/src/soc/esp32s2/peripherals.rs index fc3634e17ee..81f67a9e5f0 100644 --- a/esp-hal/src/soc/esp32s2/peripherals.rs +++ b/esp-hal/src/soc/esp32s2/peripherals.rs @@ -20,52 +20,100 @@ pub(crate) use self::peripherals::*; // peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're // creating "virtual peripherals" for them. crate::peripherals! { - ADC1 <= virtual, - ADC2 <= virtual, - AES <= AES, - DAC1 <= virtual, - DAC2 <= virtual, - DMA <= virtual, - DEDICATED_GPIO <= DEDICATED_GPIO, - DS <= DS, - EFUSE <= EFUSE, - EXTMEM <= EXTMEM, - GPIO_SD <= GPIO_SD, - HMAC <= HMAC, - I2C0 <= I2C0, - I2C1 <= I2C1, - I2S0 <= I2S0 (I2S0), - INTERRUPT_CORE0 <= INTERRUPT_CORE0, - IO_MUX <= IO_MUX, - LEDC <= LEDC, - LPWR <= RTC_CNTL, - PCNT <= PCNT, - PMS <= PMS, - PSRAM <= virtual, - RADIO_CLK <= virtual, - RMT <= RMT, - RNG <= RNG, - RSA <= RSA, - RTC_IO <= RTC_IO, - RTC_I2C <= RTC_I2C, - SHA <= SHA, - SPI0 <= SPI0, - SPI1 <= SPI1, - SPI2 <= SPI2 (SPI2_DMA, SPI2), - SPI3 <= SPI3 (SPI3_DMA, SPI3), - SYSCON <= SYSCON, - SYSTEM <= SYSTEM, - SYSTIMER <= SYSTIMER, - SW_INTERRUPT <= virtual, - TIMG0 <= TIMG0, - TIMG1 <= TIMG1, - TWAI0 <= TWAI0, - UART0 <= UART0, - UART1 <= UART1, - UHCI0 <= UHCI0, - ULP_RISCV_CORE <= virtual, - USB0 <= USB0, - USB_WRAP <= USB_WRAP, - WIFI <= virtual, - XTS_AES <= XTS_AES, + peripherals: [ + ADC1 <= virtual, + ADC2 <= virtual, + AES <= AES, + DAC1 <= virtual, + DAC2 <= virtual, + DMA <= virtual, + DEDICATED_GPIO <= DEDICATED_GPIO, + DS <= DS, + EFUSE <= EFUSE, + EXTMEM <= EXTMEM, + GPIO_SD <= GPIO_SD, + HMAC <= HMAC, + I2C0 <= I2C0, + I2C1 <= I2C1, + I2S0 <= I2S0 (I2S0), + INTERRUPT_CORE0 <= INTERRUPT_CORE0, + IO_MUX <= IO_MUX, + LEDC <= LEDC, + LPWR <= RTC_CNTL, + PCNT <= PCNT, + PMS <= PMS, + PSRAM <= virtual, + RADIO_CLK <= virtual, + RMT <= RMT, + RNG <= RNG, + RSA <= RSA, + RTC_IO <= RTC_IO, + RTC_I2C <= RTC_I2C, + SHA <= SHA, + SPI0 <= SPI0, + SPI1 <= SPI1, + SPI2 <= SPI2 (SPI2_DMA, SPI2), + SPI3 <= SPI3 (SPI3_DMA, SPI3), + SYSCON <= SYSCON, + SYSTEM <= SYSTEM, + SYSTIMER <= SYSTIMER, + SW_INTERRUPT <= virtual, + TIMG0 <= TIMG0, + TIMG1 <= TIMG1, + TWAI0 <= TWAI0, + UART0 <= UART0, + UART1 <= UART1, + UHCI0 <= UHCI0, + ULP_RISCV_CORE <= virtual, + USB0 <= USB0, + USB_WRAP <= USB_WRAP, + WIFI <= virtual, + XTS_AES <= XTS_AES, + ], + pins: [ + (0, [Input, Output, Analog, RtcIo]) + (1, [Input, Output, Analog, RtcIo]) + (2, [Input, Output, Analog, RtcIo]) + (3, [Input, Output, Analog, RtcIo]) + (4, [Input, Output, Analog, RtcIo]) + (5, [Input, Output, Analog, RtcIo]) + (6, [Input, Output, Analog, RtcIo]) + (7, [Input, Output, Analog, RtcIo]) + (8, [Input, Output, Analog, RtcIo]) + (9, [Input, Output, Analog, RtcIo]) + (10, [Input, Output, Analog, RtcIo]) + (11, [Input, Output, Analog, RtcIo]) + (12, [Input, Output, Analog, RtcIo]) + (13, [Input, Output, Analog, RtcIo]) + (14, [Input, Output, Analog, RtcIo]) + (15, [Input, Output, Analog, RtcIo]) + (16, [Input, Output, Analog, RtcIo]) + (17, [Input, Output, Analog, RtcIo]) + (18, [Input, Output, Analog, RtcIo]) + (19, [Input, Output, Analog, RtcIo]) + (20, [Input, Output, Analog, RtcIo]) + (21, [Input, Output, Analog, RtcIo]) + + (26, [Input, Output]) + (27, [Input, Output]) + (28, [Input, Output]) + (29, [Input, Output]) + (30, [Input, Output]) + (31, [Input, Output]) + (32, [Input, Output]) + (33, [Input, Output]) + (34, [Input, Output]) + (35, [Input, Output]) + (36, [Input, Output]) + (37, [Input, Output]) + (38, [Input, Output]) + (39, [Input, Output]) + (40, [Input, Output]) + (41, [Input, Output]) + (42, [Input, Output]) + (43, [Input, Output]) + (44, [Input, Output]) + (45, [Input, Output]) + (46, [Input, Output]) + ] } diff --git a/esp-hal/src/soc/esp32s3/efuse/mod.rs b/esp-hal/src/soc/esp32s3/efuse/mod.rs index 2c1ff3c9d3c..2d2257fe43d 100644 --- a/esp-hal/src/soc/esp32s3/efuse/mod.rs +++ b/esp-hal/src/soc/esp32s3/efuse/mod.rs @@ -25,7 +25,7 @@ //! # use esp_hal::uart::Uart; //! # use core::writeln; //! # use core::fmt::Write; -//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.pins.gpio4, peripherals.pins.gpio5).unwrap(); +//! # let mut serial_tx = Uart::new(peripherals.UART0, peripherals.GPIO4, peripherals.GPIO5).unwrap(); //! let mac_address = Efuse::read_base_mac_address(); //! writeln!( //! serial_tx, diff --git a/esp-hal/src/soc/esp32s3/gpio.rs b/esp-hal/src/soc/esp32s3/gpio.rs index 2822ec1cfa0..8c71a0ad109 100644 --- a/esp-hal/src/soc/esp32s3/gpio.rs +++ b/esp-hal/src/soc/esp32s3/gpio.rs @@ -447,54 +447,6 @@ macro_rules! rtcio_analog { }; } -crate::gpio! { - (0, [Input, Output, Analog, RtcIo]) - (1, [Input, Output, Analog, RtcIo]) - (2, [Input, Output, Analog, RtcIo]) - (3, [Input, Output, Analog, RtcIo]) - (4, [Input, Output, Analog, RtcIo]) - (5, [Input, Output, Analog, RtcIo]) - (6, [Input, Output, Analog, RtcIo]) - (7, [Input, Output, Analog, RtcIo]) - (8, [Input, Output, Analog, RtcIo] () (3 => SUBSPICS1)) - (9, [Input, Output, Analog, RtcIo] (3 => SUBSPIHD 4 => FSPIHD) (3 => SUBSPIHD 4 => FSPIHD)) - (10, [Input, Output, Analog, RtcIo] (2 => FSPIIO4 4 => FSPICS0) (2 => FSPIIO4 3 => SUBSPICS0 4 => FSPICS0)) - (11, [Input, Output, Analog, RtcIo] (2 => FSPIIO5 3 => SUBSPID 4 => FSPID) (2 => FSPIIO5 3 => SUBSPID 4 => FSPID)) - (12, [Input, Output, Analog, RtcIo] (2 => FSPIIO6 4 => FSPICLK) (2 => FSPIIO6 3=> SUBSPICLK 4 => FSPICLK)) - (13, [Input, Output, Analog, RtcIo] (2 => FSPIIO7 3 => SUBSPIQ 4 => FSPIQ) (2 => FSPIIO7 3 => SUBSPIQ 4 => FSPIQ)) - (14, [Input, Output, Analog, RtcIo] (3 => SUBSPIWP 4 => FSPIWP) (2 => FSPIDQS 3 => SUBSPIWP 4 => FSPIWP)) - (15, [Input, Output, Analog, RtcIo] () (2 => U0RTS)) - (16, [Input, Output, Analog, RtcIo] (2 => U0CTS) ()) - (17, [Input, Output, Analog, RtcIo] () (2 => U1TXD)) - (18, [Input, Output, Analog, RtcIo] (2 => U1RXD) ()) - (19, [Input, Output, Analog, RtcIo] () (2 => U1RTS)) - (20, [Input, Output, Analog, RtcIo] (2 => U1CTS) ()) - (21, [Input, Output, Analog, RtcIo]) - (26, [Input, Output]) - (27, [Input, Output]) - (28, [Input, Output]) - (29, [Input, Output]) - (30, [Input, Output]) - (31, [Input, Output]) - (32, [Input, Output]) - (33, [Input, Output] (2 => FSPIHD 3 => SUBSPIHD) (2 => FSPIHD 3 => SUBSPIHD)) - (34, [Input, Output] (2 => FSPICS0) (2 => FSPICS0 3 => SUBSPICS0)) - (35, [Input, Output] (2 => FSPID 3 => SUBSPID) (2 => FSPID 3 => SUBSPID)) - (36, [Input, Output] (2 => FSPICLK) (2 => FSPICLK 3 => SUBSPICLK)) - (37, [Input, Output] (2 => FSPIQ 3 => SUBSPIQ 4 => SPIDQS) (2 => FSPIQ 3=> SUBSPIQ 4 => SPIDQS)) - (38, [Input, Output] (2 => FSPIWP 3 => SUBSPIWP) (3 => FSPIWP 3 => SUBSPIWP)) - (39, [Input, Output] () (4 => SUBSPICS1)) - (40, [Input, Output]) - (41, [Input, Output]) - (42, [Input, Output]) - (43, [Input, Output]) - (44, [Input, Output]) - (45, [Input, Output]) - (46, [Input, Output]) - (47, [Input, Output]) - (48, [Input, Output]) -} - rtcio_analog! { ( 0, touch_pad(0), "", touch_pad0_hold ) ( 1, touch_pad(1), "", touch_pad1_hold ) diff --git a/esp-hal/src/soc/esp32s3/peripherals.rs b/esp-hal/src/soc/esp32s3/peripherals.rs index ce061ae487e..c6ab886c9bf 100644 --- a/esp-hal/src/soc/esp32s3/peripherals.rs +++ b/esp-hal/src/soc/esp32s3/peripherals.rs @@ -20,62 +20,111 @@ pub(crate) use self::peripherals::*; // peripheral (no `PSRAM`, `RADIO`, etc. peripheral in the PACs), so we're // creating "virtual peripherals" for them. crate::peripherals! { - ADC1 <= virtual, - ADC2 <= virtual, - AES <= AES, - APB_CTRL <= APB_CTRL, - ASSIST_DEBUG <= ASSIST_DEBUG, - BT <= virtual, - CPU_CTRL <= virtual, - DMA <= DMA (DMA_IN_CH0,DMA_IN_CH1,DMA_IN_CH2,DMA_IN_CH3,DMA_IN_CH4,DMA_OUT_CH0,DMA_OUT_CH1,DMA_OUT_CH2,DMA_OUT_CH3,DMA_OUT_CH4), - DS <= DS, - EFUSE <= EFUSE, - EXTMEM <= EXTMEM, - GPIO_SD <= GPIO_SD, - HMAC <= HMAC, - I2C0 <= I2C0, - I2C1 <= I2C1, - I2S0 <= I2S0 (I2S0), - I2S1 <= I2S1 (I2S1), - INTERRUPT_CORE0 <= INTERRUPT_CORE0, - INTERRUPT_CORE1 <= INTERRUPT_CORE1, - IO_MUX <= IO_MUX, - LCD_CAM <= LCD_CAM, - LEDC <= LEDC, - LPWR <= RTC_CNTL, - PCNT <= PCNT, - PERI_BACKUP <= PERI_BACKUP, - PSRAM <= virtual, - MCPWM0 <= MCPWM0, - MCPWM1 <= MCPWM1, - RADIO_CLK <= virtual, - RMT <= RMT, - RNG <= RNG, - RSA <= RSA, - RTC_I2C <= RTC_I2C, - RTC_IO <= RTC_IO, - SENSITIVE <= SENSITIVE, - SHA <= SHA, - SPI0 <= SPI0, - SPI1 <= SPI1, - SPI2 <= SPI2 (SPI2), - SPI3 <= SPI3 (SPI3), - SYSTEM <= SYSTEM, - SYSTIMER <= SYSTIMER, - SW_INTERRUPT <= virtual, - TIMG0 <= TIMG0, - TIMG1 <= TIMG1, - TWAI0 <= TWAI0, - UART0 <= UART0, - UART1 <= UART1, - UART2 <= UART2, - UHCI0 <= UHCI0, - UHCI1 <= UHCI1, - ULP_RISCV_CORE <= virtual, - USB0 <= USB0, - USB_DEVICE <= USB_DEVICE, - USB_WRAP <= USB_WRAP, - WCL <= WCL, - WIFI <= virtual, - XTS_AES <= XTS_AES, + peripherals: [ + ADC1 <= virtual, + ADC2 <= virtual, + AES <= AES, + APB_CTRL <= APB_CTRL, + ASSIST_DEBUG <= ASSIST_DEBUG, + BT <= virtual, + CPU_CTRL <= virtual, + DMA <= DMA (DMA_IN_CH0,DMA_IN_CH1,DMA_IN_CH2,DMA_IN_CH3,DMA_IN_CH4,DMA_OUT_CH0,DMA_OUT_CH1,DMA_OUT_CH2,DMA_OUT_CH3,DMA_OUT_CH4), + DS <= DS, + EFUSE <= EFUSE, + EXTMEM <= EXTMEM, + GPIO_SD <= GPIO_SD, + HMAC <= HMAC, + I2C0 <= I2C0, + I2C1 <= I2C1, + I2S0 <= I2S0 (I2S0), + I2S1 <= I2S1 (I2S1), + INTERRUPT_CORE0 <= INTERRUPT_CORE0, + INTERRUPT_CORE1 <= INTERRUPT_CORE1, + IO_MUX <= IO_MUX, + LCD_CAM <= LCD_CAM, + LEDC <= LEDC, + LPWR <= RTC_CNTL, + PCNT <= PCNT, + PERI_BACKUP <= PERI_BACKUP, + PSRAM <= virtual, + MCPWM0 <= MCPWM0, + MCPWM1 <= MCPWM1, + RADIO_CLK <= virtual, + RMT <= RMT, + RNG <= RNG, + RSA <= RSA, + RTC_I2C <= RTC_I2C, + RTC_IO <= RTC_IO, + SENSITIVE <= SENSITIVE, + SHA <= SHA, + SPI0 <= SPI0, + SPI1 <= SPI1, + SPI2 <= SPI2 (SPI2), + SPI3 <= SPI3 (SPI3), + SYSTEM <= SYSTEM, + SYSTIMER <= SYSTIMER, + SW_INTERRUPT <= virtual, + TIMG0 <= TIMG0, + TIMG1 <= TIMG1, + TWAI0 <= TWAI0, + UART0 <= UART0, + UART1 <= UART1, + UART2 <= UART2, + UHCI0 <= UHCI0, + UHCI1 <= UHCI1, + ULP_RISCV_CORE <= virtual, + USB0 <= USB0, + USB_DEVICE <= USB_DEVICE, + USB_WRAP <= USB_WRAP, + WCL <= WCL, + WIFI <= virtual, + XTS_AES <= XTS_AES, + ], + pins: [ + (0, [Input, Output, Analog, RtcIo]) + (1, [Input, Output, Analog, RtcIo]) + (2, [Input, Output, Analog, RtcIo]) + (3, [Input, Output, Analog, RtcIo]) + (4, [Input, Output, Analog, RtcIo]) + (5, [Input, Output, Analog, RtcIo]) + (6, [Input, Output, Analog, RtcIo]) + (7, [Input, Output, Analog, RtcIo]) + (8, [Input, Output, Analog, RtcIo] () (3 => SUBSPICS1)) + (9, [Input, Output, Analog, RtcIo] (3 => SUBSPIHD 4 => FSPIHD) (3 => SUBSPIHD 4 => FSPIHD)) + (10, [Input, Output, Analog, RtcIo] (2 => FSPIIO4 4 => FSPICS0) (2 => FSPIIO4 3 => SUBSPICS0 4 => FSPICS0)) + (11, [Input, Output, Analog, RtcIo] (2 => FSPIIO5 3 => SUBSPID 4 => FSPID) (2 => FSPIIO5 3 => SUBSPID 4 => FSPID)) + (12, [Input, Output, Analog, RtcIo] (2 => FSPIIO6 4 => FSPICLK) (2 => FSPIIO6 3=> SUBSPICLK 4 => FSPICLK)) + (13, [Input, Output, Analog, RtcIo] (2 => FSPIIO7 3 => SUBSPIQ 4 => FSPIQ) (2 => FSPIIO7 3 => SUBSPIQ 4 => FSPIQ)) + (14, [Input, Output, Analog, RtcIo] (3 => SUBSPIWP 4 => FSPIWP) (2 => FSPIDQS 3 => SUBSPIWP 4 => FSPIWP)) + (15, [Input, Output, Analog, RtcIo] () (2 => U0RTS)) + (16, [Input, Output, Analog, RtcIo] (2 => U0CTS) ()) + (17, [Input, Output, Analog, RtcIo] () (2 => U1TXD)) + (18, [Input, Output, Analog, RtcIo] (2 => U1RXD) ()) + (19, [Input, Output, Analog, RtcIo] () (2 => U1RTS)) + (20, [Input, Output, Analog, RtcIo] (2 => U1CTS) ()) + (21, [Input, Output, Analog, RtcIo]) + (26, [Input, Output]) + (27, [Input, Output]) + (28, [Input, Output]) + (29, [Input, Output]) + (30, [Input, Output]) + (31, [Input, Output]) + (32, [Input, Output]) + (33, [Input, Output] (2 => FSPIHD 3 => SUBSPIHD) (2 => FSPIHD 3 => SUBSPIHD)) + (34, [Input, Output] (2 => FSPICS0) (2 => FSPICS0 3 => SUBSPICS0)) + (35, [Input, Output] (2 => FSPID 3 => SUBSPID) (2 => FSPID 3 => SUBSPID)) + (36, [Input, Output] (2 => FSPICLK) (2 => FSPICLK 3 => SUBSPICLK)) + (37, [Input, Output] (2 => FSPIQ 3 => SUBSPIQ 4 => SPIDQS) (2 => FSPIQ 3=> SUBSPIQ 4 => SPIDQS)) + (38, [Input, Output] (2 => FSPIWP 3 => SUBSPIWP) (3 => FSPIWP 3 => SUBSPIWP)) + (39, [Input, Output] () (4 => SUBSPICS1)) + (40, [Input, Output]) + (41, [Input, Output]) + (42, [Input, Output]) + (43, [Input, Output]) + (44, [Input, Output]) + (45, [Input, Output]) + (46, [Input, Output]) + (47, [Input, Output]) + (48, [Input, Output]) + ] } diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 3987bb3a749..1430a5269c3 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -40,10 +40,10 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::spi::SpiMode; //! # use esp_hal::spi::master::{Config, Spi}; -//! let sclk = peripherals.pins.gpio0; -//! let miso = peripherals.pins.gpio2; -//! let mosi = peripherals.pins.gpio1; -//! let cs = peripherals.pins.gpio5; +//! let sclk = peripherals.GPIO0; +//! let miso = peripherals.GPIO2; +//! let mosi = peripherals.GPIO1; +//! let cs = peripherals.GPIO5; //! //! let mut spi = Spi::new_with_config( //! peripherals.SPI2, diff --git a/esp-hal/src/spi/slave.rs b/esp-hal/src/spi/slave.rs index a443ebf911a..0ffd707d1eb 100644 --- a/esp-hal/src/spi/slave.rs +++ b/esp-hal/src/spi/slave.rs @@ -23,10 +23,10 @@ //! let dma = Dma::new(peripherals.DMA); #![cfg_attr(pdma, doc = "let dma_channel = dma.spi2channel;")] #![cfg_attr(gdma, doc = "let dma_channel = dma.channel0;")] -//! let sclk = peripherals.pins.gpio0; -//! let miso = peripherals.pins.gpio1; -//! let mosi = peripherals.pins.gpio2; -//! let cs = peripherals.pins.gpio3; +//! let sclk = peripherals.GPIO0; +//! let miso = peripherals.GPIO1; +//! let mosi = peripherals.GPIO2; +//! let cs = peripherals.GPIO3; //! //! let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = //! dma_buffers!(32000); diff --git a/esp-hal/src/touch.rs b/esp-hal/src/touch.rs index d56e5d80825..66e8dc1c742 100644 --- a/esp-hal/src/touch.rs +++ b/esp-hal/src/touch.rs @@ -10,7 +10,7 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::touch::{Touch, TouchPad}; -//! let touch_pin0 = peripherals.pins.gpio2; +//! let touch_pin0 = peripherals.GPIO2; //! let touch = Touch::continuous_mode(peripherals.TOUCH, None); //! let mut touchpad = TouchPad::new(touch_pin0, &touch); //! // ... give the peripheral some time for the measurement diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs index 3686dceeaa8..cfbb1f7ead0 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -36,8 +36,8 @@ //! # use nb::block; //! // Use GPIO pins 2 and 3 to connect to the respective pins on the TWAI //! // transceiver. -//! let can_rx_pin = peripherals.pins.gpio3; -//! let can_tx_pin = peripherals.pins.gpio2; +//! let can_rx_pin = peripherals.GPIO3; +//! let can_tx_pin = peripherals.GPIO2; //! //! // The speed of the TWAI bus. //! const TWAI_BAUDRATE: twai::BaudRate = BaudRate::B1000K; @@ -88,8 +88,8 @@ //! # use nb::block; //! // Use GPIO pins 2 and 3 to connect to the respective pins on the TWAI //! // transceiver. -//! let can_rx_pin = peripherals.pins.gpio3; -//! let can_tx_pin = peripherals.pins.gpio2; +//! let can_rx_pin = peripherals.GPIO3; +//! let can_tx_pin = peripherals.GPIO2; //! //! // The speed of the TWAI bus. //! const TWAI_BAUDRATE: twai::BaudRate = BaudRate::B1000K; diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index 7ab5783e5f9..b67f6b97427 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -26,8 +26,8 @@ //! //! let mut uart1 = Uart::new( //! peripherals.UART1, -//! peripherals.pins.gpio1, -//! peripherals.pins.gpio2, +//! peripherals.GPIO1, +//! peripherals.GPIO2, //! ).unwrap(); //! # } //! ``` @@ -56,8 +56,8 @@ //! # let mut uart1 = Uart::new_with_config( //! # peripherals.UART1, //! # Config::default(), -//! # peripherals.pins.gpio1, -//! # peripherals.pins.gpio2, +//! # peripherals.GPIO1, +//! # peripherals.GPIO2, //! # ).unwrap(); //! // Write bytes out over the UART: //! uart1.write_bytes(b"Hello, world!").expect("write error!"); @@ -71,8 +71,8 @@ //! # let mut uart1 = Uart::new_with_config( //! # peripherals.UART1, //! # Config::default(), -//! # peripherals.pins.gpio1, -//! # peripherals.pins.gpio2, +//! # peripherals.GPIO1, +//! # peripherals.GPIO2, //! # ).unwrap(); //! // The UART can be split into separate Transmit and Receive components: //! let (mut rx, mut tx) = uart1.split(); @@ -88,8 +88,8 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::uart::Uart; //! -//! let (rx, _) = peripherals.pins.gpio2.split(); -//! let (_, tx) = peripherals.pins.gpio1.split(); +//! let (rx, _) = peripherals.GPIO2.split(); +//! let (_, tx) = peripherals.GPIO1.split(); //! let mut uart1 = Uart::new( //! peripherals.UART1, //! rx.inverted(), @@ -103,8 +103,8 @@ #![doc = crate::before_snippet!()] //! # use esp_hal::uart::{UartTx, UartRx}; //! -//! let tx = UartTx::new(peripherals.UART0, peripherals.pins.gpio1).unwrap(); -//! let rx = UartRx::new(peripherals.UART1, peripherals.pins.gpio2).unwrap(); +//! let tx = UartTx::new(peripherals.UART0, peripherals.GPIO1).unwrap(); +//! let rx = UartRx::new(peripherals.UART1, peripherals.GPIO2).unwrap(); //! # } //! ``` //! diff --git a/examples/src/bin/adc.rs b/examples/src/bin/adc.rs index 83e6a3e01cc..e4c8eb2b423 100644 --- a/examples/src/bin/adc.rs +++ b/examples/src/bin/adc.rs @@ -30,11 +30,11 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let analog_pin = peripherals.pins.gpio32; + let analog_pin = peripherals.GPIO32; } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let analog_pin = peripherals.pins.gpio3; + let analog_pin = peripherals.GPIO3; } else { - let analog_pin = peripherals.pins.gpio2; + let analog_pin = peripherals.GPIO2; } } diff --git a/examples/src/bin/adc_cal.rs b/examples/src/bin/adc_cal.rs index 2a7a7662963..e7d6ceb859d 100644 --- a/examples/src/bin/adc_cal.rs +++ b/examples/src/bin/adc_cal.rs @@ -26,9 +26,9 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(feature = "esp32s3")] { - let analog_pin = peripherals.pins.gpio3; + let analog_pin = peripherals.GPIO3; } else { - let analog_pin = peripherals.pins.gpio2; + let analog_pin = peripherals.GPIO2; } } diff --git a/examples/src/bin/advanced_serial.rs b/examples/src/bin/advanced_serial.rs index 475cc2646c2..6012abc4abc 100644 --- a/examples/src/bin/advanced_serial.rs +++ b/examples/src/bin/advanced_serial.rs @@ -21,12 +21,7 @@ use nb::block; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let mut serial1 = Uart::new( - peripherals.UART1, - peripherals.pins.gpio4, - peripherals.pins.gpio5, - ) - .unwrap(); + let mut serial1 = Uart::new(peripherals.UART1, peripherals.GPIO4, peripherals.GPIO5).unwrap(); let delay = Delay::new(); diff --git a/examples/src/bin/blinky.rs b/examples/src/bin/blinky.rs index 0f48cb83954..f804dda603f 100644 --- a/examples/src/bin/blinky.rs +++ b/examples/src/bin/blinky.rs @@ -21,7 +21,7 @@ fn main() -> ! { // Set GPIO0 as an output, and set its state high initially. - let mut led = Output::new(peripherals.pins.gpio0, Level::High); + let mut led = Output::new(peripherals.GPIO0, Level::High); let delay = Delay::new(); diff --git a/examples/src/bin/blinky_erased_pins.rs b/examples/src/bin/blinky_erased_pins.rs index c3456bbbeb7..140e728e1aa 100644 --- a/examples/src/bin/blinky_erased_pins.rs +++ b/examples/src/bin/blinky_erased_pins.rs @@ -23,15 +23,15 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); // Set LED GPIOs as an output: - let led1 = Output::new(peripherals.pins.gpio2.degrade(), Level::Low); - let led2 = Output::new(peripherals.pins.gpio4.degrade(), Level::Low); - let led3 = Output::new(peripherals.pins.gpio5.degrade(), Level::Low); + let led1 = Output::new(peripherals.GPIO2.degrade(), Level::Low); + let led2 = Output::new(peripherals.GPIO4.degrade(), Level::Low); + let led3 = Output::new(peripherals.GPIO5.degrade(), Level::Low); // Use boot button as an input: #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] - let button = peripherals.pins.gpio0.degrade(); + let button = peripherals.GPIO0.degrade(); #[cfg(not(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3")))] - let button = peripherals.pins.gpio9.degrade(); + let button = peripherals.GPIO9.degrade(); let button = Input::new(button, Pull::Up); diff --git a/examples/src/bin/dac.rs b/examples/src/bin/dac.rs index 903e8f6f30e..4bd42b29860 100644 --- a/examples/src/bin/dac.rs +++ b/examples/src/bin/dac.rs @@ -27,11 +27,11 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let dac1_pin = peripherals.pins.gpio25; - let dac2_pin = peripherals.pins.gpio26; + let dac1_pin = peripherals.GPIO25; + let dac2_pin = peripherals.GPIO26; } else if #[cfg(feature = "esp32s2")] { - let dac1_pin = peripherals.pins.gpio17; - let dac2_pin = peripherals.pins.gpio18; + let dac1_pin = peripherals.GPIO17; + let dac2_pin = peripherals.GPIO18; } } diff --git a/examples/src/bin/embassy_i2c.rs b/examples/src/bin/embassy_i2c.rs index 6e1397fc20b..2b7f467ee53 100644 --- a/examples/src/bin/embassy_i2c.rs +++ b/examples/src/bin/embassy_i2c.rs @@ -38,8 +38,8 @@ async fn main(_spawner: Spawner) { config.frequency = 400.kHz(); config }) - .with_sda(peripherals.pins.gpio4) - .with_scl(peripherals.pins.gpio5) + .with_sda(peripherals.GPIO4) + .with_scl(peripherals.GPIO5) .into_async(); let mut lis3dh = Lis3dh::new_i2c(i2c0, SlaveAddr::Alternate).await.unwrap(); diff --git a/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs b/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs index d3c9ddfc5ba..1f7ff1525af 100644 --- a/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs +++ b/examples/src/bin/embassy_i2c_bmp180_calibration_data.rs @@ -38,8 +38,8 @@ async fn main(_spawner: Spawner) { config.frequency = 400.kHz(); config }) - .with_sda(peripherals.pins.gpio4) - .with_scl(peripherals.pins.gpio5) + .with_sda(peripherals.GPIO4) + .with_scl(peripherals.GPIO5) .into_async(); loop { diff --git a/examples/src/bin/embassy_i2s_parallel.rs b/examples/src/bin/embassy_i2s_parallel.rs index f88b69c1d8b..927b95ded17 100644 --- a/examples/src/bin/embassy_i2s_parallel.rs +++ b/examples/src/bin/embassy_i2s_parallel.rs @@ -42,17 +42,17 @@ async fn main(_spawner: Spawner) { let dma_channel = dma.i2s1channel; let i2s = peripherals.I2S1; - let clock = peripherals.pins.gpio25; + let clock = peripherals.GPIO25; let pins = TxEightBits::new( - peripherals.pins.gpio16, - peripherals.pins.gpio4, - peripherals.pins.gpio17, - peripherals.pins.gpio18, - peripherals.pins.gpio5, - peripherals.pins.gpio19, - peripherals.pins.gpio12, - peripherals.pins.gpio14, + peripherals.GPIO16, + peripherals.GPIO4, + peripherals.GPIO17, + peripherals.GPIO18, + peripherals.GPIO5, + peripherals.GPIO19, + peripherals.GPIO12, + peripherals.GPIO14, ); let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, BUFFER_SIZE); diff --git a/examples/src/bin/embassy_i2s_read.rs b/examples/src/bin/embassy_i2s_read.rs index ae6a8e79233..612ee4ad9f5 100644 --- a/examples/src/bin/embassy_i2s_read.rs +++ b/examples/src/bin/embassy_i2s_read.rs @@ -56,13 +56,13 @@ async fn main(_spawner: Spawner) { .into_async(); #[cfg(not(feature = "esp32"))] - let i2s = i2s.with_mclk(peripherals.pins.gpio0); + let i2s = i2s.with_mclk(peripherals.GPIO0); let i2s_rx = i2s .i2s_rx - .with_bclk(peripherals.pins.gpio2) - .with_ws(peripherals.pins.gpio4) - .with_din(peripherals.pins.gpio5) + .with_bclk(peripherals.GPIO2) + .with_ws(peripherals.GPIO4) + .with_din(peripherals.GPIO5) .build(); let buffer = rx_buffer; diff --git a/examples/src/bin/embassy_i2s_sound.rs b/examples/src/bin/embassy_i2s_sound.rs index 4298c8b1ea9..fd06eff7a00 100644 --- a/examples/src/bin/embassy_i2s_sound.rs +++ b/examples/src/bin/embassy_i2s_sound.rs @@ -79,9 +79,9 @@ async fn main(_spawner: Spawner) { let i2s_tx = i2s .i2s_tx - .with_bclk(peripherals.pins.gpio2) - .with_ws(peripherals.pins.gpio4) - .with_dout(peripherals.pins.gpio5) + .with_bclk(peripherals.GPIO2) + .with_ws(peripherals.GPIO4) + .with_dout(peripherals.GPIO5) .build(); let data = diff --git a/examples/src/bin/embassy_multicore.rs b/examples/src/bin/embassy_multicore.rs index 0dddeed44ca..6def339d64d 100644 --- a/examples/src/bin/embassy_multicore.rs +++ b/examples/src/bin/embassy_multicore.rs @@ -63,7 +63,7 @@ async fn main(_spawner: Spawner) { static LED_CTRL: StaticCell> = StaticCell::new(); let led_ctrl_signal = &*LED_CTRL.init(Signal::new()); - let led = Output::new(peripherals.pins.gpio0, Level::Low); + let led = Output::new(peripherals.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 f87fb08fd7b..7a1de606c95 100644 --- a/examples/src/bin/embassy_multicore_interrupt.rs +++ b/examples/src/bin/embassy_multicore_interrupt.rs @@ -85,7 +85,7 @@ fn main() -> ! { static LED_CTRL: StaticCell> = StaticCell::new(); let led_ctrl_signal = &*LED_CTRL.init(Signal::new()); - let led = Output::new(peripherals.pins.gpio0, Level::Low); + let led = Output::new(peripherals.GPIO0, Level::Low); static EXECUTOR_CORE_1: StaticCell> = StaticCell::new(); let executor_core1 = InterruptExecutor::new(sw_ints.software_interrupt1); diff --git a/examples/src/bin/embassy_parl_io_rx.rs b/examples/src/bin/embassy_parl_io_rx.rs index aa896ad2d49..9b589992dc0 100644 --- a/examples/src/bin/embassy_parl_io_rx.rs +++ b/examples/src/bin/embassy_parl_io_rx.rs @@ -36,10 +36,10 @@ async fn main(_spawner: Spawner) { let dma_channel = dma.channel0; let mut rx_pins = RxFourBits::new( - peripherals.pins.gpio1, - peripherals.pins.gpio2, - peripherals.pins.gpio3, - peripherals.pins.gpio4, + peripherals.GPIO1, + peripherals.GPIO2, + peripherals.GPIO3, + peripherals.GPIO4, ); let parl_io = ParlIoRxOnly::new( diff --git a/examples/src/bin/embassy_parl_io_tx.rs b/examples/src/bin/embassy_parl_io_tx.rs index d538af55ec0..44302552bde 100644 --- a/examples/src/bin/embassy_parl_io_tx.rs +++ b/examples/src/bin/embassy_parl_io_tx.rs @@ -47,13 +47,13 @@ async fn main(_spawner: Spawner) { let dma_channel = dma.channel0; let tx_pins = TxFourBits::new( - peripherals.pins.gpio1, - peripherals.pins.gpio2, - peripherals.pins.gpio3, - peripherals.pins.gpio4, + peripherals.GPIO1, + peripherals.GPIO2, + peripherals.GPIO3, + peripherals.GPIO4, ); - let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, peripherals.pins.gpio5); + let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, peripherals.GPIO5); let parl_io = ParlIoTxOnly::new( peripherals.PARL_IO, @@ -65,7 +65,7 @@ async fn main(_spawner: Spawner) { ) .unwrap(); - let mut clock_pin = ClkOutPin::new(peripherals.pins.gpio8); + let mut clock_pin = ClkOutPin::new(peripherals.GPIO8); let mut parl_io_tx = parl_io .tx diff --git a/examples/src/bin/embassy_rmt_rx.rs b/examples/src/bin/embassy_rmt_rx.rs index d42f73d047a..08c5f8bc28d 100644 --- a/examples/src/bin/embassy_rmt_rx.rs +++ b/examples/src/bin/embassy_rmt_rx.rs @@ -61,16 +61,16 @@ async fn main(spawner: Spawner) { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2"))] { - let mut channel = rmt.channel0.configure(peripherals.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel0.configure(peripherals.GPIO4, rx_config).unwrap(); } else if #[cfg(feature = "esp32s3")] { - let mut channel = rmt.channel7.configure(peripherals.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel7.configure(peripherals.GPIO4, rx_config).unwrap(); } else { - let mut channel = rmt.channel2.configure(peripherals.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel2.configure(peripherals.GPIO4, rx_config).unwrap(); } } spawner - .spawn(signal_task(Output::new(peripherals.pins.gpio5, Level::Low))) + .spawn(signal_task(Output::new(peripherals.GPIO5, Level::Low))) .unwrap(); let mut data = [PulseCode { diff --git a/examples/src/bin/embassy_rmt_tx.rs b/examples/src/bin/embassy_rmt_tx.rs index 9d1000494ab..5943c453700 100644 --- a/examples/src/bin/embassy_rmt_tx.rs +++ b/examples/src/bin/embassy_rmt_tx.rs @@ -42,7 +42,7 @@ async fn main(_spawner: Spawner) { let mut channel = rmt .channel0 .configure( - peripherals.pins.gpio4, + peripherals.GPIO4, TxChannelConfig { clk_divider: 255, ..TxChannelConfig::default() diff --git a/examples/src/bin/embassy_serial.rs b/examples/src/bin/embassy_serial.rs index a89ddef1372..643bac9285c 100644 --- a/examples/src/bin/embassy_serial.rs +++ b/examples/src/bin/embassy_serial.rs @@ -73,17 +73,17 @@ async fn main(spawner: Spawner) { // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio1, peripherals.pins.gpio3); + let (tx_pin, rx_pin) = (peripherals.GPIO1, peripherals.GPIO3); } else if #[cfg(feature = "esp32c2")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio20, peripherals.pins.gpio19); + let (tx_pin, rx_pin) = (peripherals.GPIO20, peripherals.GPIO19); } else if #[cfg(feature = "esp32c3")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio21, peripherals.pins.gpio20); + let (tx_pin, rx_pin) = (peripherals.GPIO21, peripherals.GPIO20); } else if #[cfg(feature = "esp32c6")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); + let (tx_pin, rx_pin) = (peripherals.GPIO16, peripherals.GPIO17); } else if #[cfg(feature = "esp32h2")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); + let (tx_pin, rx_pin) = (peripherals.GPIO24, peripherals.GPIO23); } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio43, peripherals.pins.gpio44); + let (tx_pin, rx_pin) = (peripherals.GPIO43, peripherals.GPIO44); } } diff --git a/examples/src/bin/embassy_spi.rs b/examples/src/bin/embassy_spi.rs index fd2a7e6de7e..82a7813f884 100644 --- a/examples/src/bin/embassy_spi.rs +++ b/examples/src/bin/embassy_spi.rs @@ -40,10 +40,10 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let sclk = peripherals.pins.gpio0; - let miso = peripherals.pins.gpio2; - let mosi = peripherals.pins.gpio4; - let cs = peripherals.pins.gpio5; + let sclk = peripherals.GPIO0; + let miso = peripherals.GPIO2; + let mosi = peripherals.GPIO4; + let cs = peripherals.GPIO5; let dma = Dma::new(peripherals.DMA); diff --git a/examples/src/bin/embassy_touch.rs b/examples/src/bin/embassy_touch.rs index 643f6684e00..2849d178343 100644 --- a/examples/src/bin/embassy_touch.rs +++ b/examples/src/bin/embassy_touch.rs @@ -33,8 +33,8 @@ async fn main(_spawner: Spawner) { let mut rtc = Rtc::new(peripherals.LPWR); - let touch_pin0 = peripherals.pins.gpio2; - let touch_pin1 = peripherals.pins.gpio4; + let touch_pin0 = peripherals.GPIO2; + let touch_pin1 = peripherals.GPIO4; let touch_cfg = Some(TouchConfig { measurement_duration: Some(0x2000), diff --git a/examples/src/bin/embassy_twai.rs b/examples/src/bin/embassy_twai.rs index ad672cc2d48..d788c75301f 100644 --- a/examples/src/bin/embassy_twai.rs +++ b/examples/src/bin/embassy_twai.rs @@ -92,10 +92,10 @@ async fn main(spawner: Spawner) { esp_hal_embassy::init(timg0.timer0); // Without an external transceiver, we only need a single line between the two MCUs. - let (rx_pin, tx_pin) = peripherals.pins.gpio2.split(); + let (rx_pin, tx_pin) = peripherals.GPIO2.split(); // Use these if you want to use an external transceiver: - // let tx_pin = peripherals.pins.gpio2; - // let rx_pin = peripherals.pins.gpio0; + // let tx_pin = peripherals.GPIO2; + // let rx_pin = peripherals.GPIO0; // The speed of the bus. const TWAI_BAUDRATE: twai::BaudRate = twai::BaudRate::B125K; diff --git a/examples/src/bin/embassy_usb_serial.rs b/examples/src/bin/embassy_usb_serial.rs index 65601da8b9c..207ae1132a1 100644 --- a/examples/src/bin/embassy_usb_serial.rs +++ b/examples/src/bin/embassy_usb_serial.rs @@ -36,11 +36,7 @@ async fn main(_spawner: Spawner) { let timg0 = TimerGroup::new(peripherals.TIMG0); esp_hal_embassy::init(timg0.timer0); - let usb = Usb::new( - peripherals.USB0, - peripherals.pins.gpio20, - peripherals.pins.gpio19, - ); + let usb = Usb::new(peripherals.USB0, peripherals.GPIO20, peripherals.GPIO19); // Create the driver, from the HAL. let mut ep_out_buffer = [0u8; 1024]; diff --git a/examples/src/bin/embassy_wait.rs b/examples/src/bin/embassy_wait.rs index fa9a67dccde..b78a85ff3c4 100644 --- a/examples/src/bin/embassy_wait.rs +++ b/examples/src/bin/embassy_wait.rs @@ -26,9 +26,9 @@ async fn main(_spawner: Spawner) { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let mut input = Input::new(peripherals.pins.gpio0, Pull::Down); + let mut input = Input::new(peripherals.GPIO0, Pull::Down); } else { - let mut input = Input::new(peripherals.pins.gpio9, Pull::Down); + let mut input = Input::new(peripherals.GPIO9, Pull::Down); } } diff --git a/examples/src/bin/etm_blinky_systimer.rs b/examples/src/bin/etm_blinky_systimer.rs index 35a30566522..1cdb361e2ef 100644 --- a/examples/src/bin/etm_blinky_systimer.rs +++ b/examples/src/bin/etm_blinky_systimer.rs @@ -30,7 +30,7 @@ fn main() -> ! { let mut alarm0 = syst_alarms.alarm0; alarm0.set_period(1u32.secs()); - let mut led = peripherals.pins.gpio1; + let mut led = peripherals.GPIO1; // setup ETM let gpio_ext = Channels::new(peripherals.GPIO_SD); diff --git a/examples/src/bin/etm_gpio.rs b/examples/src/bin/etm_gpio.rs index cf5d5a9d2e0..d28b1bc3683 100644 --- a/examples/src/bin/etm_gpio.rs +++ b/examples/src/bin/etm_gpio.rs @@ -24,8 +24,8 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let mut led = Output::new(peripherals.pins.gpio1, Level::Low); - let button = peripherals.pins.gpio9; + let mut led = Output::new(peripherals.GPIO1, Level::Low); + let button = peripherals.GPIO9; led.set_high(); diff --git a/examples/src/bin/gpio_interrupt.rs b/examples/src/bin/gpio_interrupt.rs index 33a66ae21b1..befe9d6dc84 100644 --- a/examples/src/bin/gpio_interrupt.rs +++ b/examples/src/bin/gpio_interrupt.rs @@ -32,13 +32,13 @@ fn main() -> ! { // Set GPIO2 as an output, and set its state high initially. let mut io = Io::new(peripherals.IO_MUX); io.set_interrupt_handler(handler); - let mut led = Output::new(peripherals.pins.gpio2, Level::Low); + let mut led = Output::new(peripherals.GPIO2, Level::Low); cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let button = peripherals.pins.gpio0; + let button = peripherals.GPIO0; } else { - let button = peripherals.pins.gpio9; + let button = peripherals.GPIO9; } } diff --git a/examples/src/bin/hello_world.rs b/examples/src/bin/hello_world.rs index 4e97c5d5353..a90ebb234c2 100644 --- a/examples/src/bin/hello_world.rs +++ b/examples/src/bin/hello_world.rs @@ -26,17 +26,17 @@ fn main() -> ! { // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio1, peripherals.pins.gpio3); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO1, peripherals.GPIO3); } else if #[cfg(feature = "esp32c2")] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio20, peripherals.pins.gpio19); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO20, peripherals.GPIO19); } else if #[cfg(feature = "esp32c3")] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio21, peripherals.pins.gpio20); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO21, peripherals.GPIO20); } else if #[cfg(feature = "esp32c6")] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO16, peripherals.GPIO17); } else if #[cfg(feature = "esp32h2")] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO24, peripherals.GPIO23); } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio43, peripherals.pins.gpio44); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO43, peripherals.GPIO44); } } diff --git a/examples/src/bin/i2c_bmp180_calibration_data.rs b/examples/src/bin/i2c_bmp180_calibration_data.rs index b84536e7275..2d765fc31c2 100644 --- a/examples/src/bin/i2c_bmp180_calibration_data.rs +++ b/examples/src/bin/i2c_bmp180_calibration_data.rs @@ -25,8 +25,8 @@ fn main() -> ! { // Create a new peripheral object with the described wiring and standard // I2C clock speed: let mut i2c = I2c::new(peripherals.I2C0, Config::default()) - .with_sda(peripherals.pins.gpio4) - .with_scl(peripherals.pins.gpio5); + .with_sda(peripherals.GPIO4) + .with_scl(peripherals.GPIO5); loop { let mut data = [0u8; 22]; diff --git a/examples/src/bin/i2c_display.rs b/examples/src/bin/i2c_display.rs index 401c31b9378..c950def05fb 100644 --- a/examples/src/bin/i2c_display.rs +++ b/examples/src/bin/i2c_display.rs @@ -38,8 +38,8 @@ fn main() -> ! { // Create a new peripheral object with the described wiring // and standard I2C clock speed let i2c = I2c::new(peripherals.I2C0, Config::default()) - .with_sda(peripherals.pins.gpio4) - .with_scl(peripherals.pins.gpio5); + .with_sda(peripherals.GPIO4) + .with_scl(peripherals.GPIO5); // Initialize display let interface = I2CDisplayInterface::new(i2c); diff --git a/examples/src/bin/i2s_parallel.rs b/examples/src/bin/i2s_parallel.rs index fcfe88e9135..5f1bd400a3f 100644 --- a/examples/src/bin/i2s_parallel.rs +++ b/examples/src/bin/i2s_parallel.rs @@ -36,17 +36,17 @@ fn main() -> ! { let dma_channel = dma.i2s1channel; let i2s = peripherals.I2S1; - let clock = peripherals.pins.gpio25; + let clock = peripherals.GPIO25; let pins = TxEightBits::new( - peripherals.pins.gpio16, - peripherals.pins.gpio4, - peripherals.pins.gpio17, - peripherals.pins.gpio18, - peripherals.pins.gpio5, - peripherals.pins.gpio19, - peripherals.pins.gpio12, - peripherals.pins.gpio14, + peripherals.GPIO16, + peripherals.GPIO4, + peripherals.GPIO17, + peripherals.GPIO18, + peripherals.GPIO5, + peripherals.GPIO19, + peripherals.GPIO12, + peripherals.GPIO14, ); let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, BUFFER_SIZE); diff --git a/examples/src/bin/i2s_read.rs b/examples/src/bin/i2s_read.rs index e9f1e3c7bdb..6697053cedb 100644 --- a/examples/src/bin/i2s_read.rs +++ b/examples/src/bin/i2s_read.rs @@ -52,13 +52,13 @@ fn main() -> ! { ); #[cfg(not(feature = "esp32"))] - let i2s = i2s.with_mclk(peripherals.pins.gpio0); + let i2s = i2s.with_mclk(peripherals.GPIO0); let mut i2s_rx = i2s .i2s_rx - .with_bclk(peripherals.pins.gpio2) - .with_ws(peripherals.pins.gpio4) - .with_din(peripherals.pins.gpio5) + .with_bclk(peripherals.GPIO2) + .with_ws(peripherals.GPIO4) + .with_din(peripherals.GPIO5) .build(); let mut transfer = i2s_rx.read_dma_circular(&mut rx_buffer).unwrap(); diff --git a/examples/src/bin/i2s_sound.rs b/examples/src/bin/i2s_sound.rs index 3d763490a04..de24c709b18 100644 --- a/examples/src/bin/i2s_sound.rs +++ b/examples/src/bin/i2s_sound.rs @@ -70,9 +70,9 @@ fn main() -> ! { let mut i2s_tx = i2s .i2s_tx - .with_bclk(peripherals.pins.gpio2) - .with_ws(peripherals.pins.gpio4) - .with_dout(peripherals.pins.gpio5) + .with_bclk(peripherals.GPIO2) + .with_ws(peripherals.GPIO4) + .with_dout(peripherals.GPIO5) .build(); let data = diff --git a/examples/src/bin/ieee802154_sniffer.rs b/examples/src/bin/ieee802154_sniffer.rs index 7e9663d2624..55b8d29afbe 100644 --- a/examples/src/bin/ieee802154_sniffer.rs +++ b/examples/src/bin/ieee802154_sniffer.rs @@ -19,9 +19,9 @@ fn main() -> ! { // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32c6")] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO16, peripherals.GPIO17); } else if #[cfg(feature = "esp32h2")] { - let (mut tx_pin, mut rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); + let (mut tx_pin, mut rx_pin) = (peripherals.GPIO24, peripherals.GPIO23); } } diff --git a/examples/src/bin/lcd_cam_ov2640.rs b/examples/src/bin/lcd_cam_ov2640.rs index 705ae915184..4a419a5d3f2 100644 --- a/examples/src/bin/lcd_cam_ov2640.rs +++ b/examples/src/bin/lcd_cam_ov2640.rs @@ -52,21 +52,21 @@ fn main() -> ! { let channel = channel.configure(false, DmaPriority::Priority0); - let cam_siod = peripherals.pins.gpio4; - let cam_sioc = peripherals.pins.gpio5; - let cam_xclk = peripherals.pins.gpio15; - let cam_vsync = peripherals.pins.gpio6; - let cam_href = peripherals.pins.gpio7; - let cam_pclk = peripherals.pins.gpio13; + let cam_siod = peripherals.GPIO4; + let cam_sioc = peripherals.GPIO5; + let cam_xclk = peripherals.GPIO15; + let cam_vsync = peripherals.GPIO6; + let cam_href = peripherals.GPIO7; + let cam_pclk = peripherals.GPIO13; let cam_data_pins = RxEightBits::new( - peripherals.pins.gpio11, - peripherals.pins.gpio9, - peripherals.pins.gpio8, - peripherals.pins.gpio10, - peripherals.pins.gpio12, - peripherals.pins.gpio18, - peripherals.pins.gpio17, - peripherals.pins.gpio16, + peripherals.GPIO11, + peripherals.GPIO9, + peripherals.GPIO8, + peripherals.GPIO10, + peripherals.GPIO12, + peripherals.GPIO18, + peripherals.GPIO17, + peripherals.GPIO16, ); let lcd_cam = LcdCam::new(peripherals.LCD_CAM); diff --git a/examples/src/bin/lcd_i8080.rs b/examples/src/bin/lcd_i8080.rs index 9c2c9c96921..749c5a546ee 100644 --- a/examples/src/bin/lcd_i8080.rs +++ b/examples/src/bin/lcd_i8080.rs @@ -41,11 +41,11 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let lcd_backlight = peripherals.pins.gpio45; - let lcd_reset = peripherals.pins.gpio4; - let lcd_rs = peripherals.pins.gpio0; // Command/Data selection - let lcd_wr = peripherals.pins.gpio47; // Write clock - let lcd_te = peripherals.pins.gpio48; // Frame sync + let lcd_backlight = peripherals.GPIO45; + let lcd_reset = peripherals.GPIO4; + let lcd_rs = peripherals.GPIO0; // Command/Data selection + let lcd_wr = peripherals.GPIO47; // Write clock + let lcd_te = peripherals.GPIO48; // Frame sync let dma = Dma::new(peripherals.DMA); let channel = dma.channel0; @@ -61,14 +61,14 @@ fn main() -> ! { let tear_effect = Input::new(lcd_te, Pull::None); let tx_pins = TxEightBits::new( - peripherals.pins.gpio9, - peripherals.pins.gpio46, - peripherals.pins.gpio3, - peripherals.pins.gpio8, - peripherals.pins.gpio18, - peripherals.pins.gpio17, - peripherals.pins.gpio16, - peripherals.pins.gpio15, + peripherals.GPIO9, + peripherals.GPIO46, + peripherals.GPIO3, + peripherals.GPIO8, + peripherals.GPIO18, + peripherals.GPIO17, + peripherals.GPIO16, + peripherals.GPIO15, ); let lcd_cam = LcdCam::new(peripherals.LCD_CAM); diff --git a/examples/src/bin/ledc.rs b/examples/src/bin/ledc.rs index 396065fb5ac..ce7b3bdd78a 100644 --- a/examples/src/bin/ledc.rs +++ b/examples/src/bin/ledc.rs @@ -25,7 +25,7 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let led = peripherals.pins.gpio0; + let led = peripherals.GPIO0; let mut ledc = Ledc::new(peripherals.LEDC); diff --git a/examples/src/bin/lp_core_basic.rs b/examples/src/bin/lp_core_basic.rs index 56925e18adf..b26acf09107 100644 --- a/examples/src/bin/lp_core_basic.rs +++ b/examples/src/bin/lp_core_basic.rs @@ -27,7 +27,7 @@ fn main() -> ! { // configure GPIO 1 as LP output pin - let lp_pin = LowPowerOutput::new(peripherals.pins.gpio1); + let lp_pin = LowPowerOutput::new(peripherals.GPIO1); let mut lp_core = LpCore::new(peripherals.LP_CORE); lp_core.stop(); diff --git a/examples/src/bin/lp_core_i2c.rs b/examples/src/bin/lp_core_i2c.rs index 303b13a4499..c3bbe3c6bcc 100644 --- a/examples/src/bin/lp_core_i2c.rs +++ b/examples/src/bin/lp_core_i2c.rs @@ -27,8 +27,8 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let lp_sda = LowPowerOutputOpenDrain::new(peripherals.pins.gpio6); - let lp_scl = LowPowerOutputOpenDrain::new(peripherals.pins.gpio7); + let lp_sda = LowPowerOutputOpenDrain::new(peripherals.GPIO6); + let lp_scl = LowPowerOutputOpenDrain::new(peripherals.GPIO7); let lp_i2c = LpI2c::new(peripherals.LP_I2C0, lp_sda, lp_scl, 100.kHz()); diff --git a/examples/src/bin/lp_core_uart.rs b/examples/src/bin/lp_core_uart.rs index b3cbc7df67c..15c3d98da71 100644 --- a/examples/src/bin/lp_core_uart.rs +++ b/examples/src/bin/lp_core_uart.rs @@ -32,14 +32,14 @@ fn main() -> ! { let mut uart1 = Uart::new_with_config( peripherals.UART1, Config::default(), - peripherals.pins.gpio6, - peripherals.pins.gpio7, + peripherals.GPIO6, + peripherals.GPIO7, ) .unwrap(); // Set up (LP) UART: - let lp_tx = LowPowerOutput::new(peripherals.pins.gpio5); - let lp_rx = LowPowerInput::new(peripherals.pins.gpio4); + let lp_tx = LowPowerOutput::new(peripherals.GPIO5); + let lp_rx = LowPowerInput::new(peripherals.GPIO4); let lp_uart = LpUart::new(peripherals.LP_UART, lp_tx, lp_rx); let mut lp_core = LpCore::new(peripherals.LP_CORE); diff --git a/examples/src/bin/mcpwm.rs b/examples/src/bin/mcpwm.rs index 98d42bdeb99..8e3281159e9 100644 --- a/examples/src/bin/mcpwm.rs +++ b/examples/src/bin/mcpwm.rs @@ -19,7 +19,7 @@ use esp_hal::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let pin = peripherals.pins.gpio0; + let pin = peripherals.GPIO0; // initialize peripheral cfg_if::cfg_if! { diff --git a/examples/src/bin/parl_io_rx.rs b/examples/src/bin/parl_io_rx.rs index 22937190c2c..6f5d1c2f353 100644 --- a/examples/src/bin/parl_io_rx.rs +++ b/examples/src/bin/parl_io_rx.rs @@ -29,10 +29,10 @@ fn main() -> ! { let dma_channel = dma.channel0; let mut rx_pins = RxFourBits::new( - peripherals.pins.gpio1, - peripherals.pins.gpio2, - peripherals.pins.gpio3, - peripherals.pins.gpio4, + peripherals.GPIO1, + peripherals.GPIO2, + peripherals.GPIO3, + peripherals.GPIO4, ); let parl_io = ParlIoRxOnly::new( diff --git a/examples/src/bin/parl_io_tx.rs b/examples/src/bin/parl_io_tx.rs index 97184a339fd..fc790349e78 100644 --- a/examples/src/bin/parl_io_tx.rs +++ b/examples/src/bin/parl_io_tx.rs @@ -40,13 +40,13 @@ fn main() -> ! { let dma_channel = dma.channel0; let tx_pins = TxFourBits::new( - peripherals.pins.gpio1, - peripherals.pins.gpio2, - peripherals.pins.gpio3, - peripherals.pins.gpio4, + peripherals.GPIO1, + peripherals.GPIO2, + peripherals.GPIO3, + peripherals.GPIO4, ); - let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, peripherals.pins.gpio5); + let mut pin_conf = TxPinConfigWithValidPin::new(tx_pins, peripherals.GPIO5); let parl_io = ParlIoTxOnly::new( peripherals.PARL_IO, @@ -56,7 +56,7 @@ fn main() -> ! { ) .unwrap(); - let mut clock_pin = ClkOutPin::new(peripherals.pins.gpio6); + let mut clock_pin = ClkOutPin::new(peripherals.GPIO6); let mut parl_io_tx = parl_io .tx diff --git a/examples/src/bin/pcnt_encoder.rs b/examples/src/bin/pcnt_encoder.rs index 4c5ee1cf0ee..29a9a1a6b20 100644 --- a/examples/src/bin/pcnt_encoder.rs +++ b/examples/src/bin/pcnt_encoder.rs @@ -48,8 +48,8 @@ fn main() -> ! { println!("setup channel 0"); let ch0 = &u0.channel0; - let pin_a = Input::new(peripherals.pins.gpio4, Pull::Up); - let pin_b = Input::new(peripherals.pins.gpio5, Pull::Up); + let pin_a = Input::new(peripherals.GPIO4, Pull::Up); + let pin_b = Input::new(peripherals.GPIO5, Pull::Up); let (input_a, _) = pin_a.split(); let (input_b, _) = pin_b.split(); diff --git a/examples/src/bin/qspi_flash.rs b/examples/src/bin/qspi_flash.rs index e2bea23632c..a7e9df83b54 100644 --- a/examples/src/bin/qspi_flash.rs +++ b/examples/src/bin/qspi_flash.rs @@ -47,19 +47,19 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let sclk = peripherals.pins.gpio0; - let miso = peripherals.pins.gpio2; - let mosi = peripherals.pins.gpio4; - let sio2 = peripherals.pins.gpio5; - let sio3 = peripherals.pins.gpio13; - let cs = peripherals.pins.gpio14; + let sclk = peripherals.GPIO0; + let miso = peripherals.GPIO2; + let mosi = peripherals.GPIO4; + let sio2 = peripherals.GPIO5; + let sio3 = peripherals.GPIO13; + let cs = peripherals.GPIO14; } else { - let sclk = peripherals.pins.gpio0; - let miso = peripherals.pins.gpio1; - let mosi = peripherals.pins.gpio2; - let sio2 = peripherals.pins.gpio3; - let sio3 = peripherals.pins.gpio4; - let cs = peripherals.pins.gpio5; + let sclk = peripherals.GPIO0; + let miso = peripherals.GPIO1; + let mosi = peripherals.GPIO2; + let sio2 = peripherals.GPIO3; + let sio3 = peripherals.GPIO4; + let cs = peripherals.GPIO5; } } diff --git a/examples/src/bin/rmt_rx.rs b/examples/src/bin/rmt_rx.rs index 1e35cea7ade..c9dc626b1b4 100644 --- a/examples/src/bin/rmt_rx.rs +++ b/examples/src/bin/rmt_rx.rs @@ -26,7 +26,7 @@ const WIDTH: usize = 80; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let mut out = Output::new(peripherals.pins.gpio5, Level::Low); + let mut out = Output::new(peripherals.GPIO5, Level::Low); cfg_if::cfg_if! { if #[cfg(feature = "esp32h2")] { @@ -46,11 +46,11 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2"))] { - let mut channel = rmt.channel0.configure(peripherals.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel0.configure(peripherals.GPIO4, rx_config).unwrap(); } else if #[cfg(feature = "esp32s3")] { - let mut channel = rmt.channel7.configure(peripherals.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel7.configure(peripherals.GPIO4, rx_config).unwrap(); } else { - let mut channel = rmt.channel2.configure(peripherals.pins.gpio4, rx_config).unwrap(); + let mut channel = rmt.channel2.configure(peripherals.GPIO4, rx_config).unwrap(); } } diff --git a/examples/src/bin/rmt_tx.rs b/examples/src/bin/rmt_tx.rs index c3ae58e996e..d87e8d87a85 100644 --- a/examples/src/bin/rmt_tx.rs +++ b/examples/src/bin/rmt_tx.rs @@ -38,7 +38,7 @@ fn main() -> ! { let mut channel = rmt .channel0 - .configure(peripherals.pins.gpio4, tx_config) + .configure(peripherals.GPIO4, tx_config) .unwrap(); let delay = Delay::new(); diff --git a/examples/src/bin/serial_interrupts.rs b/examples/src/bin/serial_interrupts.rs index a8dec11dcb7..725f5814d24 100644 --- a/examples/src/bin/serial_interrupts.rs +++ b/examples/src/bin/serial_interrupts.rs @@ -29,17 +29,17 @@ fn main() -> ! { // Default pins for Uart/Serial communication cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio1, peripherals.pins.gpio3); + let (tx_pin, rx_pin) = (peripherals.GPIO1, peripherals.GPIO3); } else if #[cfg(feature = "esp32c2")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio20, peripherals.pins.gpio19); + let (tx_pin, rx_pin) = (peripherals.GPIO20, peripherals.GPIO19); } else if #[cfg(feature = "esp32c3")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio21, peripherals.pins.gpio20); + let (tx_pin, rx_pin) = (peripherals.GPIO21, peripherals.GPIO20); } else if #[cfg(feature = "esp32c6")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio16, peripherals.pins.gpio17); + let (tx_pin, rx_pin) = (peripherals.GPIO16, peripherals.GPIO17); } else if #[cfg(feature = "esp32h2")] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio24, peripherals.pins.gpio23); + let (tx_pin, rx_pin) = (peripherals.GPIO24, peripherals.GPIO23); } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { - let (tx_pin, rx_pin) = (peripherals.pins.gpio43, peripherals.pins.gpio44); + let (tx_pin, rx_pin) = (peripherals.GPIO43, peripherals.GPIO44); } } let config = Config::default().rx_fifo_full_threshold(30); diff --git a/examples/src/bin/sleep_timer_ext0.rs b/examples/src/bin/sleep_timer_ext0.rs index 77d0bfab3b2..f026bbc68b1 100644 --- a/examples/src/bin/sleep_timer_ext0.rs +++ b/examples/src/bin/sleep_timer_ext0.rs @@ -32,7 +32,7 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let ext0_pin = Input::new(peripherals.pins.gpio4, Pull::None); + let ext0_pin = Input::new(peripherals.GPIO4, Pull::None); println!("up and runnning!"); let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn); diff --git a/examples/src/bin/sleep_timer_ext1.rs b/examples/src/bin/sleep_timer_ext1.rs index ba764fac968..783a4a26af7 100644 --- a/examples/src/bin/sleep_timer_ext1.rs +++ b/examples/src/bin/sleep_timer_ext1.rs @@ -33,8 +33,8 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let pin_0 = Input::new(peripherals.pins.gpio4, Pull::None); - let mut pin_2 = peripherals.pins.gpio2; + let pin_0 = Input::new(peripherals.GPIO4, Pull::None); + let mut pin_2 = peripherals.GPIO2; println!("up and runnning!"); let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn); diff --git a/examples/src/bin/sleep_timer_lpio.rs b/examples/src/bin/sleep_timer_lpio.rs index cc449228a35..8ae16d28eb4 100644 --- a/examples/src/bin/sleep_timer_lpio.rs +++ b/examples/src/bin/sleep_timer_lpio.rs @@ -34,8 +34,8 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); - let pin2 = Input::new(peripherals.pins.gpio2, Pull::None); - let mut pin3 = peripherals.pins.gpio3; + let pin2 = Input::new(peripherals.GPIO2, Pull::None); + let mut pin3 = peripherals.GPIO3; println!("up and runnning!"); let reason = get_reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn); diff --git a/examples/src/bin/sleep_timer_rtcio.rs b/examples/src/bin/sleep_timer_rtcio.rs index c87f22eba86..a04c7892ecb 100644 --- a/examples/src/bin/sleep_timer_rtcio.rs +++ b/examples/src/bin/sleep_timer_rtcio.rs @@ -49,16 +49,16 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32c3", feature = "esp32c2"))] { - let pin2 = Input::new(peripherals.pins.gpio2, Pull::None); - let mut pin3 = peripherals.pins.gpio3; + let pin2 = Input::new(peripherals.GPIO2, Pull::None); + let mut pin3 = peripherals.GPIO3; let wakeup_pins: &mut [(&mut dyn gpio::RtcPinWithResistors, WakeupLevel)] = &mut [ (&mut *pin2.into_ref(), WakeupLevel::Low), (&mut pin3, WakeupLevel::High), ]; } else if #[cfg(feature = "esp32s3")] { - let pin17 = Input::new(peripherals.pins.gpio17, Pull::None); - let mut pin18 = peripherals.pins.gpio18; + let pin17 = Input::new(peripherals.GPIO17, Pull::None); + let mut pin18 = peripherals.GPIO18; let wakeup_pins: &mut [(&mut dyn gpio::RtcPin, WakeupLevel)] = &mut [ (&mut *pin17.into_ref(), WakeupLevel::Low), diff --git a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs index 5ee15877be3..6ea46778f86 100644 --- a/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs +++ b/examples/src/bin/spi_halfduplex_read_manufacturer_id.rs @@ -45,19 +45,19 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let sclk = peripherals.pins.gpio0; - let miso = peripherals.pins.gpio2; - let mosi = peripherals.pins.gpio4; - let sio2 = peripherals.pins.gpio5; - let sio3 = peripherals.pins.gpio13; - let cs = peripherals.pins.gpio14; + let sclk = peripherals.GPIO0; + let miso = peripherals.GPIO2; + let mosi = peripherals.GPIO4; + let sio2 = peripherals.GPIO5; + let sio3 = peripherals.GPIO13; + let cs = peripherals.GPIO14; } else { - let sclk = peripherals.pins.gpio0; - let miso = peripherals.pins.gpio1; - let mosi = peripherals.pins.gpio2; - let sio2 = peripherals.pins.gpio3; - let sio3 = peripherals.pins.gpio4; - let cs = peripherals.pins.gpio5; + let sclk = peripherals.GPIO0; + let miso = peripherals.GPIO1; + let mosi = peripherals.GPIO2; + let sio2 = peripherals.GPIO3; + let sio3 = peripherals.GPIO4; + let cs = peripherals.GPIO5; } } diff --git a/examples/src/bin/spi_loopback.rs b/examples/src/bin/spi_loopback.rs index 577b1a821c0..22e92a29ca5 100644 --- a/examples/src/bin/spi_loopback.rs +++ b/examples/src/bin/spi_loopback.rs @@ -31,9 +31,9 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let sclk = peripherals.pins.gpio0; - let miso_mosi = peripherals.pins.gpio2; - let cs = peripherals.pins.gpio5; + let sclk = peripherals.GPIO0; + let miso_mosi = peripherals.GPIO2; + let cs = peripherals.GPIO5; let miso = unsafe { miso_mosi.clone_unchecked() }; diff --git a/examples/src/bin/spi_loopback_dma.rs b/examples/src/bin/spi_loopback_dma.rs index 8dcb339078a..639ac030927 100644 --- a/examples/src/bin/spi_loopback_dma.rs +++ b/examples/src/bin/spi_loopback_dma.rs @@ -35,10 +35,10 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let sclk = peripherals.pins.gpio0; - let miso = peripherals.pins.gpio2; - let mosi = peripherals.pins.gpio4; - let cs = peripherals.pins.gpio5; + let sclk = peripherals.GPIO0; + let miso = peripherals.GPIO2; + let mosi = peripherals.GPIO4; + let cs = peripherals.GPIO5; let dma = Dma::new(peripherals.DMA); diff --git a/examples/src/bin/spi_loopback_dma_psram.rs b/examples/src/bin/spi_loopback_dma_psram.rs index 10c077b9420..0a8fe54445b 100644 --- a/examples/src/bin/spi_loopback_dma_psram.rs +++ b/examples/src/bin/spi_loopback_dma_psram.rs @@ -62,10 +62,10 @@ fn main() -> ! { esp_alloc::psram_allocator!(peripherals.PSRAM, esp_hal::psram); let delay = Delay::new(); - let sclk = peripherals.pins.gpio42; - let mosi = peripherals.pins.gpio48; + let sclk = peripherals.GPIO42; + let mosi = peripherals.GPIO48; let miso = unsafe { mosi.clone_unchecked() }; - let cs = peripherals.pins.gpio38; + let cs = peripherals.GPIO38; let dma = Dma::new(peripherals.DMA); let dma_channel = dma.channel0; diff --git a/examples/src/bin/spi_slave_dma.rs b/examples/src/bin/spi_slave_dma.rs index 29c64356373..142816166f9 100644 --- a/examples/src/bin/spi_slave_dma.rs +++ b/examples/src/bin/spi_slave_dma.rs @@ -44,15 +44,15 @@ use esp_println::println; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let mut master_sclk = Output::new(peripherals.pins.gpio4, Level::Low); - let master_miso = Input::new(peripherals.pins.gpio5, Pull::None); - let mut master_mosi = Output::new(peripherals.pins.gpio8, Level::Low); - let mut master_cs = Output::new(peripherals.pins.gpio9, Level::High); - - let slave_sclk = peripherals.pins.gpio0; - let slave_miso = peripherals.pins.gpio1; - let slave_mosi = peripherals.pins.gpio2; - let slave_cs = peripherals.pins.gpio3; + let mut master_sclk = Output::new(peripherals.GPIO4, Level::Low); + let master_miso = Input::new(peripherals.GPIO5, Pull::None); + let mut master_mosi = Output::new(peripherals.GPIO8, Level::Low); + let mut master_cs = Output::new(peripherals.GPIO9, Level::High); + + let slave_sclk = peripherals.GPIO0; + let slave_miso = peripherals.GPIO1; + let slave_mosi = peripherals.GPIO2; + let slave_cs = peripherals.GPIO3; let dma = Dma::new(peripherals.DMA); cfg_if::cfg_if! { diff --git a/examples/src/bin/touch.rs b/examples/src/bin/touch.rs index d82a794df70..a36207a8a75 100644 --- a/examples/src/bin/touch.rs +++ b/examples/src/bin/touch.rs @@ -52,8 +52,8 @@ fn main() -> ! { let mut rtc = Rtc::new(peripherals.LPWR); rtc.set_interrupt_handler(interrupt_handler); - let touch_pin0 = peripherals.pins.gpio2; - let touch_pin1 = peripherals.pins.gpio4; + let touch_pin0 = peripherals.GPIO2; + let touch_pin1 = peripherals.GPIO4; let touch_cfg = Some(TouchConfig { measurement_duration: Some(0x2000), diff --git a/examples/src/bin/twai.rs b/examples/src/bin/twai.rs index 063d6c1d7bb..b59a39cda55 100644 --- a/examples/src/bin/twai.rs +++ b/examples/src/bin/twai.rs @@ -40,10 +40,10 @@ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); // Without an external transceiver, we only need a single line between the two MCUs. - let (rx_pin, tx_pin) = peripherals.pins.gpio2.split(); + let (rx_pin, tx_pin) = peripherals.GPIO2.split(); // Use these if you want to use an external transceiver: - // let tx_pin = peripherals.pins.gpio2; - // let rx_pin = peripherals.pins.gpio0; + // let tx_pin = peripherals.GPIO2; + // let rx_pin = peripherals.GPIO0; // The speed of the bus. const TWAI_BAUDRATE: twai::BaudRate = twai::BaudRate::B125K; diff --git a/examples/src/bin/ulp_riscv_core_basic.rs b/examples/src/bin/ulp_riscv_core_basic.rs index 98087c84d54..6d062b7f3c1 100644 --- a/examples/src/bin/ulp_riscv_core_basic.rs +++ b/examples/src/bin/ulp_riscv_core_basic.rs @@ -19,7 +19,7 @@ use esp_println::{print, println}; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let pin = LowPowerOutput::new(peripherals.pins.gpio1); + let pin = LowPowerOutput::new(peripherals.GPIO1); let mut ulp_core = ulp_core::UlpCore::new(peripherals.ULP_RISCV_CORE); diff --git a/examples/src/bin/usb_serial.rs b/examples/src/bin/usb_serial.rs index 8f29eaa71ca..1bb93ae1a56 100644 --- a/examples/src/bin/usb_serial.rs +++ b/examples/src/bin/usb_serial.rs @@ -27,11 +27,7 @@ static mut EP_MEMORY: [u32; 1024] = [0; 1024]; fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let usb = Usb::new( - peripherals.USB0, - peripherals.pins.gpio20, - peripherals.pins.gpio19, - ); + let usb = Usb::new(peripherals.USB0, peripherals.GPIO20, peripherals.GPIO19); let usb_bus = UsbBus::new(usb, unsafe { &mut *addr_of_mut!(EP_MEMORY) }); let mut serial = SerialPort::new(&usb_bus); diff --git a/examples/src/bin/wifi_ble.rs b/examples/src/bin/wifi_ble.rs index 4927f6d0fde..84e383e0787 100644 --- a/examples/src/bin/wifi_ble.rs +++ b/examples/src/bin/wifi_ble.rs @@ -56,9 +56,9 @@ fn main() -> ! { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let button = Input::new(peripherals.pins.gpio0, Pull::Down); + let button = Input::new(peripherals.GPIO0, Pull::Down); } else { - let button = Input::new(peripherals.pins.gpio9, Pull::Down); + let button = Input::new(peripherals.GPIO9, Pull::Down); } } diff --git a/examples/src/bin/wifi_embassy_ble.rs b/examples/src/bin/wifi_embassy_ble.rs index a303c2b7cc9..22ad06076d4 100644 --- a/examples/src/bin/wifi_embassy_ble.rs +++ b/examples/src/bin/wifi_embassy_ble.rs @@ -72,9 +72,9 @@ async fn main(_spawner: Spawner) -> ! { cfg_if::cfg_if! { if #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] { - let button = Input::new(peripherals.pins.gpio0, Pull::Down); + let button = Input::new(peripherals.GPIO0, Pull::Down); } else { - let button = Input::new(peripherals.pins.gpio9, Pull::Down); + let button = Input::new(peripherals.GPIO9, Pull::Down); } } diff --git a/hil-test/src/lib.rs b/hil-test/src/lib.rs index 04fd7f6e9c4..660e8697cbe 100644 --- a/hil-test/src/lib.rs +++ b/hil-test/src/lib.rs @@ -31,17 +31,17 @@ macro_rules! i2c_pins { // Order: (SDA, SCL) cfg_if::cfg_if! { if #[cfg(any(esp32s2, esp32s3))] { - ($peripherals.pins.gpio2, $peripherals.pins.gpio3) + ($peripherals.GPIO2, $peripherals.GPIO3) } else if #[cfg(esp32)] { - ($peripherals.pins.gpio32, $peripherals.pins.gpio33) + ($peripherals.GPIO32, $peripherals.GPIO33) } else if #[cfg(esp32c6)] { - ($peripherals.pins.gpio6, $peripherals.pins.gpio7) + ($peripherals.GPIO6, $peripherals.GPIO7) } else if #[cfg(esp32h2)] { - ($peripherals.pins.gpio12, $peripherals.pins.gpio22) + ($peripherals.GPIO12, $peripherals.GPIO22) } else if #[cfg(esp32c2)] { - ($peripherals.pins.gpio18, $peripherals.pins.gpio9) + ($peripherals.GPIO18, $peripherals.GPIO9) } else { - ($peripherals.pins.gpio4, $peripherals.pins.gpio5) + ($peripherals.GPIO4, $peripherals.GPIO5) } } }}; @@ -52,11 +52,11 @@ macro_rules! common_test_pins { ($peripherals:expr) => {{ cfg_if::cfg_if! { if #[cfg(any(esp32s2, esp32s3))] { - ($peripherals.pins.gpio9, $peripherals.pins.gpio10) + ($peripherals.GPIO9, $peripherals.GPIO10) } else if #[cfg(esp32)] { - ($peripherals.pins.gpio26, $peripherals.pins.gpio27) + ($peripherals.GPIO26, $peripherals.GPIO27) } else { - ($peripherals.pins.gpio2, $peripherals.pins.gpio3) + ($peripherals.GPIO2, $peripherals.GPIO3) } } }}; @@ -69,15 +69,15 @@ macro_rules! unconnected_pin { ($peripherals:expr) => {{ cfg_if::cfg_if! { if #[cfg(any(esp32, esp32s2, esp32s3))] { - $peripherals.pins.gpio0 + $peripherals.GPIO0 } else if #[cfg(esp32c6)] { - $peripherals.pins.gpio9 + $peripherals.GPIO9 } else if #[cfg(esp32h2)] { - $peripherals.pins.gpio9 + $peripherals.GPIO9 } else if #[cfg(esp32c2)] { - $peripherals.pins.gpio8 + $peripherals.GPIO8 } else { - $peripherals.pins.gpio9 + $peripherals.GPIO9 } } }}; diff --git a/hil-test/tests/embassy_interrupt_spi_dma.rs b/hil-test/tests/embassy_interrupt_spi_dma.rs index 46c91be1914..082fd2dceca 100644 --- a/hil-test/tests/embassy_interrupt_spi_dma.rs +++ b/hil-test/tests/embassy_interrupt_spi_dma.rs @@ -11,7 +11,6 @@ use embassy_time::{Duration, Instant, Ticker}; use esp_hal::{ dma::{Dma, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, - gpio::Io, interrupt::{software::SoftwareInterruptControl, Priority}, peripheral::Peripheral, prelude::*, diff --git a/hil-test/tests/gpio.rs b/hil-test/tests/gpio.rs index 1d999fbf3bf..0d197b2d17d 100644 --- a/hil-test/tests/gpio.rs +++ b/hil-test/tests/gpio.rs @@ -387,8 +387,8 @@ mod tests { #[cfg(esp32)] #[test] fn can_configure_rtcio_pins_as_input() { - let pins = unsafe { esp_hal::gpio::Pins::steal() }; + let pin = unsafe { esp_hal::gpio::GpioPin::<37>::steal() }; - _ = Input::new(pins.gpio37, Pull::Down); + _ = Input::new(pin, Pull::Down); } } diff --git a/hil-test/tests/lcd_cam_i8080.rs b/hil-test/tests/lcd_cam_i8080.rs index 2c7d761ddbf..33a76d04c36 100644 --- a/hil-test/tests/lcd_cam_i8080.rs +++ b/hil-test/tests/lcd_cam_i8080.rs @@ -8,7 +8,7 @@ use esp_hal::{ dma::{Dma, DmaPriority, DmaTxBuf}, dma_buffers, - gpio::{Io, NoPin, Pins}, + gpio::{GpioPin, NoPin}, lcd_cam::{ lcd::i8080::{Command, Config, TxEightBits, TxSixteenBits, I8080}, BitOrder, @@ -25,6 +25,15 @@ use hil_test as _; const DATA_SIZE: usize = 1024 * 10; +#[allow(non_snake_case)] +struct Pins { + pub GPIO8: GpioPin<8>, + pub GPIO11: GpioPin<11>, + pub GPIO12: GpioPin<12>, + pub GPIO16: GpioPin<16>, + pub GPIO17: GpioPin<17>, +} + struct Context<'d> { lcd_cam: LcdCam<'d, Blocking>, pcnt: Pcnt<'d>, @@ -52,7 +61,13 @@ mod tests { lcd_cam, dma, pcnt, - pins: peripherals.pins, + pins: Pins { + GPIO8: peripherals.GPIO8, + GPIO11: peripherals.GPIO11, + GPIO12: peripherals.GPIO12, + GPIO16: peripherals.GPIO16, + GPIO17: peripherals.GPIO17, + }, dma_buf, } } @@ -102,11 +117,11 @@ mod tests { // issue with configuring pins as outputs after inputs have been sorted // out. See https://github.com/esp-rs/esp-hal/pull/2173#issue-2529323702 - let (unit_ctrl, cs_signal) = ctx.pins.gpio8.split(); - let (unit0_input, unit0_signal) = ctx.pins.gpio11.split(); - let (unit1_input, unit1_signal) = ctx.pins.gpio12.split(); - let (unit2_input, unit2_signal) = ctx.pins.gpio16.split(); - let (unit3_input, unit3_signal) = ctx.pins.gpio17.split(); + let (unit_ctrl, cs_signal) = ctx.pins.GPIO8.split(); + let (unit0_input, unit0_signal) = ctx.pins.GPIO11.split(); + let (unit1_input, unit1_signal) = ctx.pins.GPIO12.split(); + let (unit2_input, unit2_signal) = ctx.pins.GPIO16.split(); + let (unit3_input, unit3_signal) = ctx.pins.GPIO17.split(); let pcnt = ctx.pcnt; @@ -213,11 +228,11 @@ mod tests { // issue with configuring pins as outputs after inputs have been sorted // out. See https://github.com/esp-rs/esp-hal/pull/2173#issue-2529323702 - let (unit_ctrl, cs_signal) = ctx.pins.gpio8.split(); - let (unit0_input, unit0_signal) = ctx.pins.gpio11.split(); - let (unit1_input, unit1_signal) = ctx.pins.gpio12.split(); - let (unit2_input, unit2_signal) = ctx.pins.gpio16.split(); - let (unit3_input, unit3_signal) = ctx.pins.gpio17.split(); + let (unit_ctrl, cs_signal) = ctx.pins.GPIO8.split(); + let (unit0_input, unit0_signal) = ctx.pins.GPIO11.split(); + let (unit1_input, unit1_signal) = ctx.pins.GPIO12.split(); + let (unit2_input, unit2_signal) = ctx.pins.GPIO16.split(); + let (unit3_input, unit3_signal) = ctx.pins.GPIO17.split(); let pcnt = ctx.pcnt; diff --git a/hil-test/tests/spi_full_duplex.rs b/hil-test/tests/spi_full_duplex.rs index 7a0b0ea9570..3e7a42b398c 100644 --- a/hil-test/tests/spi_full_duplex.rs +++ b/hil-test/tests/spi_full_duplex.rs @@ -58,7 +58,7 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let sclk = peripherals.pins.gpio0; + let sclk = peripherals.GPIO0; let (_, mosi) = hil_test::common_test_pins!(peripherals); let dma = Dma::new(peripherals.DMA); diff --git a/hil-test/tests/spi_half_duplex_read.rs b/hil-test/tests/spi_half_duplex_read.rs index 8192850293e..212e764424a 100644 --- a/hil-test/tests/spi_half_duplex_read.rs +++ b/hil-test/tests/spi_half_duplex_read.rs @@ -33,7 +33,7 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let sclk = peripherals.pins.gpio0; + let sclk = peripherals.GPIO0; let (miso, miso_mirror) = hil_test::common_test_pins!(peripherals); let miso_mirror = Output::new(miso_mirror, Level::High); diff --git a/hil-test/tests/spi_half_duplex_write.rs b/hil-test/tests/spi_half_duplex_write.rs index 7ec44286c4b..985ede3e5f6 100644 --- a/hil-test/tests/spi_half_duplex_write.rs +++ b/hil-test/tests/spi_half_duplex_write.rs @@ -35,7 +35,7 @@ mod tests { fn init() -> Context { let peripherals = esp_hal::init(esp_hal::Config::default()); - let sclk = peripherals.pins.gpio0; + let sclk = peripherals.GPIO0; let (mosi, _) = hil_test::common_test_pins!(peripherals); let pcnt = Pcnt::new(peripherals.PCNT); diff --git a/hil-test/tests/spi_half_duplex_write_psram.rs b/hil-test/tests/spi_half_duplex_write_psram.rs index 6968ecb32f5..950cf2f0ea6 100644 --- a/hil-test/tests/spi_half_duplex_write_psram.rs +++ b/hil-test/tests/spi_half_duplex_write_psram.rs @@ -10,7 +10,7 @@ use esp_hal::{ dma::{Dma, DmaBufBlkSize, DmaPriority, DmaRxBuf, DmaTxBuf}, dma_buffers, dma_descriptors_chunk_size, - gpio::{interconnect::InputSignal, Io}, + gpio::interconnect::InputSignal, pcnt::{channel::EdgeMode, unit::Unit, Pcnt}, prelude::*, spi::{ @@ -53,7 +53,7 @@ mod tests { let peripherals = esp_hal::init(esp_hal::Config::default()); esp_alloc::psram_allocator!(peripherals.PSRAM, esp_hal::psram); - let sclk = peripherals.pins.gpio0; + let sclk = peripherals.GPIO0; let (mosi, _) = hil_test::common_test_pins!(peripherals); let pcnt = Pcnt::new(peripherals.PCNT);