diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 201e87c92..000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "recommendations": ["rust-lang.rust-analyzer", "tamasfe.even-better-toml"] -} diff --git a/esp-hal/src/aes/mod.rs b/esp-hal/src/aes/mod.rs index 65ac29370..cfa6e9c47 100644 --- a/esp-hal/src/aes/mod.rs +++ b/esp-hal/src/aes/mod.rs @@ -124,7 +124,7 @@ pub enum Key { /// 128-bit AES key Key16([u8; 16]), /// 192-bit AES key - #[cfg(any(feature = "esp32", feature = "esp32s2"))] + #[cfg(any(esp32, esp32s2))] Key24([u8; 24]), /// 256-bit AES key Key32([u8; 32]), @@ -137,7 +137,7 @@ impl From<[u8; 16]> for Key { } } -#[cfg(any(feature = "esp32", feature = "esp32s2"))] +#[cfg(any(esp32, esp32s2))] impl From<[u8; 24]> for Key { fn from(key: [u8; 24]) -> Self { Key::Key24(key) @@ -155,7 +155,7 @@ impl Key { fn as_slice(&self) -> &[u8] { match self { Key::Key16(ref key) => key, - #[cfg(any(feature = "esp32", feature = "esp32s2"))] + #[cfg(any(esp32, esp32s2))] Key::Key24(ref key) => key, Key::Key32(ref key) => key, } diff --git a/esp-hal/src/interrupt/xtensa.rs b/esp-hal/src/interrupt/xtensa.rs index db81a6514..039cd434b 100644 --- a/esp-hal/src/interrupt/xtensa.rs +++ b/esp-hal/src/interrupt/xtensa.rs @@ -187,7 +187,7 @@ pub fn get_status(core: Cpu) -> u128 { } }; - #[cfg(feature = "esp32s3")] + #[cfg(esp32s3)] let status = match core { Cpu::ProCpu => { status diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 1ceb42bca..ccee14bd3 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -2589,7 +2589,7 @@ pub trait Instance: crate::private::Sealed { fn ch_bus_freq(&mut self, frequency: HertzU32, clocks: &Clocks) { // Disable clock source - #[cfg(not(any(feature = "esp32", feature = "esp32s2")))] + #[cfg(not(any(esp32, esp32s2)))] self.register_block().clk_gate().modify(|_, w| { w.clk_en() .clear_bit() @@ -2603,7 +2603,7 @@ pub trait Instance: crate::private::Sealed { self.setup(frequency, clocks); // Enable clock source - #[cfg(not(any(feature = "esp32", feature = "esp32s2")))] + #[cfg(not(any(esp32, esp32s2)))] self.register_block().clk_gate().modify(|_, w| { w.clk_en() .set_bit() diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index 7c24784c8..63f301ad6 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -465,12 +465,8 @@ where } fn read_byte(&mut self) -> nb::Result { - #[allow(unused_variables)] - let offset = 0; - - // on ESP32-S2 we need to use PeriBus2 to read the FIFO - #[cfg(esp32s2)] - let offset = 0x20c00000; + // On the ESP32-S2 we need to use PeriBus2 to read the FIFO: + let offset = if cfg!(esp32s2) { 0x20C00000 } else { 0 }; if T::get_rx_fifo_count() > 0 { let value = unsafe { @@ -488,12 +484,8 @@ where /// Read all available bytes from the RX FIFO into the provided buffer and /// returns the number of read bytes. Never blocks pub fn drain_fifo(&mut self, buf: &mut [u8]) -> usize { - #[allow(unused_variables)] - let offset = 0; - - // on ESP32-S2 we need to use PeriBus2 to read the FIFO - #[cfg(esp32s2)] - let offset = 0x20c00000; + // On the ESP32-S2 we need to use PeriBus2 to read the FIFO: + let offset = if cfg!(esp32s2) { 0x20C00000 } else { 0 }; let mut count = 0; while T::get_rx_fifo_count() > 0 && count < buf.len() { @@ -982,7 +974,11 @@ where .uart1_sclk_div_num() .bits(clk_div as u8 - 1) .uart1_sclk_sel() - .bits(0x3) // TODO: this probably shouldn't be hard-coded + .bits(match clock_source { + ClockSource::Apb => 1, + ClockSource::RcFast => 2, + ClockSource::Xtal => 3, + }) .uart1_sclk_en() .set_bit() }); diff --git a/pre-commit b/pre-commit deleted file mode 100755 index d6794895c..000000000 --- a/pre-commit +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# Exit immediately on first non-zero status from a command in the script. -set -o errexit - -# Ensure all tools being used are available. -command -v "cargo" >/dev/null 2>&1 || { echo >&2 "The 'cargo' command is not installed, exiting"; exit 1; } -command -v "rustfmt" >/dev/null 2>&1 || { echo >&2 "The 'rustfmt' command is not installed, exiting"; exit 1; } - -# Check the formatting of all Rust code for every package. -for manifest in "esp"*/Cargo.toml; do - # Check package is correctly formatted. - cargo fmt --all --manifest-path "${manifest}" -- --check -done