Fix warnings, lint esp-hal without unstable (#3782)

* Prevent warnings

* Test esp-hal with no features enabled

* Update wording of error variants

* Re-generate semver baseline
This commit is contained in:
Dániel Buga 2025-07-11 09:14:59 +02:00 committed by GitHub
parent c907645422
commit 547afd5cb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 71 additions and 33 deletions

View File

@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Increase ESP32 DRAM memory region by 16K (#3703) - Increase ESP32 DRAM memory region by 16K (#3703)
- The I2C async interrupt handler is now placed into IRAM (#3722) - The I2C async interrupt handler is now placed into IRAM (#3722)
- Adjusted ESP32-S2 and ESP-S3 memory region lengths to reflect those defined in ESP-IDF. (#3709) - Adjusted ESP32-S2 and ESP-S3 memory region lengths to reflect those defined in ESP-IDF. (#3709)
- Changed the various `ConfigError` variant names to use a consistent word order. (#3782)
### Fixed ### Fixed

View File

@ -67,3 +67,22 @@ Additionally, the `configure` methods have been renamed to `configure_tx` and
-}; -};
+ let rx_channel = rmt.channel2.configure_rx(pin, rx_config); + let rx_channel = rmt.channel2.configure_rx(pin, rx_config);
``` ```
## `ConfigError` variants have been changed
### SPI master
- `UnsupportedFrequency` -> `FrequencyOutOfRange`
### UART
- `UnachievableBaudrate` -> `BaudrateNotAchievable`
- `UnsupportedBaudrate` -> `BaudrateNotSupported`
- `UnsupportedTimeout` -> `TimeoutTooLong`
- `UnsupportedRxFifoThreshold` -> `RxFifoThresholdNotSupported`
- `UnsupportedTxFifoThreshold` -> `TxFifoThresholdNotSupported`
### I2C master
- `FrequencyInvalid` -> `FrequencyOutOfRange`
- `TimeoutInvalid` -> `TimeoutTooLong`

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -230,6 +230,7 @@ pub(super) fn enable_phy(enable: bool) {
}); });
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(enable: bool) { pub(super) fn enable_bt(enable: bool) {
DPORT::regs().wifi_clk_en().modify(|r, w| unsafe { DPORT::regs().wifi_clk_en().modify(|r, w| unsafe {
if enable { if enable {
@ -240,6 +241,7 @@ pub(super) fn enable_bt(enable: bool) {
}); });
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_wifi(enable: bool) { pub(super) fn enable_wifi(enable: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst` // `periph_ll_wifi_module_enable_clk_clear_rst`
// `periph_ll_wifi_module_disable_clk_set_rst` // `periph_ll_wifi_module_disable_clk_set_rst`

View File

@ -148,11 +148,13 @@ pub(super) fn enable_phy(enable: bool) {
}); });
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(_: bool) { pub(super) fn enable_bt(_: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst`, no-op // `periph_ll_wifi_module_enable_clk_clear_rst`, no-op
// `periph_ll_wifi_module_disable_clk_clear_rst`, no-op // `periph_ll_wifi_module_disable_clk_clear_rst`, no-op
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_wifi(_: bool) { pub(super) fn enable_wifi(_: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst`, no-op // `periph_ll_wifi_module_enable_clk_clear_rst`, no-op
// `periph_ll_wifi_module_disable_clk_clear_rst`, no-op // `periph_ll_wifi_module_disable_clk_clear_rst`, no-op

View File

@ -182,11 +182,13 @@ pub(super) fn enable_phy(enable: bool) {
}); });
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_wifi(_: bool) { pub(super) fn enable_wifi(_: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst`, no-op // `periph_ll_wifi_module_enable_clk_clear_rst`, no-op
// `periph_ll_wifi_module__clk_clear_rst`, no-op // `periph_ll_wifi_module__clk_clear_rst`, no-op
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(_: bool) { pub(super) fn enable_bt(_: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst`, no-op // `periph_ll_wifi_module_enable_clk_clear_rst`, no-op
// `periph_ll_wifi_module__clk_clear_rst`, no-op // `periph_ll_wifi_module__clk_clear_rst`, no-op

View File

@ -207,6 +207,7 @@ pub(super) fn enable_phy(en: bool) {
.modify(|_, w| w.clk_i2c_mst_sel_160m().bit(en)); .modify(|_, w| w.clk_i2c_mst_sel_160m().bit(en));
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_wifi(en: bool) { pub(super) fn enable_wifi(en: bool) {
MODEM_SYSCON::regs().clk_conf1().modify(|_, w| { MODEM_SYSCON::regs().clk_conf1().modify(|_, w| {
w.clk_wifi_apb_en().bit(en); w.clk_wifi_apb_en().bit(en);
@ -232,6 +233,7 @@ pub(super) fn enable_wifi(en: bool) {
}); });
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_ieee802154(en: bool) { pub(super) fn enable_ieee802154(en: bool) {
MODEM_SYSCON::regs().clk_conf().modify(|_, w| { MODEM_SYSCON::regs().clk_conf().modify(|_, w| {
w.clk_zb_apb_en().bit(en); w.clk_zb_apb_en().bit(en);
@ -261,6 +263,7 @@ pub(super) fn enable_ieee802154(en: bool) {
.modify(|_, w| w.clk_coex_en().set_bit()); .modify(|_, w| w.clk_coex_en().set_bit());
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(en: bool) { pub(super) fn enable_bt(en: bool) {
MODEM_SYSCON::regs().clk_conf().modify(|_, w| { MODEM_SYSCON::regs().clk_conf().modify(|_, w| {
w.clk_etm_en().bit(en); w.clk_etm_en().bit(en);

View File

@ -282,10 +282,12 @@ fn ble_ieee802154_clock_enable(en: bool) {
.modify(|_, w| w.clk_coex_en().bit(en)); .modify(|_, w| w.clk_coex_en().bit(en));
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(en: bool) { pub(super) fn enable_bt(en: bool) {
ble_ieee802154_clock_enable(en); ble_ieee802154_clock_enable(en);
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_ieee802154(en: bool) { pub(super) fn enable_ieee802154(en: bool) {
ble_ieee802154_clock_enable(en); ble_ieee802154_clock_enable(en);
} }

View File

@ -57,6 +57,7 @@ pub(super) fn enable_phy(enable: bool) {
}); });
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_wifi(enable: bool) { pub(super) fn enable_wifi(enable: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst` // `periph_ll_wifi_module_enable_clk_clear_rst`
// `periph_ll_wifi_module_disable_clk_set_rst` // `periph_ll_wifi_module_disable_clk_set_rst`

View File

@ -40,11 +40,13 @@ pub(super) fn enable_phy(enable: bool) {
}); });
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(_: bool) { pub(super) fn enable_bt(_: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst`. does nothing // `periph_ll_wifi_module_enable_clk_clear_rst`. does nothing
// `periph_ll_wifi_module_disable_clk_set_rst`. does nothing // `periph_ll_wifi_module_disable_clk_set_rst`. does nothing
} }
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_wifi(_: bool) { pub(super) fn enable_wifi(_: bool) {
// `periph_ll_wifi_module_enable_clk_clear_rst`. does nothing // `periph_ll_wifi_module_enable_clk_clear_rst`. does nothing
// `periph_ll_wifi_module_disable_clk_set_rst`. does nothing // `periph_ll_wifi_module_disable_clk_set_rst`. does nothing

View File

@ -48,7 +48,7 @@ use core::{cell::Cell, marker::PhantomData};
#[cfg(bt)] #[cfg(bt)]
use crate::peripherals::BT; use crate::peripherals::BT;
#[cfg(ieee802154)] #[cfg(all(feature = "unstable", ieee802154))]
use crate::peripherals::IEEE802154; use crate::peripherals::IEEE802154;
#[cfg(wifi)] #[cfg(wifi)]
use crate::peripherals::WIFI; use crate::peripherals::WIFI;

View File

@ -248,7 +248,7 @@ impl BusTimeout {
if raw <= property!("i2c_master.max_bus_timeout") { if raw <= property!("i2c_master.max_bus_timeout") {
Ok(Some(raw)) Ok(Some(raw))
} else { } else {
Err(ConfigError::TimeoutInvalid) Err(ConfigError::TimeoutTooLong)
} }
} }
} }
@ -320,7 +320,7 @@ impl FsmTimeout {
#[instability::unstable] #[instability::unstable]
pub fn new(value: u8) -> Result<Self, ConfigError> { pub fn new(value: u8) -> Result<Self, ConfigError> {
if value > Self::FSM_TIMEOUT_MAX { if value > Self::FSM_TIMEOUT_MAX {
return Err(ConfigError::TimeoutInvalid); return Err(ConfigError::TimeoutTooLong);
} }
Ok(Self { value }) Ok(Self { value })
@ -434,10 +434,10 @@ impl core::fmt::Display for Error {
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive] #[non_exhaustive]
pub enum ConfigError { pub enum ConfigError {
/// Provided bus frequency is invalid for the current configuration. /// Provided bus frequency is not valid for the current configuration.
FrequencyInvalid, FrequencyOutOfRange,
/// Provided timeout is invalid for the current configuration. /// Provided timeout is not valid for the current configuration.
TimeoutInvalid, TimeoutTooLong,
} }
impl core::error::Error for ConfigError {} impl core::error::Error for ConfigError {}
@ -445,11 +445,11 @@ impl core::error::Error for ConfigError {}
impl core::fmt::Display for ConfigError { impl core::fmt::Display for ConfigError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self { match self {
ConfigError::FrequencyInvalid => write!( ConfigError::FrequencyOutOfRange => write!(
f, f,
"Provided bus frequency is invalid for the current configuration" "Provided bus frequency is invalid for the current configuration"
), ),
ConfigError::TimeoutInvalid => write!( ConfigError::TimeoutTooLong => write!(
f, f,
"Provided timeout is invalid for the current configuration" "Provided timeout is invalid for the current configuration"
), ),
@ -1408,7 +1408,7 @@ fn configure_clock(
#[cfg(not(esp32))] #[cfg(not(esp32))]
let scl_wait_high_period = scl_wait_high_period let scl_wait_high_period = scl_wait_high_period
.try_into() .try_into()
.map_err(|_| ConfigError::FrequencyInvalid)?; .map_err(|_| ConfigError::FrequencyOutOfRange)?;
register_block.scl_high_period().write(|w| { register_block.scl_high_period().write(|w| {
#[cfg(not(esp32))] // ESP32 does not have a wait_high field #[cfg(not(esp32))] // ESP32 does not have a wait_high field

View File

@ -602,7 +602,7 @@ impl Config {
if self.frequency < source_freq / max_divider || self.frequency > source_freq / min_divider if self.frequency < source_freq / max_divider || self.frequency > source_freq / min_divider
{ {
return Err(ConfigError::UnsupportedFrequency); return Err(ConfigError::FrequencyOutOfRange);
} }
Ok(()) Ok(())
@ -633,8 +633,8 @@ struct SpiPinGuard {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ConfigError { pub enum ConfigError {
/// The requested frequency is not supported. /// The requested frequency is not in the supported range.
UnsupportedFrequency, FrequencyOutOfRange,
} }
impl core::error::Error for ConfigError {} impl core::error::Error for ConfigError {}
@ -642,8 +642,8 @@ impl core::error::Error for ConfigError {}
impl core::fmt::Display for ConfigError { impl core::fmt::Display for ConfigError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self { match self {
ConfigError::UnsupportedFrequency => { ConfigError::FrequencyOutOfRange => {
write!(f, "The requested frequency is not supported") write!(f, "The requested frequency is not in the supported range")
} }
} }
} }
@ -1131,7 +1131,7 @@ where
/// ///
/// If frequency passed in config exceeds /// If frequency passed in config exceeds
/// # {max_frequency} /// # {max_frequency}
/// or is below 70kHz, [`ConfigError::UnsupportedFrequency`] error will be returned. /// or is below 70kHz, [`ConfigError::FrequencyOutOfRange`] error will be returned.
/// ///
/// ## Example /// ## Example
/// ///

View File

@ -349,7 +349,7 @@ impl Config {
// Max supported baud rate is 5Mbaud // Max supported baud rate is 5Mbaud
if self.baudrate == 0 || self.baudrate > 5_000_000 { if self.baudrate == 0 || self.baudrate > 5_000_000 {
return Err(ConfigError::UnsupportedBaudrate); return Err(ConfigError::BaudrateNotSupported);
} }
Ok(()) Ok(())
} }
@ -517,7 +517,7 @@ pub enum ConfigError {
/// The requested baud rate is not achievable. /// The requested baud rate is not achievable.
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
UnachievableBaudrate, BaudrateNotAchievable,
/// The requested baud rate is not supported. /// The requested baud rate is not supported.
/// ///
@ -525,19 +525,19 @@ pub enum ConfigError {
/// * the baud rate exceeds 5MBaud or is equal to zero. /// * the baud rate exceeds 5MBaud or is equal to zero.
/// * the user has specified an exact baud rate or with some percentage of deviation to the /// * the user has specified an exact baud rate or with some percentage of deviation to the
/// desired value, and the driver cannot reach this speed. /// desired value, and the driver cannot reach this speed.
UnsupportedBaudrate, BaudrateNotSupported,
/// The requested timeout exceeds the maximum value ( /// The requested timeout exceeds the maximum value (
#[cfg_attr(esp32, doc = "127")] #[cfg_attr(esp32, doc = "127")]
#[cfg_attr(not(esp32), doc = "1023")] #[cfg_attr(not(esp32), doc = "1023")]
/// ). /// ).
UnsupportedTimeout, TimeoutTooLong,
/// The requested RX FIFO threshold exceeds the maximum value (127 bytes). /// The requested RX FIFO threshold exceeds the maximum value (127 bytes).
UnsupportedRxFifoThreshold, RxFifoThresholdNotSupported,
/// The requested TX FIFO threshold exceeds the maximum value (127 bytes). /// The requested TX FIFO threshold exceeds the maximum value (127 bytes).
UnsupportedTxFifoThreshold, TxFifoThresholdNotSupported,
} }
impl core::error::Error for ConfigError {} impl core::error::Error for ConfigError {}
@ -546,17 +546,17 @@ impl core::fmt::Display for ConfigError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self { match self {
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
ConfigError::UnachievableBaudrate => { ConfigError::BaudrateNotAchievable => {
write!(f, "The requested baud rate is not achievable") write!(f, "The requested baud rate is not achievable")
} }
ConfigError::UnsupportedBaudrate => { ConfigError::BaudrateNotSupported => {
write!(f, "The requested baud rate is not supported") write!(f, "The requested baud rate is not supported")
} }
ConfigError::UnsupportedTimeout => write!(f, "The requested timeout is not supported"), ConfigError::TimeoutTooLong => write!(f, "The requested timeout is not supported"),
ConfigError::UnsupportedRxFifoThreshold => { ConfigError::RxFifoThresholdNotSupported => {
write!(f, "The requested RX FIFO threshold is not supported") write!(f, "The requested RX FIFO threshold is not supported")
} }
ConfigError::UnsupportedTxFifoThreshold => { ConfigError::TxFifoThresholdNotSupported => {
write!(f, "The requested TX FIFO threshold is not supported") write!(f, "The requested TX FIFO threshold is not supported")
} }
} }
@ -2819,7 +2819,7 @@ impl Info {
/// [`Info::RX_FIFO_MAX_THRHD`]. /// [`Info::RX_FIFO_MAX_THRHD`].
fn set_rx_fifo_full_threshold(&self, threshold: u16) -> Result<(), ConfigError> { fn set_rx_fifo_full_threshold(&self, threshold: u16) -> Result<(), ConfigError> {
if threshold > Self::RX_FIFO_MAX_THRHD { if threshold > Self::RX_FIFO_MAX_THRHD {
return Err(ConfigError::UnsupportedRxFifoThreshold); return Err(ConfigError::RxFifoThresholdNotSupported);
} }
self.regs() self.regs()
@ -2843,7 +2843,7 @@ impl Info {
/// [`Info::TX_FIFO_MAX_THRHD`]. /// [`Info::TX_FIFO_MAX_THRHD`].
fn set_tx_fifo_empty_threshold(&self, threshold: u16) -> Result<(), ConfigError> { fn set_tx_fifo_empty_threshold(&self, threshold: u16) -> Result<(), ConfigError> {
if threshold > Self::TX_FIFO_MAX_THRHD { if threshold > Self::TX_FIFO_MAX_THRHD {
return Err(ConfigError::UnsupportedTxFifoThreshold); return Err(ConfigError::TxFifoThresholdNotSupported);
} }
self.regs() self.regs()
@ -2887,7 +2887,7 @@ impl Info {
let timeout_reg = timeout as u16 * _symbol_len as u16; let timeout_reg = timeout as u16 * _symbol_len as u16;
if timeout_reg > MAX_THRHD { if timeout_reg > MAX_THRHD {
return Err(ConfigError::UnsupportedTimeout); return Err(ConfigError::TimeoutTooLong);
} }
cfg_if::cfg_if! { cfg_if::cfg_if! {
@ -3175,7 +3175,7 @@ impl Info {
// We tolerate deviation of 1% from the desired baud value, as it never will be // We tolerate deviation of 1% from the desired baud value, as it never will be
// exactly the same // exactly the same
if deviation > 1_u32 { if deviation > 1_u32 {
return Err(ConfigError::UnachievableBaudrate); return Err(ConfigError::BaudrateNotAchievable);
} }
} }
BaudrateTolerance::ErrorPercent(percent) => { BaudrateTolerance::ErrorPercent(percent) => {
@ -3183,7 +3183,7 @@ impl Info {
* 100) * 100)
/ actual_baud; / actual_baud;
if deviation > percent as u32 { if deviation > percent as u32 {
return Err(ConfigError::UnachievableBaudrate); return Err(ConfigError::BaudrateNotAchievable);
} }
} }
_ => {} _ => {}

View File

@ -250,6 +250,10 @@ impl Package {
let mut cases = Vec::new(); let mut cases = Vec::new();
match self { match self {
Package::EspHal => {
// Make sure no additional features (e.g. no "unstable") still compiles:
cases.push(vec![]);
}
Package::EspWifi => { Package::EspWifi => {
// Minimal set of features that when enabled _should_ still compile: // Minimal set of features that when enabled _should_ still compile:
cases.push(vec![ cases.push(vec![