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)
- 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)
- Changed the various `ConfigError` variant names to use a consistent word order. (#3782)
### 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);
```
## `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) {
DPORT::regs().wifi_clk_en().modify(|r, w| unsafe {
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) {
// `periph_ll_wifi_module_enable_clk_clear_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) {
// `periph_ll_wifi_module_enable_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) {
// `periph_ll_wifi_module_enable_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) {
// `periph_ll_wifi_module_enable_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) {
// `periph_ll_wifi_module_enable_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));
}
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_wifi(en: bool) {
MODEM_SYSCON::regs().clk_conf1().modify(|_, w| {
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) {
MODEM_SYSCON::regs().clk_conf().modify(|_, w| {
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());
}
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(en: bool) {
MODEM_SYSCON::regs().clk_conf().modify(|_, w| {
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));
}
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_bt(en: bool) {
ble_ieee802154_clock_enable(en);
}
#[cfg_attr(not(feature = "unstable"), expect(unused))]
pub(super) fn enable_ieee802154(en: bool) {
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) {
// `periph_ll_wifi_module_enable_clk_clear_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) {
// `periph_ll_wifi_module_enable_clk_clear_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) {
// `periph_ll_wifi_module_enable_clk_clear_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)]
use crate::peripherals::BT;
#[cfg(ieee802154)]
#[cfg(all(feature = "unstable", ieee802154))]
use crate::peripherals::IEEE802154;
#[cfg(wifi)]
use crate::peripherals::WIFI;

View File

@ -248,7 +248,7 @@ impl BusTimeout {
if raw <= property!("i2c_master.max_bus_timeout") {
Ok(Some(raw))
} else {
Err(ConfigError::TimeoutInvalid)
Err(ConfigError::TimeoutTooLong)
}
}
}
@ -320,7 +320,7 @@ impl FsmTimeout {
#[instability::unstable]
pub fn new(value: u8) -> Result<Self, ConfigError> {
if value > Self::FSM_TIMEOUT_MAX {
return Err(ConfigError::TimeoutInvalid);
return Err(ConfigError::TimeoutTooLong);
}
Ok(Self { value })
@ -434,10 +434,10 @@ impl core::fmt::Display for Error {
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum ConfigError {
/// Provided bus frequency is invalid for the current configuration.
FrequencyInvalid,
/// Provided timeout is invalid for the current configuration.
TimeoutInvalid,
/// Provided bus frequency is not valid for the current configuration.
FrequencyOutOfRange,
/// Provided timeout is not valid for the current configuration.
TimeoutTooLong,
}
impl core::error::Error for ConfigError {}
@ -445,11 +445,11 @@ impl core::error::Error for ConfigError {}
impl core::fmt::Display for ConfigError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
ConfigError::FrequencyInvalid => write!(
ConfigError::FrequencyOutOfRange => write!(
f,
"Provided bus frequency is invalid for the current configuration"
),
ConfigError::TimeoutInvalid => write!(
ConfigError::TimeoutTooLong => write!(
f,
"Provided timeout is invalid for the current configuration"
),
@ -1408,7 +1408,7 @@ fn configure_clock(
#[cfg(not(esp32))]
let scl_wait_high_period = scl_wait_high_period
.try_into()
.map_err(|_| ConfigError::FrequencyInvalid)?;
.map_err(|_| ConfigError::FrequencyOutOfRange)?;
register_block.scl_high_period().write(|w| {
#[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
{
return Err(ConfigError::UnsupportedFrequency);
return Err(ConfigError::FrequencyOutOfRange);
}
Ok(())
@ -633,8 +633,8 @@ struct SpiPinGuard {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ConfigError {
/// The requested frequency is not supported.
UnsupportedFrequency,
/// The requested frequency is not in the supported range.
FrequencyOutOfRange,
}
impl core::error::Error for ConfigError {}
@ -642,8 +642,8 @@ impl core::error::Error for ConfigError {}
impl core::fmt::Display for ConfigError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
ConfigError::UnsupportedFrequency => {
write!(f, "The requested frequency is not supported")
ConfigError::FrequencyOutOfRange => {
write!(f, "The requested frequency is not in the supported range")
}
}
}
@ -1131,7 +1131,7 @@ where
///
/// If frequency passed in config exceeds
/// # {max_frequency}
/// or is below 70kHz, [`ConfigError::UnsupportedFrequency`] error will be returned.
/// or is below 70kHz, [`ConfigError::FrequencyOutOfRange`] error will be returned.
///
/// ## Example
///

View File

@ -349,7 +349,7 @@ impl Config {
// Max supported baud rate is 5Mbaud
if self.baudrate == 0 || self.baudrate > 5_000_000 {
return Err(ConfigError::UnsupportedBaudrate);
return Err(ConfigError::BaudrateNotSupported);
}
Ok(())
}
@ -517,7 +517,7 @@ pub enum ConfigError {
/// The requested baud rate is not achievable.
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
UnachievableBaudrate,
BaudrateNotAchievable,
/// 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 user has specified an exact baud rate or with some percentage of deviation to the
/// 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(not(esp32), doc = "1023")]
/// ).
UnsupportedTimeout,
TimeoutTooLong,
/// The requested RX FIFO threshold exceeds the maximum value (127 bytes).
UnsupportedRxFifoThreshold,
RxFifoThresholdNotSupported,
/// The requested TX FIFO threshold exceeds the maximum value (127 bytes).
UnsupportedTxFifoThreshold,
TxFifoThresholdNotSupported,
}
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 {
match self {
#[cfg(feature = "unstable")]
ConfigError::UnachievableBaudrate => {
ConfigError::BaudrateNotAchievable => {
write!(f, "The requested baud rate is not achievable")
}
ConfigError::UnsupportedBaudrate => {
ConfigError::BaudrateNotSupported => {
write!(f, "The requested baud rate is not supported")
}
ConfigError::UnsupportedTimeout => write!(f, "The requested timeout is not supported"),
ConfigError::UnsupportedRxFifoThreshold => {
ConfigError::TimeoutTooLong => write!(f, "The requested timeout is not supported"),
ConfigError::RxFifoThresholdNotSupported => {
write!(f, "The requested RX FIFO threshold is not supported")
}
ConfigError::UnsupportedTxFifoThreshold => {
ConfigError::TxFifoThresholdNotSupported => {
write!(f, "The requested TX FIFO threshold is not supported")
}
}
@ -2819,7 +2819,7 @@ impl Info {
/// [`Info::RX_FIFO_MAX_THRHD`].
fn set_rx_fifo_full_threshold(&self, threshold: u16) -> Result<(), ConfigError> {
if threshold > Self::RX_FIFO_MAX_THRHD {
return Err(ConfigError::UnsupportedRxFifoThreshold);
return Err(ConfigError::RxFifoThresholdNotSupported);
}
self.regs()
@ -2843,7 +2843,7 @@ impl Info {
/// [`Info::TX_FIFO_MAX_THRHD`].
fn set_tx_fifo_empty_threshold(&self, threshold: u16) -> Result<(), ConfigError> {
if threshold > Self::TX_FIFO_MAX_THRHD {
return Err(ConfigError::UnsupportedTxFifoThreshold);
return Err(ConfigError::TxFifoThresholdNotSupported);
}
self.regs()
@ -2887,7 +2887,7 @@ impl Info {
let timeout_reg = timeout as u16 * _symbol_len as u16;
if timeout_reg > MAX_THRHD {
return Err(ConfigError::UnsupportedTimeout);
return Err(ConfigError::TimeoutTooLong);
}
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
// exactly the same
if deviation > 1_u32 {
return Err(ConfigError::UnachievableBaudrate);
return Err(ConfigError::BaudrateNotAchievable);
}
}
BaudrateTolerance::ErrorPercent(percent) => {
@ -3183,7 +3183,7 @@ impl Info {
* 100)
/ actual_baud;
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();
match self {
Package::EspHal => {
// Make sure no additional features (e.g. no "unstable") still compiles:
cases.push(vec![]);
}
Package::EspWifi => {
// Minimal set of features that when enabled _should_ still compile:
cases.push(vec![