Remove unused files, clean up some #[cfg]s and #[allow] attributes (#1494)

* Remove unnecessary files

* Use config symbols instead of feature names for remaining `cfg` attrs

* Clean up some attributes/TODO comments in UART driver
This commit is contained in:
Jesse Braham 2024-04-22 16:29:33 +00:00 committed by GitHub
parent 4d2ab5bc8f
commit c4383196fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 36 deletions

View File

@ -1,3 +0,0 @@
{
"recommendations": ["rust-lang.rust-analyzer", "tamasfe.even-better-toml"]
}

View File

@ -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,
}

View File

@ -187,7 +187,7 @@ pub fn get_status(core: Cpu) -> u128 {
}
};
#[cfg(feature = "esp32s3")]
#[cfg(esp32s3)]
let status = match core {
Cpu::ProCpu => {
status

View File

@ -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()

View File

@ -465,12 +465,8 @@ where
}
fn read_byte(&mut self) -> nb::Result<u8, Error> {
#[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()
});

View File

@ -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