diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index df6768f50..b963be169 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -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 diff --git a/esp-hal/MIGRATING-1.0.0-beta.1.md b/esp-hal/MIGRATING-1.0.0-beta.1.md index 777cdbb55..0634817b5 100644 --- a/esp-hal/MIGRATING-1.0.0-beta.1.md +++ b/esp-hal/MIGRATING-1.0.0-beta.1.md @@ -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` diff --git a/esp-hal/api-baseline/esp32.json.gz b/esp-hal/api-baseline/esp32.json.gz index e96a5537f..faf69ab22 100644 Binary files a/esp-hal/api-baseline/esp32.json.gz and b/esp-hal/api-baseline/esp32.json.gz differ diff --git a/esp-hal/api-baseline/esp32c2.json.gz b/esp-hal/api-baseline/esp32c2.json.gz index 217237df5..9a12a8e54 100644 Binary files a/esp-hal/api-baseline/esp32c2.json.gz and b/esp-hal/api-baseline/esp32c2.json.gz differ diff --git a/esp-hal/api-baseline/esp32c3.json.gz b/esp-hal/api-baseline/esp32c3.json.gz index 16ad482b7..665c6818e 100644 Binary files a/esp-hal/api-baseline/esp32c3.json.gz and b/esp-hal/api-baseline/esp32c3.json.gz differ diff --git a/esp-hal/api-baseline/esp32c6.json.gz b/esp-hal/api-baseline/esp32c6.json.gz index 7297f8406..40cf104db 100644 Binary files a/esp-hal/api-baseline/esp32c6.json.gz and b/esp-hal/api-baseline/esp32c6.json.gz differ diff --git a/esp-hal/api-baseline/esp32h2.json.gz b/esp-hal/api-baseline/esp32h2.json.gz index f34ff1b57..a2a5db2a5 100644 Binary files a/esp-hal/api-baseline/esp32h2.json.gz and b/esp-hal/api-baseline/esp32h2.json.gz differ diff --git a/esp-hal/api-baseline/esp32s2.json.gz b/esp-hal/api-baseline/esp32s2.json.gz index ab6d1f8d7..537731838 100644 Binary files a/esp-hal/api-baseline/esp32s2.json.gz and b/esp-hal/api-baseline/esp32s2.json.gz differ diff --git a/esp-hal/api-baseline/esp32s3.json.gz b/esp-hal/api-baseline/esp32s3.json.gz index a26426bad..b88ccba66 100644 Binary files a/esp-hal/api-baseline/esp32s3.json.gz and b/esp-hal/api-baseline/esp32s3.json.gz differ diff --git a/esp-hal/src/clock/clocks_ll/esp32.rs b/esp-hal/src/clock/clocks_ll/esp32.rs index c3018d7bf..4b57900ef 100644 --- a/esp-hal/src/clock/clocks_ll/esp32.rs +++ b/esp-hal/src/clock/clocks_ll/esp32.rs @@ -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` diff --git a/esp-hal/src/clock/clocks_ll/esp32c2.rs b/esp-hal/src/clock/clocks_ll/esp32c2.rs index cfe856118..4f83dde50 100644 --- a/esp-hal/src/clock/clocks_ll/esp32c2.rs +++ b/esp-hal/src/clock/clocks_ll/esp32c2.rs @@ -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 diff --git a/esp-hal/src/clock/clocks_ll/esp32c3.rs b/esp-hal/src/clock/clocks_ll/esp32c3.rs index da7d84e0e..94c3de26e 100644 --- a/esp-hal/src/clock/clocks_ll/esp32c3.rs +++ b/esp-hal/src/clock/clocks_ll/esp32c3.rs @@ -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 diff --git a/esp-hal/src/clock/clocks_ll/esp32c6.rs b/esp-hal/src/clock/clocks_ll/esp32c6.rs index 91dd4efb4..b4d908271 100644 --- a/esp-hal/src/clock/clocks_ll/esp32c6.rs +++ b/esp-hal/src/clock/clocks_ll/esp32c6.rs @@ -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); diff --git a/esp-hal/src/clock/clocks_ll/esp32h2.rs b/esp-hal/src/clock/clocks_ll/esp32h2.rs index c5afdcf9b..d2a095c5e 100644 --- a/esp-hal/src/clock/clocks_ll/esp32h2.rs +++ b/esp-hal/src/clock/clocks_ll/esp32h2.rs @@ -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); } diff --git a/esp-hal/src/clock/clocks_ll/esp32s2.rs b/esp-hal/src/clock/clocks_ll/esp32s2.rs index e21db46d5..ca5909b29 100644 --- a/esp-hal/src/clock/clocks_ll/esp32s2.rs +++ b/esp-hal/src/clock/clocks_ll/esp32s2.rs @@ -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` diff --git a/esp-hal/src/clock/clocks_ll/esp32s3.rs b/esp-hal/src/clock/clocks_ll/esp32s3.rs index c2726848f..e61751163 100644 --- a/esp-hal/src/clock/clocks_ll/esp32s3.rs +++ b/esp-hal/src/clock/clocks_ll/esp32s3.rs @@ -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 diff --git a/esp-hal/src/clock/mod.rs b/esp-hal/src/clock/mod.rs index a6c213653..9a94c5847 100644 --- a/esp-hal/src/clock/mod.rs +++ b/esp-hal/src/clock/mod.rs @@ -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; diff --git a/esp-hal/src/i2c/master/mod.rs b/esp-hal/src/i2c/master/mod.rs index e3c5807a6..8e538e1bd 100644 --- a/esp-hal/src/i2c/master/mod.rs +++ b/esp-hal/src/i2c/master/mod.rs @@ -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 { 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 diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 7b0921633..18754fae5 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -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 /// diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index c9e322ac6..7a754ee8e 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -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); } } _ => {} diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 709ba89ab..07e359127 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -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![