mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 06:40:47 +00:00
Make nb optional, remove void (#3418)
This commit is contained in:
parent
cb4b09fb62
commit
ddbac7b12d
@ -48,12 +48,11 @@ esp-synopsys-usb-otg = { version = "0.4.2", optional = true, features = ["fs
|
||||
fugit = "0.3.7"
|
||||
instability = "0.3.7"
|
||||
log = { version = "0.4.27", optional = true }
|
||||
nb = "1.1.0"
|
||||
nb = { version = "1.1.0", optional = true }
|
||||
paste = "1.0.15"
|
||||
portable-atomic = { version = "1.11.0", default-features = false }
|
||||
procmacros = { version = "0.17.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
|
||||
strum = { version = "0.27.1", default-features = false, features = ["derive"] }
|
||||
void = { version = "1.0.2", default-features = false }
|
||||
usb-device = { version = "0.3.2", optional = true }
|
||||
rand_core06 = { package = "rand_core", version = "0.6.4", optional = true }
|
||||
rand_core09 = { package = "rand_core", version = "0.9.0", optional = true }
|
||||
@ -163,6 +162,7 @@ unstable = [
|
||||
"dep:embedded-io-async",
|
||||
"dep:rand_core06",
|
||||
"dep:rand_core09",
|
||||
"dep:nb",
|
||||
]
|
||||
|
||||
[lints.clippy]
|
||||
|
@ -57,14 +57,17 @@
|
||||
//! [ADC calibration is not implemented for all targets]: https://github.com/esp-rs/esp-hal/issues/326
|
||||
use core::marker::PhantomData;
|
||||
|
||||
pub use self::implementation::*;
|
||||
use crate::gpio::AnalogPin;
|
||||
|
||||
#[cfg_attr(esp32, path = "esp32.rs")]
|
||||
#[cfg_attr(riscv, path = "riscv.rs")]
|
||||
#[cfg_attr(any(esp32s2, esp32s3), path = "xtensa.rs")]
|
||||
#[cfg(feature = "unstable")]
|
||||
mod implementation;
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
pub use self::implementation::*;
|
||||
|
||||
/// The attenuation of the ADC pin.
|
||||
///
|
||||
/// The effective measurement range for a given attenuation is dependent on the
|
||||
@ -109,6 +112,7 @@ pub struct AdcPin<PIN, ADCI, CS = ()> {
|
||||
}
|
||||
|
||||
/// Configuration for the ADC.
|
||||
#[cfg(feature = "unstable")]
|
||||
pub struct AdcConfig<ADCI> {
|
||||
#[cfg_attr(not(esp32), allow(unused))]
|
||||
resolution: Resolution,
|
||||
@ -116,6 +120,7 @@ pub struct AdcConfig<ADCI> {
|
||||
_phantom: PhantomData<ADCI>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
impl<ADCI> AdcConfig<ADCI> {
|
||||
/// Create a new configuration struct with its default values
|
||||
pub fn new() -> Self {
|
||||
@ -141,6 +146,7 @@ impl<ADCI> AdcConfig<ADCI> {
|
||||
/// Enable the specified pin with the given attenuation and calibration
|
||||
/// scheme
|
||||
#[cfg(not(esp32))]
|
||||
#[cfg(feature = "unstable")]
|
||||
pub fn enable_pin_with_cal<PIN, CS>(
|
||||
&mut self,
|
||||
pin: PIN,
|
||||
@ -163,6 +169,7 @@ impl<ADCI> AdcConfig<ADCI> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
impl<ADCI> Default for AdcConfig<ADCI> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@ -175,6 +182,7 @@ impl<ADCI> Default for AdcConfig<ADCI> {
|
||||
|
||||
#[cfg(not(esp32))]
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "unstable")]
|
||||
pub trait CalibrationAccess: RegisterAccess {
|
||||
const ADC_CAL_CNT_MAX: u16;
|
||||
const ADC_CAL_CHANNEL: u16;
|
||||
|
@ -19,7 +19,7 @@
|
||||
//! channel will trigger the corresponding task automatically.
|
||||
//!
|
||||
//! For more information, please refer to the
|
||||
#, "/api-reference/peripherals/etm.html)")]
|
||||
#, "/api-reference/peripherals/etm.html)")]
|
||||
//! ## Examples
|
||||
//!
|
||||
//! ### Control LED by the button via ETM
|
||||
|
@ -188,7 +188,7 @@ mod fmt;
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
metadata!("build_info", CHIP_NAME, chip!());
|
||||
metadata!("build_info", CHIP_NAME, crate::chip!());
|
||||
|
||||
#[cfg(riscv)]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
|
||||
@ -224,7 +224,7 @@ pub mod gpio;
|
||||
#[cfg(any(i2c0, i2c1))]
|
||||
pub mod i2c;
|
||||
pub mod peripheral;
|
||||
#[cfg(any(hmac, sha))]
|
||||
#[cfg(all(feature = "unstable", any(hmac, sha)))]
|
||||
mod reg_access;
|
||||
#[cfg(any(spi0, spi1, spi2, spi3))]
|
||||
pub mod spi;
|
||||
@ -267,40 +267,69 @@ macro_rules! unstable_module {
|
||||
};
|
||||
}
|
||||
|
||||
// can't use instability on inline module definitions, see https://github.com/rust-lang/rust/issues/54727
|
||||
// we don't want unstable drivers to be compiled even, unless enabled
|
||||
#[doc(hidden)]
|
||||
macro_rules! unstable_driver {
|
||||
($(
|
||||
$(#[$meta:meta])*
|
||||
pub mod $module:ident;
|
||||
)*) => {
|
||||
$(
|
||||
$(#[$meta])*
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
|
||||
pub mod $module;
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use unstable_driver;
|
||||
pub(crate) use unstable_module;
|
||||
|
||||
unstable_module! {
|
||||
#[cfg(aes)]
|
||||
pub mod aes;
|
||||
#[cfg(any(adc1, adc2, dac))]
|
||||
pub mod analog;
|
||||
pub mod asynch;
|
||||
#[cfg(assist_debug)]
|
||||
pub mod assist_debug;
|
||||
pub mod config;
|
||||
pub mod debugger;
|
||||
#[cfg(any(xtensa, all(riscv, systimer)))]
|
||||
pub mod delay;
|
||||
#[cfg(any(dport, interrupt_core0, interrupt_core1))]
|
||||
pub mod interrupt;
|
||||
pub mod rom;
|
||||
#[doc(hidden)]
|
||||
pub mod sync;
|
||||
// Drivers needed for initialization or they are tightly coupled to something else.
|
||||
#[cfg(any(adc1, adc2, dac))]
|
||||
pub mod analog;
|
||||
#[cfg(any(systimer, timg0, timg1))]
|
||||
pub mod timer;
|
||||
#[cfg(any(lp_clkrst, rtc_cntl))]
|
||||
pub mod rtc_cntl;
|
||||
#[cfg(any(gdma, pdma))]
|
||||
pub mod dma;
|
||||
#[cfg(ecc)]
|
||||
pub mod ecc;
|
||||
#[cfg(soc_etm)]
|
||||
pub mod etm;
|
||||
#[cfg(usb0)]
|
||||
pub mod otg_fs;
|
||||
}
|
||||
|
||||
unstable_driver! {
|
||||
#[cfg(aes)]
|
||||
pub mod aes;
|
||||
#[cfg(assist_debug)]
|
||||
pub mod assist_debug;
|
||||
#[cfg(any(xtensa, all(riscv, systimer)))]
|
||||
pub mod delay;
|
||||
#[cfg(ecc)]
|
||||
pub mod ecc;
|
||||
#[cfg(hmac)]
|
||||
pub mod hmac;
|
||||
#[cfg(any(i2s0, i2s1))]
|
||||
pub mod i2s;
|
||||
#[cfg(any(dport, interrupt_core0, interrupt_core1))]
|
||||
pub mod interrupt;
|
||||
#[cfg(lcd_cam)]
|
||||
pub mod lcd_cam;
|
||||
#[cfg(ledc)]
|
||||
pub mod ledc;
|
||||
#[cfg(any(mcpwm0, mcpwm1))]
|
||||
pub mod mcpwm;
|
||||
#[cfg(usb0)]
|
||||
pub mod otg_fs;
|
||||
#[cfg(parl_io)]
|
||||
pub mod parl_io;
|
||||
#[cfg(pcnt)]
|
||||
@ -309,17 +338,10 @@ unstable_module! {
|
||||
pub mod rmt;
|
||||
#[cfg(rng)]
|
||||
pub mod rng;
|
||||
pub mod rom;
|
||||
#[cfg(rsa)]
|
||||
pub mod rsa;
|
||||
#[cfg(any(lp_clkrst, rtc_cntl))]
|
||||
pub mod rtc_cntl;
|
||||
#[cfg(sha)]
|
||||
pub mod sha;
|
||||
#[doc(hidden)]
|
||||
pub mod sync;
|
||||
#[cfg(any(systimer, timg0, timg1))]
|
||||
pub mod timer;
|
||||
#[cfg(touch)]
|
||||
pub mod touch;
|
||||
#[cfg(trace0)]
|
||||
|
@ -38,7 +38,7 @@
|
||||
)]
|
||||
#![doc = ""]
|
||||
//! For more information, please refer to the
|
||||
#, "/api-reference/peripherals/rmt.html)")]
|
||||
#, "/api-reference/peripherals/rmt.html)")]
|
||||
//! ## Configuration
|
||||
//! Each TX/RX channel has the same functionality controlled by a dedicated set
|
||||
//! of registers and is able to independently transmit or receive data. TX
|
||||
|
@ -25,7 +25,7 @@
|
||||
//! considered pseudo-random only.
|
||||
//!
|
||||
//! For more information, please refer to the
|
||||
#, "/api-reference/system/random.html)")]
|
||||
#, "/api-reference/system/random.html)")]
|
||||
//! ## Configuration
|
||||
//! To use the [Rng] Driver, you need to initialize it with the RNG peripheral.
|
||||
//! Once initialized, you can generate random numbers by calling the `random`
|
||||
|
@ -35,8 +35,7 @@ macro_rules! trm_link {
|
||||
() => { "https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf" };
|
||||
}
|
||||
|
||||
pub use chip;
|
||||
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod constants {
|
||||
use crate::time::Rate;
|
||||
|
||||
|
@ -28,13 +28,12 @@ macro_rules! trm_link {
|
||||
() => { "https://www.espressif.com/sites/default/files/documentation/esp8684_technical_reference_manual_en.pdf" };
|
||||
}
|
||||
|
||||
pub use chip;
|
||||
|
||||
#[allow(unused)]
|
||||
pub(crate) mod registers {
|
||||
pub const INTERRUPT_MAP_BASE: u32 = 0x600c2000;
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod constants {
|
||||
use crate::time::Rate;
|
||||
|
||||
|
@ -32,13 +32,12 @@ macro_rules! trm_link {
|
||||
() => { "https://www.espressif.com/sites/default/files/documentation/esp32-c3_technical_reference_manual_en.pdf" };
|
||||
}
|
||||
|
||||
pub use chip;
|
||||
|
||||
#[allow(unused)]
|
||||
pub(crate) mod registers {
|
||||
pub const INTERRUPT_MAP_BASE: u32 = 0x600c2000;
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod constants {
|
||||
use crate::time::Rate;
|
||||
|
||||
|
@ -34,13 +34,12 @@ macro_rules! trm_link {
|
||||
() => { "https://www.espressif.com/sites/default/files/documentation/esp32-c6_technical_reference_manual_en.pdf" };
|
||||
}
|
||||
|
||||
pub use chip;
|
||||
|
||||
#[allow(unused)]
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod registers {
|
||||
pub const INTERRUPT_MAP_BASE: u32 = 0x60010000;
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod constants {
|
||||
use crate::time::Rate;
|
||||
|
||||
|
@ -33,13 +33,12 @@ macro_rules! trm_link {
|
||||
() => { "https://www.espressif.com/sites/default/files/documentation/esp32-h2_technical_reference_manual_en.pdf" };
|
||||
}
|
||||
|
||||
pub use chip;
|
||||
|
||||
#[allow(unused)]
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod registers {
|
||||
pub const INTERRUPT_MAP_BASE: u32 = 0x60010000;
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod constants {
|
||||
use crate::time::Rate;
|
||||
|
||||
|
@ -39,8 +39,7 @@ macro_rules! trm_link {
|
||||
() => { "https://www.espressif.com/sites/default/files/documentation/esp32-s2_technical_reference_manual_en.pdf" };
|
||||
}
|
||||
|
||||
pub use chip;
|
||||
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod constants {
|
||||
use crate::time::Rate;
|
||||
|
||||
|
@ -40,8 +40,7 @@ macro_rules! trm_link {
|
||||
() => { "https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf" };
|
||||
}
|
||||
|
||||
pub use chip;
|
||||
|
||||
#[cfg_attr(not(feature = "unstable"), allow(unused))]
|
||||
pub(crate) mod constants {
|
||||
use crate::time::Rate;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
//! TWAI protocol is suited for automotive and industrial applications.
|
||||
//!
|
||||
//! See ESP-IDF's
|
||||
#, "/api-reference/peripherals/twai.html#twai-protocol-summary)")]
|
||||
#, "/api-reference/peripherals/twai.html#twai-protocol-summary)")]
|
||||
//! for a summary on the protocol.
|
||||
//!
|
||||
//! ## Configuration
|
||||
|
Loading…
x
Reference in New Issue
Block a user