Skip to content

Commit

Permalink
Use newly published versions of all PACs in esp-hal (#2025)
Browse files Browse the repository at this point in the history
* Use newly published versions of all PACs in `esp-hal`

* Address additional review comments
  • Loading branch information
jessebraham committed Aug 29, 2024
1 parent 99c238d commit bac6bfd
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 68 deletions.
14 changes: 7 additions & 7 deletions esp-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ xtensa-lx = { version = "0.9.0", optional = true }
# IMPORTANT:
# Each supported device MUST have its PAC included below along with a
# corresponding feature.
esp32 = { git = "https://github.com/esp-rs/esp-pacs", rev = "bf5890e", features = ["critical-section", "rt"], optional = true }
esp32c2 = { git = "https://github.com/esp-rs/esp-pacs", rev = "bf5890e", features = ["critical-section", "rt"], optional = true }
esp32c3 = { git = "https://github.com/esp-rs/esp-pacs", rev = "bf5890e", features = ["critical-section", "rt"], optional = true }
esp32c6 = { git = "https://github.com/esp-rs/esp-pacs", rev = "bf5890e", features = ["critical-section", "rt"], optional = true }
esp32h2 = { git = "https://github.com/esp-rs/esp-pacs", rev = "bf5890e", features = ["critical-section", "rt"], optional = true }
esp32s2 = { git = "https://github.com/esp-rs/esp-pacs", rev = "bf5890e", features = ["critical-section", "rt"], optional = true }
esp32s3 = { git = "https://github.com/esp-rs/esp-pacs", rev = "bf5890e", features = ["critical-section", "rt"], optional = true }
esp32 = { version = "0.33.0", features = ["critical-section", "rt"], optional = true }
esp32c2 = { version = "0.22.0", features = ["critical-section", "rt"], optional = true }
esp32c3 = { version = "0.25.0", features = ["critical-section", "rt"], optional = true }
esp32c6 = { version = "0.16.0", features = ["critical-section", "rt"], optional = true }
esp32h2 = { version = "0.12.0", features = ["critical-section", "rt"], optional = true }
esp32s2 = { version = "0.24.0", features = ["critical-section", "rt"], optional = true }
esp32s3 = { version = "0.28.0", features = ["critical-section", "rt"], optional = true }

[target.'cfg(target_arch = "riscv32")'.dependencies]
esp-riscv-rt = { version = "0.9.0", path = "../esp-riscv-rt" }
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/gpio/lp_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn get_pin_reg(pin: u8) -> &'static crate::peripherals::lp_io::GPIO0 {
let lp_io = &*crate::peripherals::LP_IO::PTR;
let pin_ptr = (lp_io.gpio0().as_ptr()).add(pin as usize);

&*(pin_ptr as *const esp32c6::generic::Reg<esp32c6::lp_io::gpio0::GPIO0_SPEC>)
&*(pin_ptr as *const crate::peripherals::lp_io::GPIO0)
}
}

Expand Down
15 changes: 2 additions & 13 deletions esp-hal/src/gpio/rtc_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,13 @@ impl<'d, const PIN: u8> LowPowerOutputOpenDrain<'d, PIN> {
}
}

#[cfg(esp32s3)]
#[inline(always)]
fn get_pin_reg(pin: u8) -> &'static crate::peripherals::rtc_io::TOUCH_PAD0 {
unsafe {
let rtc_io = &*crate::peripherals::RTC_IO::PTR;
let pin_ptr = (rtc_io.touch_pad0().as_ptr()).add(pin as usize);

&*(pin_ptr as *const esp32s3::generic::Reg<esp32s3::rtc_io::touch_pad0::TOUCH_PAD0_SPEC>)
}
}

#[cfg(esp32s2)]
#[cfg(any(esp32s2, esp32s3))]
#[inline(always)]
fn get_pin_reg(pin: u8) -> &'static crate::peripherals::rtc_io::TOUCH_PAD {
unsafe {
let rtc_io = &*crate::peripherals::RTC_IO::PTR;
let pin_ptr = (rtc_io.touch_pad(0).as_ptr()).add(pin as usize);

&*(pin_ptr as *const esp32s2::generic::Reg<esp32s2::rtc_io::touch_pad::TOUCH_PAD_SPEC>)
&*(pin_ptr as *const crate::peripherals::rtc_io::TOUCH_PAD)
}
}
60 changes: 30 additions & 30 deletions esp-hal/src/soc/esp32s3/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,21 +405,21 @@ crate::gpio::gpio! {
}

crate::gpio::analog! {
( 0, 0, touch_pad0(), mux_sel, fun_sel, fun_ie, rue, rde)
( 1, 1, touch_pad1(), mux_sel, fun_sel, fun_ie, rue, rde)
( 2, 2, touch_pad2(), mux_sel, fun_sel, fun_ie, rue, rde)
( 3, 3, touch_pad3(), mux_sel, fun_sel, fun_ie, rue, rde)
( 4, 4, touch_pad4(), mux_sel, fun_sel, fun_ie, rue, rde)
( 5, 5, touch_pad5(), mux_sel, fun_sel, fun_ie, rue, rde)
( 6, 6, touch_pad6(), mux_sel, fun_sel, fun_ie, rue, rde)
( 7, 7, touch_pad7(), mux_sel, fun_sel, fun_ie, rue, rde)
( 8, 8, touch_pad8(), mux_sel, fun_sel, fun_ie, rue, rde)
( 9, 9, touch_pad9(), mux_sel, fun_sel, fun_ie, rue, rde)
(10, 10, touch_pad10(), mux_sel, fun_sel, fun_ie, rue, rde)
(11, 11, touch_pad11(), mux_sel, fun_sel, fun_ie, rue, rde)
(12, 12, touch_pad12(), mux_sel, fun_sel, fun_ie, rue, rde)
(13, 13, touch_pad13(), mux_sel, fun_sel, fun_ie, rue, rde)
(14, 14, touch_pad14(), mux_sel, fun_sel, fun_ie, rue, rde)
( 0, 0, touch_pad(0), mux_sel, fun_sel, fun_ie, rue, rde)
( 1, 1, touch_pad(1), mux_sel, fun_sel, fun_ie, rue, rde)
( 2, 2, touch_pad(2), mux_sel, fun_sel, fun_ie, rue, rde)
( 3, 3, touch_pad(3), mux_sel, fun_sel, fun_ie, rue, rde)
( 4, 4, touch_pad(4), mux_sel, fun_sel, fun_ie, rue, rde)
( 5, 5, touch_pad(5), mux_sel, fun_sel, fun_ie, rue, rde)
( 6, 6, touch_pad(6), mux_sel, fun_sel, fun_ie, rue, rde)
( 7, 7, touch_pad(7), mux_sel, fun_sel, fun_ie, rue, rde)
( 8, 8, touch_pad(8), mux_sel, fun_sel, fun_ie, rue, rde)
( 9, 9, touch_pad(9), mux_sel, fun_sel, fun_ie, rue, rde)
(10, 10, touch_pad(10), mux_sel, fun_sel, fun_ie, rue, rde)
(11, 11, touch_pad(11), mux_sel, fun_sel, fun_ie, rue, rde)
(12, 12, touch_pad(12), mux_sel, fun_sel, fun_ie, rue, rde)
(13, 13, touch_pad(13), mux_sel, fun_sel, fun_ie, rue, rde)
(14, 14, touch_pad(14), mux_sel, fun_sel, fun_ie, rue, rde)
(15, 15, xtal_32p_pad(), x32p_mux_sel, x32p_fun_sel, x32p_fun_ie, x32p_rue, x32p_rde)
(16, 16, xtal_32n_pad(), x32n_mux_sel, x32n_fun_sel, x32n_fun_ie, x32n_rue, x32n_rde)
(17, 17, pad_dac1(), pdac1_mux_sel,pdac1_fun_sel,pdac1_fun_ie, pdac1_rue, pdac1_rde)
Expand All @@ -430,21 +430,21 @@ crate::gpio::analog! {
}

crate::gpio::rtc_pins! {
( 0, 0, touch_pad0(), "", touch_pad0_hold, rue, rde)
( 1, 1, touch_pad1(), "", touch_pad1_hold, rue, rde)
( 2, 2, touch_pad2(), "", touch_pad2_hold, rue, rde)
( 3, 3, touch_pad3(), "", touch_pad3_hold, rue, rde)
( 4, 4, touch_pad4(), "", touch_pad4_hold, rue, rde)
( 5, 5, touch_pad5(), "", touch_pad5_hold, rue, rde)
( 6, 6, touch_pad6(), "", touch_pad6_hold, rue, rde)
( 7, 7, touch_pad7(), "", touch_pad7_hold, rue, rde)
( 8, 8, touch_pad8(), "", touch_pad8_hold, rue, rde)
( 9, 9, touch_pad9(), "", touch_pad9_hold, rue, rde)
(10, 10, touch_pad10(), "", touch_pad10_hold, rue, rde)
(11, 11, touch_pad11(), "", touch_pad11_hold, rue, rde)
(12, 12, touch_pad12(), "", touch_pad12_hold, rue, rde)
(13, 13, touch_pad13(), "", touch_pad13_hold, rue, rde)
(14, 14, touch_pad14(), "", touch_pad14_hold, rue, rde)
( 0, 0, touch_pad(0), "", touch_pad0_hold, rue, rde)
( 1, 1, touch_pad(1), "", touch_pad1_hold, rue, rde)
( 2, 2, touch_pad(2), "", touch_pad2_hold, rue, rde)
( 3, 3, touch_pad(3), "", touch_pad3_hold, rue, rde)
( 4, 4, touch_pad(4), "", touch_pad4_hold, rue, rde)
( 5, 5, touch_pad(5), "", touch_pad5_hold, rue, rde)
( 6, 6, touch_pad(6), "", touch_pad6_hold, rue, rde)
( 7, 7, touch_pad(7), "", touch_pad7_hold, rue, rde)
( 8, 8, touch_pad(8), "", touch_pad8_hold, rue, rde)
( 9, 9, touch_pad(9), "", touch_pad9_hold, rue, rde)
(10, 10, touch_pad(10), "", touch_pad10_hold, rue, rde)
(11, 11, touch_pad(11), "", touch_pad11_hold, rue, rde)
(12, 12, touch_pad(12), "", touch_pad12_hold, rue, rde)
(13, 13, touch_pad(13), "", touch_pad13_hold, rue, rde)
(14, 14, touch_pad(14), "", touch_pad14_hold, rue, rde)
(15, 15, xtal_32p_pad(), x32p_, x32p_hold, x32p_rue, x32p_rde)
(16, 16, xtal_32n_pad(), x32n_, x32n_hold, x32n_rue, x32n_rde)
(17, 17, pad_dac1(), pdac1_, pdac1_hold, pdac1_rue, pdac1_rde)
Expand Down
18 changes: 7 additions & 11 deletions esp-hal/src/timer/timg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,13 @@ where
.modify(|_, w| w.level_int_en().set_bit());

self.register_block()
.int_ena_timers()
.int_ena()
.modify(|_, w| w.t(self.timer_number()).bit(state));
}

fn clear_interrupt(&self) {
self.register_block()
.int_clr_timers()
.int_clr()
.write(|w| w.t(self.timer_number()).clear_bit_by_one());
}

Expand All @@ -512,7 +512,7 @@ where

fn is_interrupt_set(&self) -> bool {
self.register_block()
.int_raw_timers()
.int_raw()
.read()
.t(self.timer_number())
.bit_is_set()
Expand Down Expand Up @@ -707,19 +707,19 @@ where
.modify(|_, w| w.level_int_en().set_bit());

self.register_block()
.int_ena_timers()
.int_ena()
.modify(|_, w| w.t(T).set_bit());
}

fn unlisten(&self) {
self.register_block()
.int_ena_timers()
.int_ena()
.modify(|_, w| w.t(T).clear_bit());
}

fn clear_interrupt(&self) {
self.register_block()
.int_clr_timers()
.int_clr()
.write(|w| w.t(T).clear_bit_by_one());
}

Expand Down Expand Up @@ -752,11 +752,7 @@ where
}

fn is_interrupt_set(&self) -> bool {
self.register_block()
.int_raw_timers()
.read()
.t(T)
.bit_is_set()
self.register_block().int_raw().read().t(T).bit_is_set()
}

fn set_divider(&self, divider: u16) {
Expand Down
9 changes: 3 additions & 6 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ use crate::{
gpio::{InputPin, InputSignal, OutputPin, OutputSignal},
interrupt::InterruptHandler,
peripheral::Peripheral,
peripherals::{
uart0::{fifo::FIFO_SPEC, RegisterBlock},
Interrupt,
},
peripherals::{uart0::RegisterBlock, Interrupt},
private::Internal,
system::PeripheralClockControl,
Blocking,
Expand Down Expand Up @@ -654,7 +651,7 @@ where
if T::get_rx_fifo_count() > 0 {
let value = unsafe {
let fifo = (T::register_block().fifo().as_ptr() as *mut u8).offset(offset)
as *mut crate::peripherals::generic::Reg<FIFO_SPEC>;
as *mut crate::peripherals::uart0::FIFO;
(*fifo).read().rxfifo_rd_byte().bits()
};

Expand All @@ -674,7 +671,7 @@ where
while T::get_rx_fifo_count() > 0 && count < buf.len() {
let value = unsafe {
let fifo = (T::register_block().fifo().as_ptr() as *mut u8).offset(offset)
as *mut crate::peripherals::generic::Reg<FIFO_SPEC>;
as *mut crate::peripherals::uart0::FIFO;
(*fifo).read().rxfifo_rd_byte().bits()
};
buf[count] = value;
Expand Down

0 comments on commit bac6bfd

Please sign in to comment.