From 1724685f2e760f9b0ae81ced7d9aeb3ab8ea2c16 Mon Sep 17 00:00:00 2001 From: icedrocket <114203630+icedrocket@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:50:00 +0900 Subject: [PATCH 1/3] Add more trait re-exports to prelude module --- esp-hal-common/src/prelude.rs | 96 ++++++++++++++++++++++-- esp32-hal/examples/gpio_interrupt.rs | 2 +- esp32-hal/examples/spi_loopback_dma.rs | 4 +- esp32c2-hal/examples/adc.rs | 2 - esp32c2-hal/examples/blinky.rs | 1 - esp32c2-hal/examples/gpio_interrupt.rs | 2 +- esp32c2-hal/examples/spi_loopback_dma.rs | 4 +- esp32c3-hal/examples/adc.rs | 2 - esp32c3-hal/examples/blinky.rs | 1 - esp32c3-hal/examples/gpio_interrupt.rs | 2 +- esp32c3-hal/examples/pulse_control.rs | 1 - esp32c3-hal/examples/spi_loopback_dma.rs | 4 +- esp32s2-hal/examples/gpio_interrupt.rs | 2 +- esp32s2-hal/examples/spi_loopback_dma.rs | 4 +- esp32s3-hal/examples/adc.rs | 1 - esp32s3-hal/examples/gpio_interrupt.rs | 2 +- esp32s3-hal/examples/spi_loopback_dma.rs | 4 +- 17 files changed, 106 insertions(+), 28 deletions(-) diff --git a/esp-hal-common/src/prelude.rs b/esp-hal-common/src/prelude.rs index 2b97508355c..aefd61d1aed 100644 --- a/esp-hal-common/src/prelude.rs +++ b/esp-hal-common/src/prelude.rs @@ -20,9 +20,52 @@ pub use fugit::{ }; pub use nb; +#[cfg(any(esp32c2, esp32c3))] +pub use crate::analog::SarAdcExt as _esp_hal_analog_SarAdcExt; +#[cfg(any(esp32, esp32s2, esp32s3))] +pub use crate::analog::SensExt as _esp_hal_analog_SensExt; +#[cfg(rmt)] +pub use crate::pulse_control::{ + ConfiguredChannel as _esp_hal_pulse_control_ConfiguredChannel, + OutputChannel as _esp_hal_pulse_control_OutputChannel, +}; #[cfg(any(esp32, esp32s2))] -pub use crate::analog::SensExt; -pub use crate::{macros::*, system::SystemExt}; +pub use crate::spi::dma::WithDmaSpi3 as _esp_hal_spi_dma_WithDmaSpi3; +pub use crate::{ + clock::Clock as _esp_hal_clock_Clock, + dma::{ + DmaTransfer as _esp_hal_dma_DmaTransfer, + DmaTransferRxTx as _esp_hal_dma_DmaTransferRxTx, + }, + gpio::{ + InputPin as _esp_hal_gpio_InputPin, + OutputPin as _esp_hal_gpio_OutputPin, + Pin as _esp_hal_gpio_Pin, + }, + i2c::Instance as _esp_hal_i2c_Instance, + ledc::{ + channel::{ + ChannelHW as _esp_hal_ledc_channel_ChannelHW, + ChannelIFace as _esp_hal_ledc_channel_ChannelIFace, + }, + timer::{ + TimerHW as _esp_hal_ledc_timer_TimerHW, + TimerIFace as _esp_hal_ledc_timer_TimerIFace, + }, + }, + macros::*, + serial::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins}, + spi::{ + dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2, + Instance as _esp_hal_spi_Instance, + InstanceDma as _esp_hal_spi_InstanceDma, + }, + system::SystemExt as _esp_hal_system_SystemExt, + timer::{ + Instance as _esp_hal_timer_Instance, + TimerGroupInstance as _esp_hal_timer_TimerGroupInstance, + }, +}; /// All traits required for using the 1.0.0-alpha.x release of embedded-hal #[cfg(feature = "eh1")] @@ -55,7 +98,50 @@ pub mod eh1 { }; pub use nb; - pub use crate::system::SystemExt; + #[cfg(any(esp32c2, esp32c3))] + pub use crate::analog::SarAdcExt as _esp_hal_analog_SarAdcExt; + #[cfg(any(esp32, esp32s2, esp32s3))] + pub use crate::analog::SensExt as _esp_hal_analog_SensExt; + #[cfg(rmt)] + pub use crate::pulse_control::{ + ConfiguredChannel as _esp_hal_pulse_control_ConfiguredChannel, + OutputChannel as _esp_hal_pulse_control_OutputChannel, + }; + #[cfg(any(esp32, esp32s2))] + pub use crate::spi::dma::WithDmaSpi3 as _esp_hal_spi_dma_WithDmaSpi3; + pub use crate::{ + clock::Clock as _esp_hal_clock_Clock, + dma::{ + DmaTransfer as _esp_hal_dma_DmaTransfer, + DmaTransferRxTx as _esp_hal_dma_DmaTransferRxTx, + }, + gpio::{ + InputPin as _esp_hal_gpio_InputPin, + OutputPin as _esp_hal_gpio_OutputPin, + Pin as _esp_hal_gpio_Pin, + }, + i2c::Instance as _esp_hal_i2c_Instance, + ledc::{ + channel::{ + ChannelHW as _esp_hal_ledc_channel_ChannelHW, + ChannelIFace as _esp_hal_ledc_channel_ChannelIFace, + }, + timer::{ + TimerHW as _esp_hal_ledc_timer_TimerHW, + TimerIFace as _esp_hal_ledc_timer_TimerIFace, + }, + }, + macros::*, + serial::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins}, + spi::{ + dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2, + Instance as _esp_hal_spi_Instance, + InstanceDma as _esp_hal_spi_InstanceDma, + }, + system::SystemExt as _esp_hal_system_SystemExt, + timer::{ + Instance as _esp_hal_timer_Instance, + TimerGroupInstance as _esp_hal_timer_TimerGroupInstance, + }, + }; } - -pub use crate::{macros::*, timer::Instance}; diff --git a/esp32-hal/examples/gpio_interrupt.rs b/esp32-hal/examples/gpio_interrupt.rs index 8076d879c43..14611b793eb 100644 --- a/esp32-hal/examples/gpio_interrupt.rs +++ b/esp32-hal/examples/gpio_interrupt.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32_hal::{ clock::ClockControl, gpio::{Gpio0, IO}, - gpio_types::{Event, Input, Pin, PullDown}, + gpio_types::{Event, Input, PullDown}, interrupt, macros::ram, pac::{self, Peripherals}, diff --git a/esp32-hal/examples/spi_loopback_dma.rs b/esp32-hal/examples/spi_loopback_dma.rs index 6eb3c069f0e..241fbb1db1b 100644 --- a/esp32-hal/examples/spi_loopback_dma.rs +++ b/esp32-hal/examples/spi_loopback_dma.rs @@ -18,12 +18,12 @@ use esp32_hal::{ clock::ClockControl, - dma::{DmaPriority, DmaTransferRxTx}, + dma::{DmaPriority}, gpio::IO, pac::Peripherals, pdma::Dma, prelude::*, - spi::{dma::WithDmaSpi2, Spi, SpiMode}, + spi::{Spi, SpiMode}, timer::TimerGroup, Delay, Rtc, diff --git a/esp32c2-hal/examples/adc.rs b/esp32c2-hal/examples/adc.rs index 4e6b031865f..58581aa8a47 100644 --- a/esp32c2-hal/examples/adc.rs +++ b/esp32c2-hal/examples/adc.rs @@ -7,12 +7,10 @@ use esp32c2_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC1}, - analog::SarAdcExt, clock::ClockControl, gpio::IO, pac::Peripherals, prelude::*, - system::SystemExt, timer::TimerGroup, Delay, Rtc, diff --git a/esp32c2-hal/examples/blinky.rs b/esp32c2-hal/examples/blinky.rs index 4598fd4c771..649843f9e83 100644 --- a/esp32c2-hal/examples/blinky.rs +++ b/esp32c2-hal/examples/blinky.rs @@ -10,7 +10,6 @@ use esp32c2_hal::{ gpio::IO, pac::Peripherals, prelude::*, - system::SystemExt, timer::TimerGroup, Delay, Rtc, diff --git a/esp32c2-hal/examples/gpio_interrupt.rs b/esp32c2-hal/examples/gpio_interrupt.rs index 86dd749df7a..fc92b49596f 100644 --- a/esp32c2-hal/examples/gpio_interrupt.rs +++ b/esp32c2-hal/examples/gpio_interrupt.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32c2_hal::{ clock::ClockControl, gpio::{Gpio9, IO}, - gpio_types::{Event, Input, Pin, PullDown}, + gpio_types::{Event, Input, PullDown}, interrupt, pac::{self, Peripherals}, prelude::*, diff --git a/esp32c2-hal/examples/spi_loopback_dma.rs b/esp32c2-hal/examples/spi_loopback_dma.rs index 3b8eb46aaba..fecc9977d79 100644 --- a/esp32c2-hal/examples/spi_loopback_dma.rs +++ b/esp32c2-hal/examples/spi_loopback_dma.rs @@ -18,12 +18,12 @@ use esp32c2_hal::{ clock::ClockControl, - dma::{DmaPriority, DmaTransferRxTx}, + dma::{DmaPriority}, gdma::Gdma, gpio::IO, pac::Peripherals, prelude::*, - spi::{dma::WithDmaSpi2, Spi, SpiMode}, + spi::{Spi, SpiMode}, timer::TimerGroup, Delay, Rtc, diff --git a/esp32c3-hal/examples/adc.rs b/esp32c3-hal/examples/adc.rs index 7b89df76afd..6e3d93bb0d0 100644 --- a/esp32c3-hal/examples/adc.rs +++ b/esp32c3-hal/examples/adc.rs @@ -7,12 +7,10 @@ use esp32c3_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC1}, - analog::SarAdcExt, clock::ClockControl, gpio::IO, pac::Peripherals, prelude::*, - system::SystemExt, timer::TimerGroup, Delay, Rtc, diff --git a/esp32c3-hal/examples/blinky.rs b/esp32c3-hal/examples/blinky.rs index 305e867ffb4..6d71b197156 100644 --- a/esp32c3-hal/examples/blinky.rs +++ b/esp32c3-hal/examples/blinky.rs @@ -10,7 +10,6 @@ use esp32c3_hal::{ gpio::IO, pac::Peripherals, prelude::*, - system::SystemExt, timer::TimerGroup, Delay, Rtc, diff --git a/esp32c3-hal/examples/gpio_interrupt.rs b/esp32c3-hal/examples/gpio_interrupt.rs index a0c5c8bcea8..b0b0f7846ed 100644 --- a/esp32c3-hal/examples/gpio_interrupt.rs +++ b/esp32c3-hal/examples/gpio_interrupt.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32c3_hal::{ clock::ClockControl, gpio::{Gpio9, IO}, - gpio_types::{Event, Input, Pin, PullDown}, + gpio_types::{Event, Input, PullDown}, interrupt, pac::{self, Peripherals}, prelude::*, diff --git a/esp32c3-hal/examples/pulse_control.rs b/esp32c3-hal/examples/pulse_control.rs index 854f30d7e84..5287f21b706 100644 --- a/esp32c3-hal/examples/pulse_control.rs +++ b/esp32c3-hal/examples/pulse_control.rs @@ -11,7 +11,6 @@ use esp32c3_hal::{ pac::Peripherals, prelude::*, pulse_control::{ClockSource, ConfiguredChannel, OutputChannel, PulseCode, RepeatMode}, - system::SystemExt, timer::TimerGroup, PulseControl, Rtc, diff --git a/esp32c3-hal/examples/spi_loopback_dma.rs b/esp32c3-hal/examples/spi_loopback_dma.rs index 49e933ac4b2..ee1bf7a5995 100644 --- a/esp32c3-hal/examples/spi_loopback_dma.rs +++ b/esp32c3-hal/examples/spi_loopback_dma.rs @@ -18,12 +18,12 @@ use esp32c3_hal::{ clock::ClockControl, - dma::{DmaPriority, DmaTransferRxTx}, + dma::{DmaPriority}, gdma::Gdma, gpio::IO, pac::Peripherals, prelude::*, - spi::{dma::WithDmaSpi2, Spi, SpiMode}, + spi::{Spi, SpiMode}, timer::TimerGroup, Delay, Rtc, diff --git a/esp32s2-hal/examples/gpio_interrupt.rs b/esp32s2-hal/examples/gpio_interrupt.rs index 16a0e26a940..2ad309fc920 100644 --- a/esp32s2-hal/examples/gpio_interrupt.rs +++ b/esp32s2-hal/examples/gpio_interrupt.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32s2_hal::{ clock::ClockControl, gpio::{Gpio0, IO}, - gpio_types::{Event, Input, Pin, PullDown}, + gpio_types::{Event, Input, PullDown}, interrupt, macros::ram, pac::{self, Peripherals}, diff --git a/esp32s2-hal/examples/spi_loopback_dma.rs b/esp32s2-hal/examples/spi_loopback_dma.rs index c3e31ce5961..a8a72cc0996 100644 --- a/esp32s2-hal/examples/spi_loopback_dma.rs +++ b/esp32s2-hal/examples/spi_loopback_dma.rs @@ -18,12 +18,12 @@ use esp32s2_hal::{ clock::ClockControl, - dma::{DmaPriority, DmaTransferRxTx}, + dma::{DmaPriority}, gpio::IO, pac::Peripherals, pdma::Dma, prelude::*, - spi::{dma::WithDmaSpi2, Spi, SpiMode}, + spi::{Spi, SpiMode}, timer::TimerGroup, Delay, Rtc, diff --git a/esp32s3-hal/examples/adc.rs b/esp32s3-hal/examples/adc.rs index a2be3e4dd20..60e710e6f1d 100644 --- a/esp32s3-hal/examples/adc.rs +++ b/esp32s3-hal/examples/adc.rs @@ -7,7 +7,6 @@ use esp32s3_hal::{ adc::{AdcConfig, Attenuation, ADC, ADC1}, - analog::SensExt, clock::ClockControl, gpio::IO, pac::Peripherals, diff --git a/esp32s3-hal/examples/gpio_interrupt.rs b/esp32s3-hal/examples/gpio_interrupt.rs index cfe7609ebec..8298d537fd3 100644 --- a/esp32s3-hal/examples/gpio_interrupt.rs +++ b/esp32s3-hal/examples/gpio_interrupt.rs @@ -12,7 +12,7 @@ use critical_section::Mutex; use esp32s3_hal::{ clock::ClockControl, gpio::{Gpio0, IO}, - gpio_types::{Event, Input, Pin, PullDown}, + gpio_types::{Event, Input, PullDown}, interrupt, macros::ram, pac::{self, Peripherals}, diff --git a/esp32s3-hal/examples/spi_loopback_dma.rs b/esp32s3-hal/examples/spi_loopback_dma.rs index dc16fa42e5a..94a3dd96338 100644 --- a/esp32s3-hal/examples/spi_loopback_dma.rs +++ b/esp32s3-hal/examples/spi_loopback_dma.rs @@ -18,12 +18,12 @@ use esp32s3_hal::{ clock::ClockControl, - dma::{DmaPriority, DmaTransferRxTx}, + dma::{DmaPriority}, gdma::Gdma, gpio::IO, pac::Peripherals, prelude::*, - spi::{dma::WithDmaSpi2, Spi, SpiMode}, + spi::{Spi, SpiMode}, timer::TimerGroup, Delay, Rtc, From 9b068e182544586e34396331b927ca4a3e22ef13 Mon Sep 17 00:00:00 2001 From: icedrocket <114203630+icedrocket@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:50:00 +0900 Subject: [PATCH 2/3] Don't expose usb_serial_jtag module --- esp32s3-hal/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/esp32s3-hal/src/lib.rs b/esp32s3-hal/src/lib.rs index 8156e3763b4..81a652157d7 100644 --- a/esp32s3-hal/src/lib.rs +++ b/esp32s3-hal/src/lib.rs @@ -23,7 +23,6 @@ pub use esp_hal_common::{ spi, systimer, timer, - usb_serial_jtag, utils, Cpu, Delay, From ab38c47de5806e382e9b71e0295799bd5b1aed68 Mon Sep 17 00:00:00 2001 From: icedrocket <114203630+icedrocket@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:50:00 +0900 Subject: [PATCH 3/3] Add missing system module re-exports --- esp32-hal/src/lib.rs | 1 + esp32s2-hal/src/lib.rs | 1 + esp32s3-hal/src/lib.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/esp32-hal/src/lib.rs b/esp32-hal/src/lib.rs index 51312de2f7d..bfba115d858 100644 --- a/esp32-hal/src/lib.rs +++ b/esp32-hal/src/lib.rs @@ -19,6 +19,7 @@ pub use esp_hal_common::{ pulse_control, serial, spi, + system, timer, utils, Cpu, diff --git a/esp32s2-hal/src/lib.rs b/esp32s2-hal/src/lib.rs index ffb1bd5727a..b109e6d5077 100644 --- a/esp32s2-hal/src/lib.rs +++ b/esp32s2-hal/src/lib.rs @@ -19,6 +19,7 @@ pub use esp_hal_common::{ pulse_control, serial, spi, + system, systimer, timer, utils, diff --git a/esp32s3-hal/src/lib.rs b/esp32s3-hal/src/lib.rs index 81a652157d7..94389bf4304 100644 --- a/esp32s3-hal/src/lib.rs +++ b/esp32s3-hal/src/lib.rs @@ -21,6 +21,7 @@ pub use esp_hal_common::{ pulse_control, serial, spi, + system, systimer, timer, utils,