This commit is contained in:
Kirill Mikhailov 2025-01-09 21:13:20 +01:00 committed by GitHub
commit b8aaded49e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
55 changed files with 244 additions and 148 deletions

View File

@ -5,7 +5,7 @@ use core::marker::PhantomData;
use embassy_executor::{raw, Spawner}; use embassy_executor::{raw, Spawner};
use esp_hal::Cpu; use esp_hal::Cpu;
#[cfg(multi_core)] #[cfg(multi_core)]
use esp_hal::{interrupt::software::SoftwareInterrupt, macros::handler}; use esp_hal::{handler, interrupt::software::SoftwareInterrupt};
#[cfg(low_power_wait)] #[cfg(low_power_wait)]
use portable_atomic::{AtomicBool, Ordering}; use portable_atomic::{AtomicBool, Ordering};

View File

@ -101,6 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SPI: Fix naming violations for `Address` and `Command` enum variants (#2906) - SPI: Fix naming violations for `Address` and `Command` enum variants (#2906)
- `ClockSource` enums are now `#[non_exhaustive]` (#2912) - `ClockSource` enums are now `#[non_exhaustive]` (#2912)
- `macros` module is now private (#2900)
- `gpio::{Input, Flex}::wakeup_enable` now returns an error instead of panicking. (#2916) - `gpio::{Input, Flex}::wakeup_enable` now returns an error instead of panicking. (#2916)

View File

@ -476,3 +476,13 @@ The ADC attenuation variants are renamed from e.g. `Attenuation0dB` to `_0dB`.
-Attenuation::Attenuation0dB -Attenuation::Attenuation0dB
+Attenuation::_0dB +Attenuation::_0dB
``` ```
## `macro` module is private now
Macros from `procmacros` crate (`handler`, `ram`, `load_lp_code`) are now imported via `esp-hal`.
```diff
- use esp_hal::macros::{handler, ram, load_lp_code};
+ use esp_hal::{handler, ram, load_lp_code};
```

View File

@ -234,8 +234,8 @@ impl RegisterAccess for crate::peripherals::ADC1 {
fn set_init_code(data: u16) { fn set_init_code(data: u16) {
let [msb, lsb] = data.to_be_bytes(); let [msb, lsb] = data.to_be_bytes();
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, msb as u32); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, msb as u32);
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, lsb as u32); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, lsb as u32);
} }
fn reset() { fn reset() {
@ -257,16 +257,16 @@ impl super::CalibrationAccess for crate::peripherals::ADC1 {
const ADC_VAL_MASK: u16 = ADC_VAL_MASK; const ADC_VAL_MASK: u16 = ADC_VAL_MASK;
fn enable_vdef(enable: bool) { fn enable_vdef(enable: bool) {
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_DREF_ADDR, enable as u8); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_DREF_ADDR, enable as u8);
} }
fn connect_cal(source: AdcCalSource, enable: bool) { fn connect_cal(source: AdcCalSource, enable: bool) {
match source { match source {
AdcCalSource::Gnd => { AdcCalSource::Gnd => {
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_ENCAL_GND_ADDR, enable as u8); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_ENCAL_GND_ADDR, enable as u8);
} }
AdcCalSource::Ref => { AdcCalSource::Ref => {
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SARADC1_ENCAL_REF_ADDR, enable as u8); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SARADC1_ENCAL_REF_ADDR, enable as u8);
} }
} }
} }
@ -348,8 +348,8 @@ impl RegisterAccess for crate::peripherals::ADC2 {
fn set_init_code(data: u16) { fn set_init_code(data: u16) {
let [msb, lsb] = data.to_be_bytes(); let [msb, lsb] = data.to_be_bytes();
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_HIGH_ADDR, msb as u32); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_HIGH_ADDR, msb as u32);
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_LOW_ADDR, lsb as u32); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_LOW_ADDR, lsb as u32);
} }
fn reset() { fn reset() {
@ -371,16 +371,16 @@ impl super::CalibrationAccess for crate::peripherals::ADC2 {
const ADC_VAL_MASK: u16 = ADC_VAL_MASK; const ADC_VAL_MASK: u16 = ADC_VAL_MASK;
fn enable_vdef(enable: bool) { fn enable_vdef(enable: bool) {
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_DREF_ADDR, enable as u8); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_DREF_ADDR, enable as u8);
} }
fn connect_cal(source: AdcCalSource, enable: bool) { fn connect_cal(source: AdcCalSource, enable: bool) {
match source { match source {
AdcCalSource::Gnd => { AdcCalSource::Gnd => {
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_ENCAL_GND_ADDR, enable as u8); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_ENCAL_GND_ADDR, enable as u8);
} }
AdcCalSource::Ref => { AdcCalSource::Ref => {
crate::regi2c_write_mask!(I2C_SAR_ADC, ADC_SARADC2_ENCAL_REF_ADDR, enable as u8); crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SARADC2_ENCAL_REF_ADDR, enable as u8);
} }
} }
} }

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
clock::{Clock, PllClock, XtalClock}, clock::{Clock, PllClock, XtalClock},
regi2c_write, rom::regi2c_write,
}; };
const REF_CLK_FREQ: u32 = 1000000; const REF_CLK_FREQ: u32 = 1000000;

View File

@ -1,7 +1,6 @@
use crate::{ use crate::{
clock::{ApbClock, Clock, CpuClock, PllClock, XtalClock}, clock::{ApbClock, Clock, CpuClock, PllClock, XtalClock},
regi2c_write, rom::{regi2c_write, regi2c_write_mask},
regi2c_write_mask,
}; };
const I2C_BBPLL: u32 = 0x66; const I2C_BBPLL: u32 = 0x66;

View File

@ -1,7 +1,6 @@
use crate::{ use crate::{
clock::{ApbClock, Clock, CpuClock, PllClock, XtalClock}, clock::{ApbClock, Clock, CpuClock, PllClock, XtalClock},
regi2c_write, rom::{regi2c_write, regi2c_write_mask},
regi2c_write_mask,
}; };
const I2C_BBPLL: u32 = 0x66; const I2C_BBPLL: u32 = 0x66;

View File

@ -19,7 +19,7 @@ use critical_section::CriticalSection;
use crate::{ use crate::{
dma::*, dma::*,
interrupt::Priority, interrupt::Priority,
macros::handler, handler,
peripheral::{Peripheral, PeripheralRef}, peripheral::{Peripheral, PeripheralRef},
peripherals::Interrupt, peripherals::Interrupt,
}; };

View File

@ -18,7 +18,7 @@ use crate::{
asynch::AtomicWaker, asynch::AtomicWaker,
dma::*, dma::*,
interrupt::Priority, interrupt::Priority,
macros::handler, handler,
peripheral::{Peripheral, PeripheralRef}, peripheral::{Peripheral, PeripheralRef},
peripherals::Interrupt, peripherals::Interrupt,
}; };

View File

@ -1026,6 +1026,8 @@ macro_rules! io_type {
(Analog, $gpionum:literal) => { (Analog, $gpionum:literal) => {
// FIXME: the implementation shouldn't be in the GPIO module // FIXME: the implementation shouldn't be in the GPIO module
#[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2))] #[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2))]
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
impl $crate::gpio::AnalogPin for $crate::gpio::GpioPin<$gpionum> { impl $crate::gpio::AnalogPin for $crate::gpio::GpioPin<$gpionum> {
/// Configures the pin for analog mode. /// Configures the pin for analog mode.
fn set_analog(&self, _: $crate::private::Internal) { fn set_analog(&self, _: $crate::private::Internal) {

View File

@ -2258,7 +2258,7 @@ macro_rules! instance {
($inst:ident, $peri:ident, $scl:ident, $sda:ident, $interrupt:ident) => { ($inst:ident, $peri:ident, $scl:ident, $sda:ident, $interrupt:ident) => {
impl Instance for crate::peripherals::$inst { impl Instance for crate::peripherals::$inst {
fn parts(&self) -> (&Info, &State) { fn parts(&self) -> (&Info, &State) {
#[crate::macros::handler] #[crate::handler]
pub(super) fn irq_handler() { pub(super) fn irq_handler() {
async_handler(&PERIPHERAL, &STATE); async_handler(&PERIPHERAL, &STATE);
} }

View File

@ -8,4 +8,6 @@
pub mod master; pub mod master;
#[cfg(lp_i2c0)] #[cfg(lp_i2c0)]
pub mod lp_i2c; crate::unstable_module! {
pub mod lp_i2c;
}

View File

@ -14,7 +14,7 @@ use crate::{
asynch::AtomicWaker, asynch::AtomicWaker,
interrupt::{InterruptConfigurable, InterruptHandler}, interrupt::{InterruptConfigurable, InterruptHandler},
lcd_cam::{cam::Cam, lcd::Lcd}, lcd_cam::{cam::Cam, lcd::Lcd},
macros::handler, handler,
peripheral::Peripheral, peripheral::Peripheral,
peripherals::{Interrupt, LCD_CAM}, peripherals::{Interrupt, LCD_CAM},
system::GenericPeripheralGuard, system::GenericPeripheralGuard,

View File

@ -143,41 +143,42 @@
// MUST be the first module // MUST be the first module
mod fmt; mod fmt;
pub mod asynch;
#[cfg(riscv)] #[cfg(riscv)]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub use esp_riscv_rt::{self, entry, riscv}; pub use esp_riscv_rt::{self, entry, riscv};
#[cfg(xtensa)] #[cfg(xtensa)]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub use xtensa_lx; pub use xtensa_lx;
#[cfg(xtensa)] #[cfg(xtensa)]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub use xtensa_lx_rt::{self, entry}; pub use xtensa_lx_rt::{self, entry};
// TODO what should we reexport stably? // TODO what should we reexport stably?
#[cfg(any(esp32, esp32s3))] #[cfg(any(esp32, esp32s3))]
pub use self::soc::cpu_control; pub use self::soc::cpu_control;
#[cfg(efuse)] #[cfg(efuse)]
#[instability::unstable]
#[cfg_attr(not(feature = "unstable"), allow(unused))]
pub use self::soc::efuse; pub use self::soc::efuse;
#[cfg(lp_core)] #[cfg(lp_core)]
#[instability::unstable]
#[cfg_attr(not(feature = "unstable"), allow(unused))]
pub use self::soc::lp_core; pub use self::soc::lp_core;
pub use self::soc::peripherals; pub use self::soc::peripherals;
#[instability::unstable]
#[cfg(any(feature = "quad-psram", feature = "octal-psram"))] #[cfg(any(feature = "quad-psram", feature = "octal-psram"))]
pub use self::soc::psram; pub use self::soc::psram;
#[cfg(ulp_riscv_core)] #[cfg(ulp_riscv_core)]
#[instability::unstable]
#[cfg_attr(not(feature = "unstable"), allow(unused))]
pub use self::soc::ulp_core; pub use self::soc::ulp_core;
#[cfg(any(dport, hp_sys, pcr, system))] #[cfg(any(dport, hp_sys, pcr, system))]
pub mod clock; pub mod clock;
pub mod config;
#[cfg(any(xtensa, all(riscv, systimer)))]
pub mod delay;
#[cfg(gpio)] #[cfg(gpio)]
pub mod gpio; pub mod gpio;
#[cfg(any(i2c0, i2c1))] #[cfg(any(i2c0, i2c1))]
pub mod i2c; pub mod i2c;
#[cfg(any(dport, interrupt_core0, interrupt_core1))]
pub mod interrupt;
pub mod peripheral; pub mod peripheral;
#[cfg(any(hmac, sha))] #[cfg(any(hmac, sha))]
mod reg_access; mod reg_access;
@ -186,13 +187,16 @@ pub mod spi;
#[cfg(any(uart0, uart1, uart2))] #[cfg(any(uart0, uart1, uart2))]
pub mod uart; pub mod uart;
pub mod macros; mod macros;
pub mod rom;
pub mod debugger; #[cfg(any(lp_core, ulp_riscv_core))]
#[doc(hidden)] #[cfg(feature = "unstable")]
pub mod sync; #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub mod time; pub use procmacros::load_lp_code;
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[instability::unstable]
#[cfg_attr(not(feature = "unstable"), allow(unused))]
pub use procmacros::{handler, ram};
// can't use instability on inline module definitions, see https://github.com/rust-lang/rust/issues/54727 // can't use instability on inline module definitions, see https://github.com/rust-lang/rust/issues/54727
#[doc(hidden)] #[doc(hidden)]
@ -223,8 +227,13 @@ unstable_module! {
pub mod aes; pub mod aes;
#[cfg(any(adc, dac))] #[cfg(any(adc, dac))]
pub mod analog; pub mod analog;
pub mod asynch;
#[cfg(assist_debug)] #[cfg(assist_debug)]
pub mod assist_debug; pub mod assist_debug;
pub mod config;
pub mod debugger;
#[cfg(any(xtensa, all(riscv, systimer)))]
pub mod delay;
#[cfg(any(gdma, pdma))] #[cfg(any(gdma, pdma))]
pub mod dma; pub mod dma;
#[cfg(ecc)] #[cfg(ecc)]
@ -235,6 +244,8 @@ unstable_module! {
pub mod hmac; pub mod hmac;
#[cfg(any(i2s0, i2s1))] #[cfg(any(i2s0, i2s1))]
pub mod i2s; pub mod i2s;
#[cfg(any(dport, interrupt_core0, interrupt_core1))]
pub mod interrupt;
#[cfg(lcd_cam)] #[cfg(lcd_cam)]
pub mod lcd_cam; pub mod lcd_cam;
#[cfg(ledc)] #[cfg(ledc)]
@ -253,14 +264,18 @@ unstable_module! {
pub mod rmt; pub mod rmt;
#[cfg(rng)] #[cfg(rng)]
pub mod rng; pub mod rng;
pub mod rom;
#[cfg(rsa)] #[cfg(rsa)]
pub mod rsa; pub mod rsa;
#[cfg(any(lp_clkrst, rtc_cntl))] #[cfg(any(lp_clkrst, rtc_cntl))]
pub mod rtc_cntl; pub mod rtc_cntl;
#[cfg(sha)] #[cfg(sha)]
pub mod sha; pub mod sha;
#[doc(hidden)]
pub mod sync;
#[cfg(any(dport, hp_sys, pcr, system))] #[cfg(any(dport, hp_sys, pcr, system))]
pub mod system; pub mod system;
pub mod time;
#[cfg(any(systimer, timg0, timg1))] #[cfg(any(systimer, timg0, timg1))]
pub mod timer; pub mod timer;
#[cfg(touch)] #[cfg(touch)]
@ -351,6 +366,7 @@ pub use private::Internal;
/// reset occurs during a write or a reset interrupts the zero initialization /// reset occurs during a write or a reset interrupts the zero initialization
/// on first boot. /// on first boot.
/// - Structs must contain only `Persistable` fields and padding /// - Structs must contain only `Persistable` fields and padding
#[instability::unstable]
pub unsafe trait Persistable: Sized {} pub unsafe trait Persistable: Sized {}
macro_rules! impl_persistable { macro_rules! impl_persistable {
@ -368,6 +384,7 @@ impl_persistable!(atomic AtomicU8, AtomicI8, AtomicU16, AtomicI16, AtomicU32, At
unsafe impl<T: Persistable, const N: usize> Persistable for [T; N] {} unsafe impl<T: Persistable, const N: usize> Persistable for [T; N] {}
#[doc(hidden)] #[doc(hidden)]
#[instability::unstable]
pub mod __macro_implementation { pub mod __macro_implementation {
//! Unstable private implementation details of esp-hal-procmacros. //! Unstable private implementation details of esp-hal-procmacros.
@ -493,9 +510,10 @@ unsafe extern "C" fn stack_chk_fail() {
panic!("Stack corruption detected"); panic!("Stack corruption detected");
} }
#[cfg(feature = "unstable")]
use crate::config::{WatchdogConfig, WatchdogStatus};
use crate::{ use crate::{
clock::{Clocks, CpuClock}, clock::{Clocks, CpuClock},
config::{WatchdogConfig, WatchdogStatus},
peripherals::Peripherals, peripherals::Peripherals,
}; };
@ -514,9 +532,13 @@ pub struct Config {
pub cpu_clock: CpuClock, pub cpu_clock: CpuClock,
/// Enable watchdog timer(s). /// Enable watchdog timer(s).
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub watchdog: WatchdogConfig, pub watchdog: WatchdogConfig,
/// PSRAM configuration. /// PSRAM configuration.
#[cfg(any(doc, feature = "unstable"))]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[cfg(any(feature = "quad-psram", feature = "octal-psram"))] #[cfg(any(feature = "quad-psram", feature = "octal-psram"))]
pub psram: psram::PsramConfig, pub psram: psram::PsramConfig,
} }
@ -533,43 +555,61 @@ pub fn init(config: Config) -> Peripherals {
// RTC domain must be enabled before we try to disable // RTC domain must be enabled before we try to disable
let mut rtc = crate::rtc_cntl::Rtc::new(&mut peripherals.LPWR); let mut rtc = crate::rtc_cntl::Rtc::new(&mut peripherals.LPWR);
#[cfg(not(any(esp32, esp32s2)))] // Handle watchdog configuration with defaults
if config.watchdog.swd { cfg_if::cfg_if! {
rtc.swd.enable(); if #[cfg(feature = "unstable")]
} else { {
rtc.swd.disable(); #[cfg(not(any(esp32, esp32s2)))]
} if config.watchdog.swd {
rtc.swd.enable();
} else {
rtc.swd.disable();
}
match config.watchdog.rwdt { match config.watchdog.rwdt {
WatchdogStatus::Enabled(duration) => { WatchdogStatus::Enabled(duration) => {
rtc.rwdt.enable(); rtc.rwdt.enable();
rtc.rwdt rtc.rwdt
.set_timeout(crate::rtc_cntl::RwdtStage::Stage0, duration); .set_timeout(crate::rtc_cntl::RwdtStage::Stage0, duration);
}
WatchdogStatus::Disabled => {
rtc.rwdt.disable();
}
}
match config.watchdog.timg0 {
WatchdogStatus::Enabled(duration) => {
let mut timg0_wd = crate::timer::timg::Wdt::<self::peripherals::TIMG0>::new();
timg0_wd.enable();
timg0_wd.set_timeout(crate::timer::timg::MwdtStage::Stage0, duration);
}
WatchdogStatus::Disabled => {
crate::timer::timg::Wdt::<self::peripherals::TIMG0>::new().disable();
}
}
#[cfg(timg1)]
match config.watchdog.timg1 {
WatchdogStatus::Enabled(duration) => {
let mut timg1_wd = crate::timer::timg::Wdt::<self::peripherals::TIMG1>::new();
timg1_wd.enable();
timg1_wd.set_timeout(crate::timer::timg::MwdtStage::Stage0, duration);
}
WatchdogStatus::Disabled => {
crate::timer::timg::Wdt::<self::peripherals::TIMG1>::new().disable();
}
}
} }
WatchdogStatus::Disabled => { else
{
#[cfg(not(any(esp32, esp32s2)))]
rtc.swd.disable();
rtc.rwdt.disable(); rtc.rwdt.disable();
}
}
match config.watchdog.timg0 {
WatchdogStatus::Enabled(duration) => {
let mut timg0_wd = crate::timer::timg::Wdt::<self::peripherals::TIMG0>::new();
timg0_wd.enable();
timg0_wd.set_timeout(crate::timer::timg::MwdtStage::Stage0, duration);
}
WatchdogStatus::Disabled => {
crate::timer::timg::Wdt::<self::peripherals::TIMG0>::new().disable(); crate::timer::timg::Wdt::<self::peripherals::TIMG0>::new().disable();
}
}
#[cfg(timg1)] #[cfg(timg1)]
match config.watchdog.timg1 {
WatchdogStatus::Enabled(duration) => {
let mut timg1_wd = crate::timer::timg::Wdt::<self::peripherals::TIMG1>::new();
timg1_wd.enable();
timg1_wd.set_timeout(crate::timer::timg::MwdtStage::Stage0, duration);
}
WatchdogStatus::Disabled => {
crate::timer::timg::Wdt::<self::peripherals::TIMG1>::new().disable(); crate::timer::timg::Wdt::<self::peripherals::TIMG1>::new().disable();
} }
} }

View File

@ -3,9 +3,6 @@
//! Most of the macros in this module are hidden and intended for internal use //! Most of the macros in this module are hidden and intended for internal use
//! only. For the list of public macros, see the [procmacros](https://docs.rs/esp-hal-procmacros/latest/esp_hal_procmacros/) //! only. For the list of public macros, see the [procmacros](https://docs.rs/esp-hal-procmacros/latest/esp_hal_procmacros/)
//! documentation. //! documentation.
pub use procmacros::*;
#[doc(hidden)] #[doc(hidden)]
/// Helper macro for checking doctest code snippets /// Helper macro for checking doctest code snippets
#[macro_export] #[macro_export]

View File

@ -227,7 +227,7 @@ use crate::{
asynch::AtomicWaker, asynch::AtomicWaker,
gpio::interconnect::{PeripheralInput, PeripheralOutput}, gpio::interconnect::{PeripheralInput, PeripheralOutput},
interrupt::InterruptConfigurable, interrupt::InterruptConfigurable,
macros::handler, handler,
peripheral::Peripheral, peripheral::Peripheral,
peripherals::Interrupt, peripherals::Interrupt,
soc::constants, soc::constants,

View File

@ -44,8 +44,6 @@ extern "C" {
); );
} }
#[doc(hidden)]
#[macro_export]
macro_rules! regi2c_write { macro_rules! regi2c_write {
( $block: ident, $reg_add: ident, $indata: expr ) => { ( $block: ident, $reg_add: ident, $indata: expr ) => {
paste::paste! { paste::paste! {
@ -62,8 +60,9 @@ macro_rules! regi2c_write {
}; };
} }
#[doc(hidden)] #[allow(unused_imports)]
#[macro_export] pub(crate) use regi2c_write;
macro_rules! regi2c_write_mask { macro_rules! regi2c_write_mask {
( $block: ident, $reg_add: ident, $indata: expr ) => { ( $block: ident, $reg_add: ident, $indata: expr ) => {
paste::paste! { paste::paste! {
@ -82,6 +81,9 @@ macro_rules! regi2c_write_mask {
}; };
} }
#[allow(unused_imports)]
pub(crate) use regi2c_write_mask;
#[inline(always)] #[inline(always)]
pub(crate) fn ets_delay_us(us: u32) { pub(crate) fn ets_delay_us(us: u32) {
extern "C" { extern "C" {

View File

@ -2,7 +2,7 @@ use strum::FromRepr;
use crate::{ use crate::{
peripherals::{APB_CTRL, EXTMEM, RTC_CNTL, SPI0, SPI1, SYSTEM}, peripherals::{APB_CTRL, EXTMEM, RTC_CNTL, SPI0, SPI1, SYSTEM},
regi2c_write_mask, rom::regi2c_write_mask,
rtc_cntl::{RtcCalSel, RtcClock, RtcFastClock, RtcSlowClock}, rtc_cntl::{RtcCalSel, RtcClock, RtcFastClock, RtcSlowClock},
}; };

View File

@ -3,7 +3,7 @@ use strum::FromRepr;
use crate::{ use crate::{
clock::XtalClock, clock::XtalClock,
peripherals::{APB_CTRL, EXTMEM, RTC_CNTL, SPI0, SPI1, SYSTEM}, peripherals::{APB_CTRL, EXTMEM, RTC_CNTL, SPI0, SPI1, SYSTEM},
regi2c_write_mask, rom::regi2c_write_mask,
rtc_cntl::{RtcCalSel, RtcClock, RtcFastClock, RtcSlowClock}, rtc_cntl::{RtcCalSel, RtcClock, RtcFastClock, RtcSlowClock},
}; };

View File

@ -1,7 +1,7 @@
use super::{TimerWakeupSource, WakeSource, WakeTriggers, WakeupLevel}; use super::{TimerWakeupSource, WakeSource, WakeTriggers, WakeupLevel};
use crate::{ use crate::{
gpio::{RtcFunction, RtcPinWithResistors}, gpio::{RtcFunction, RtcPinWithResistors},
regi2c_write_mask, rom::regi2c_write_mask,
rtc_cntl::{sleep::RtcioWakeupSource, Clock, Rtc, RtcClock}, rtc_cntl::{sleep::RtcioWakeupSource, Clock, Rtc, RtcClock},
}; };

View File

@ -1,7 +1,7 @@
use super::{TimerWakeupSource, WakeSource, WakeTriggers, WakeupLevel}; use super::{TimerWakeupSource, WakeSource, WakeTriggers, WakeupLevel};
use crate::{ use crate::{
gpio::{RtcFunction, RtcPinWithResistors}, gpio::{RtcFunction, RtcPinWithResistors},
regi2c_write_mask, rom::regi2c_write_mask,
rtc_cntl::{sleep::RtcioWakeupSource, Clock, Rtc, RtcClock}, rtc_cntl::{sleep::RtcioWakeupSource, Clock, Rtc, RtcClock},
}; };

View File

@ -8,7 +8,7 @@ use super::{
}; };
use crate::{ use crate::{
gpio::{RtcFunction, RtcPin}, gpio::{RtcFunction, RtcPin},
regi2c_write_mask, rom::regi2c_write_mask,
rtc_cntl::{sleep::RtcioWakeupSource, Clock, Rtc, RtcClock}, rtc_cntl::{sleep::RtcioWakeupSource, Clock, Rtc, RtcClock},
}; };

View File

@ -110,6 +110,7 @@ impl Efuse {
/// ///
/// This function panics if the field's bit length is not equal to 1. /// This function panics if the field's bit length is not equal to 1.
#[inline(always)] #[inline(always)]
#[cfg_attr(not(feature = "unstable"), allow(unused))]
pub fn read_bit(field: EfuseField) -> bool { pub fn read_bit(field: EfuseField) -> bool {
assert_eq!(field.bit_len, 1); assert_eq!(field.bit_len, 1);
Self::read_field_le::<u8>(field) != 0 Self::read_field_le::<u8>(field) != 0

View File

@ -9,14 +9,16 @@ use core::ptr::addr_of_mut;
use crate::rtc_cntl::SocResetReason; use crate::rtc_cntl::SocResetReason;
crate::unstable_module! {
pub mod efuse;
#[cfg(feature = "quad-psram")]
pub mod psram;
pub mod radio_clocks;
pub mod trng;
}
pub mod cpu_control; pub mod cpu_control;
pub mod efuse;
pub mod gpio; pub mod gpio;
pub mod peripherals; pub mod peripherals;
#[cfg(feature = "quad-psram")]
pub mod psram;
pub mod radio_clocks;
pub mod trng;
/// The name of the chip ("esp32") as `&str` /// The name of the chip ("esp32") as `&str`
#[macro_export] #[macro_export]

View File

@ -5,11 +5,13 @@
//! The `SOC` module provides access, functions and structures that are useful //! The `SOC` module provides access, functions and structures that are useful
//! for interacting with various system-related peripherals on `ESP32-C2` chip. //! for interacting with various system-related peripherals on `ESP32-C2` chip.
pub mod efuse; crate::unstable_module! {
pub mod efuse;
pub mod radio_clocks;
pub mod trng;
}
pub mod gpio; pub mod gpio;
pub mod peripherals; pub mod peripherals;
pub mod radio_clocks;
pub mod trng;
/// The name of the chip ("esp32c2") as `&str` /// The name of the chip ("esp32c2") as `&str`
#[macro_export] #[macro_export]

View File

@ -13,7 +13,7 @@ const ADC_SARADC_ENT_TSENS_ADDR: u8 = 0x07;
const ADC_SARADC_ENT_TSENS_ADDR_MSB: u8 = 2; const ADC_SARADC_ENT_TSENS_ADDR_MSB: u8 = 2;
const ADC_SARADC_ENT_TSENS_ADDR_LSB: u8 = 2; const ADC_SARADC_ENT_TSENS_ADDR_LSB: u8 = 2;
use crate::regi2c_write_mask; use crate::rom::regi2c_write_mask;
/// Enable true randomness by enabling the entropy source. /// Enable true randomness by enabling the entropy source.
/// Blocks `ADC` usage. /// Blocks `ADC` usage.

View File

@ -9,11 +9,13 @@
//! * I2S_SCLK: 160_000_000 - I2S clock frequency //! * I2S_SCLK: 160_000_000 - I2S clock frequency
//! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source //! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source
pub mod efuse; crate::unstable_module! {
pub mod efuse;
pub mod radio_clocks;
pub mod trng;
}
pub mod gpio; pub mod gpio;
pub mod peripherals; pub mod peripherals;
pub mod radio_clocks;
pub mod trng;
/// The name of the chip ("esp32c3") as `&str` /// The name of the chip ("esp32c3") as `&str`
#[macro_export] #[macro_export]

View File

@ -13,7 +13,7 @@ const ADC_SARADC_ENT_TSENS_ADDR: u8 = 0x07;
const ADC_SARADC_ENT_TSENS_ADDR_MSB: u8 = 2; const ADC_SARADC_ENT_TSENS_ADDR_MSB: u8 = 2;
const ADC_SARADC_ENT_TSENS_ADDR_LSB: u8 = 2; const ADC_SARADC_ENT_TSENS_ADDR_LSB: u8 = 2;
use crate::regi2c_write_mask; use crate::rom::regi2c_write_mask;
/// Enable true randomness by enabling the entropy source. /// Enable true randomness by enabling the entropy source.
/// Blocks `ADC` usage. /// Blocks `ADC` usage.

View File

@ -10,12 +10,14 @@
//! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source //! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source
//! * I2S_SCLK: 160_000_000 - I2S clock frequency //! * I2S_SCLK: 160_000_000 - I2S clock frequency
pub mod efuse; crate::unstable_module! {
pub mod efuse;
pub mod lp_core;
pub mod radio_clocks;
pub mod trng;
}
pub mod gpio; pub mod gpio;
pub mod lp_core;
pub mod peripherals; pub mod peripherals;
pub mod radio_clocks;
pub mod trng;
/// The name of the chip ("esp32c6") as `&str` /// The name of the chip ("esp32c6") as `&str`
#[macro_export] #[macro_export]

View File

@ -10,11 +10,13 @@
//! * I2S_DEFAULT_CLK_SRC: 1 - I2S clock source //! * I2S_DEFAULT_CLK_SRC: 1 - I2S clock source
//! * I2S_SCLK: 96_000_000 - I2S clock frequency //! * I2S_SCLK: 96_000_000 - I2S clock frequency
pub mod efuse; crate::unstable_module! {
pub mod efuse;
pub mod radio_clocks;
pub mod trng;
}
pub mod gpio; pub mod gpio;
pub mod peripherals; pub mod peripherals;
pub mod radio_clocks;
pub mod trng;
/// The name of the chip ("esp32h2") as `&str` /// The name of the chip ("esp32h2") as `&str`
#[macro_export] #[macro_export]

View File

@ -13,15 +13,16 @@ use core::ptr::addr_of_mut;
use crate::rtc_cntl::SocResetReason; use crate::rtc_cntl::SocResetReason;
pub mod efuse; crate::unstable_module! {
pub mod efuse;
#[cfg(feature = "quad-psram")]
pub mod psram;
pub mod radio_clocks;
pub mod trng;
pub mod ulp_core;
}
pub mod gpio; pub mod gpio;
pub mod peripherals; pub mod peripherals;
#[cfg(feature = "quad-psram")]
pub mod psram;
pub mod radio_clocks;
pub mod trng;
pub mod ulp_core;
/// The name of the chip ("esp32s2") as `&str` /// The name of the chip ("esp32s2") as `&str`
#[macro_export] #[macro_export]

View File

@ -13,16 +13,17 @@ use core::ptr::addr_of_mut;
use crate::rtc_cntl::SocResetReason; use crate::rtc_cntl::SocResetReason;
crate::unstable_module! {
pub mod efuse;
#[cfg(any(feature = "quad-psram", feature = "octal-psram"))]
pub mod psram;
pub mod radio_clocks;
pub mod trng;
pub mod ulp_core;
}
pub mod cpu_control; pub mod cpu_control;
pub mod efuse;
pub mod gpio; pub mod gpio;
pub mod peripherals; pub mod peripherals;
#[cfg(any(feature = "quad-psram", feature = "octal-psram"))]
pub mod psram;
pub mod radio_clocks;
pub mod trng;
pub mod ulp_core;
/// The name of the chip ("esp32s3") as `&str` /// The name of the chip ("esp32s3") as `&str`
#[macro_export] #[macro_export]

View File

@ -15,7 +15,7 @@ const ADC_SARADC_DTEST_RTC_ADDR: u32 = 0x7;
const ADC_SARADC_DTEST_RTC_ADDR_MSB: u32 = 1; const ADC_SARADC_DTEST_RTC_ADDR_MSB: u32 = 1;
const ADC_SARADC_DTEST_RTC_ADDR_LSB: u32 = 0; const ADC_SARADC_DTEST_RTC_ADDR_LSB: u32 = 0;
use crate::regi2c_write_mask; use crate::rom::regi2c_write_mask;
/// Enable true randomness by enabling the entropy source. /// Enable true randomness by enabling the entropy source.
/// Blocks `ADC` usage. /// Blocks `ADC` usage.

View File

@ -53,16 +53,20 @@ pub struct MappedPsram {
// Values other than 0 indicate that we cannot attempt setting the mac address // Values other than 0 indicate that we cannot attempt setting the mac address
// again, and values other than 2 indicate that we should read the mac address // again, and values other than 2 indicate that we should read the mac address
// from eFuse. // from eFuse.
#[cfg_attr(not(feature = "unstable"), allow(unused))]
static MAC_OVERRIDE_STATE: AtomicU8 = AtomicU8::new(0); static MAC_OVERRIDE_STATE: AtomicU8 = AtomicU8::new(0);
#[cfg_attr(not(feature = "unstable"), allow(unused))]
static mut MAC_OVERRIDE: [u8; 6] = [0; 6]; static mut MAC_OVERRIDE: [u8; 6] = [0; 6];
/// Error indicating issues with setting the MAC address. /// Error indicating issues with setting the MAC address.
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
#[cfg_attr(not(feature = "unstable"), allow(unused))]
pub enum SetMacError { pub enum SetMacError {
/// The MAC address has already been set and cannot be changed. /// The MAC address has already been set and cannot be changed.
AlreadySet, AlreadySet,
} }
#[cfg_attr(not(feature = "unstable"), allow(unused))]
impl self::efuse::Efuse { impl self::efuse::Efuse {
/// Set the base mac address /// Set the base mac address
/// ///

View File

@ -95,6 +95,7 @@ use crate::{
#[derive(Debug, Hash, EnumSetType)] #[derive(Debug, Hash, EnumSetType)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive] #[non_exhaustive]
#[instability::unstable]
pub enum SpiInterrupt { pub enum SpiInterrupt {
/// Indicates that the SPI transaction has completed successfully. /// Indicates that the SPI transaction has completed successfully.
/// ///
@ -704,6 +705,11 @@ where
/// ///
/// Sets the specified pin to push-pull output and connects it to the SPI CS /// Sets the specified pin to push-pull output and connects it to the SPI CS
/// signal. /// signal.
///
/// # Current Stability Limitations
/// The hardware chip select functionality is limited; only one CS line can
/// be set, regardless of the total number available. There is no
/// mechanism to select which CS line to use.
#[instability::unstable] #[instability::unstable]
pub fn with_cs<CS: PeripheralOutput>(self, cs: impl Peripheral<P = CS> + 'd) -> Self { pub fn with_cs<CS: PeripheralOutput>(self, cs: impl Peripheral<P = CS> + 'd) -> Self {
crate::into_mapped_ref!(cs); crate::into_mapped_ref!(cs);
@ -741,6 +747,10 @@ where
/// ///
/// Enables both input and output functionality for the pin, and connects it /// Enables both input and output functionality for the pin, and connects it
/// to the SIO2 output and input signals. /// to the SIO2 output and input signals.
///
/// # Current Stability Limitations
/// QSPI operations are unstable, associated pins configuration is
/// inefficient.
#[instability::unstable] #[instability::unstable]
pub fn with_sio2<SIO2: PeripheralOutput>(self, sio2: impl Peripheral<P = SIO2> + 'd) -> Self { pub fn with_sio2<SIO2: PeripheralOutput>(self, sio2: impl Peripheral<P = SIO2> + 'd) -> Self {
// TODO: panic if not QSPI? // TODO: panic if not QSPI?
@ -758,6 +768,10 @@ where
/// ///
/// Enables both input and output functionality for the pin, and connects it /// Enables both input and output functionality for the pin, and connects it
/// to the SIO3 output and input signals. /// to the SIO3 output and input signals.
///
/// # Current Stability Limitations
/// QSPI operations are unstable, associated pins configuration is
/// inefficient.
#[instability::unstable] #[instability::unstable]
pub fn with_sio3<SIO3: PeripheralOutput>(self, sio3: impl Peripheral<P = SIO3> + 'd) -> Self { pub fn with_sio3<SIO3: PeripheralOutput>(self, sio3: impl Peripheral<P = SIO3> + 'd) -> Self {
// TODO: panic if not QSPI? // TODO: panic if not QSPI?
@ -3370,7 +3384,7 @@ macro_rules! master_instance {
} }
fn handler(&self) -> InterruptHandler { fn handler(&self) -> InterruptHandler {
#[$crate::macros::handler] #[$crate::handler]
#[cfg_attr(place_spi_driver_in_ram, ram)] #[cfg_attr(place_spi_driver_in_ram, ram)]
fn handle() { fn handle() {
handle_async(unsafe { $crate::peripherals::$peri::steal() }) handle_async(unsafe { $crate::peripherals::$peri::steal() })

View File

@ -429,7 +429,7 @@ impl Alarm {
static mut HANDLERS: [Option<extern "C" fn()>; 3] = [None, None, None]; static mut HANDLERS: [Option<extern "C" fn()>; 3] = [None, None, None];
#[crate::macros::ram] #[crate::ram]
unsafe extern "C" fn _handle_interrupt<const CH: u8>() { unsafe extern "C" fn _handle_interrupt<const CH: u8>() {
if unsafe { &*SYSTIMER::PTR } if unsafe { &*SYSTIMER::PTR }
.int_raw() .int_raw()

View File

@ -530,7 +530,8 @@ mod asynch {
use super::*; use super::*;
use crate::{ use crate::{
asynch::AtomicWaker, asynch::AtomicWaker,
macros::{handler, ram}, handler,
ram,
Async, Async,
}; };

View File

@ -1040,6 +1040,7 @@ impl<'d> Uart<'d, Async> {
#[derive(Debug, EnumSetType)] #[derive(Debug, EnumSetType)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive] #[non_exhaustive]
#[instability::unstable]
pub enum UartInterrupt { pub enum UartInterrupt {
/// Indicates that the received has detected the configured /// Indicates that the received has detected the configured
/// [`Uart::set_at_cmd`] character. /// [`Uart::set_at_cmd`] character.
@ -1238,21 +1239,25 @@ impl InterruptConfigurable for Uart<'_, Blocking> {
impl Uart<'_, Blocking> { impl Uart<'_, Blocking> {
/// Listen for the given interrupts /// Listen for the given interrupts
#[instability::unstable]
pub fn listen(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>) { pub fn listen(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>) {
self.tx.uart.info().enable_listen(interrupts.into(), true) self.tx.uart.info().enable_listen(interrupts.into(), true)
} }
/// Unlisten the given interrupts /// Unlisten the given interrupts
#[instability::unstable]
pub fn unlisten(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>) { pub fn unlisten(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>) {
self.tx.uart.info().enable_listen(interrupts.into(), false) self.tx.uart.info().enable_listen(interrupts.into(), false)
} }
/// Gets asserted interrupts /// Gets asserted interrupts
#[instability::unstable]
pub fn interrupts(&mut self) -> EnumSet<UartInterrupt> { pub fn interrupts(&mut self) -> EnumSet<UartInterrupt> {
self.tx.uart.info().interrupts() self.tx.uart.info().interrupts()
} }
/// Resets asserted interrupts /// Resets asserted interrupts
#[instability::unstable]
pub fn clear_interrupts(&mut self, interrupts: EnumSet<UartInterrupt>) { pub fn clear_interrupts(&mut self, interrupts: EnumSet<UartInterrupt>) {
self.tx.uart.info().clear_interrupts(interrupts) self.tx.uart.info().clear_interrupts(interrupts)
} }
@ -1878,6 +1883,7 @@ pub(super) fn intr_handler(uart: &Info, state: &State) {
/// Low-power UART /// Low-power UART
#[cfg(lp_uart)] #[cfg(lp_uart)]
#[instability::unstable]
pub mod lp_uart { pub mod lp_uart {
use crate::{ use crate::{
gpio::lp_io::{LowPowerInput, LowPowerOutput}, gpio::lp_io::{LowPowerInput, LowPowerOutput},
@ -2510,7 +2516,7 @@ macro_rules! impl_instance {
($inst:ident, $peri:ident, $txd:ident, $rxd:ident, $cts:ident, $rts:ident) => { ($inst:ident, $peri:ident, $txd:ident, $rxd:ident, $cts:ident, $rts:ident) => {
impl Instance for crate::peripherals::$inst { impl Instance for crate::peripherals::$inst {
fn parts(&self) -> (&'static Info, &'static State) { fn parts(&self) -> (&'static Info, &'static State) {
#[crate::macros::handler] #[crate::handler]
pub(super) fn irq_handler() { pub(super) fn irq_handler() {
intr_handler(&PERIPHERAL, &STATE); intr_handler(&PERIPHERAL, &STATE);
} }

View File

@ -2,8 +2,8 @@ use core::{cell::RefCell, ptr::addr_of};
use critical_section::Mutex; use critical_section::Mutex;
use esp_hal::{ use esp_hal::{
handler,
interrupt::Priority, interrupt::Priority,
macros::handler,
peripherals::RADIO_CLK, peripherals::RADIO_CLK,
system::{RadioClockController, RadioPeripherals}, system::{RadioClockController, RadioPeripherals},
}; };

View File

@ -13,7 +13,7 @@ use crate::{
HCI_OUT_COLLECTOR, HCI_OUT_COLLECTOR,
}, },
compat::common::{self, str_from_c, ConcurrentQueue}, compat::common::{self, str_from_c, ConcurrentQueue},
hal::macros::ram, hal::ram,
}; };
#[cfg_attr(esp32c3, path = "os_adapter_esp32c3.rs")] #[cfg_attr(esp32c3, path = "os_adapter_esp32c3.rs")]

View File

@ -4,7 +4,7 @@ use super::phy_init_data::PHY_INIT_DATA_DEFAULT;
use crate::{ use crate::{
binary::include::*, binary::include::*,
hal::{ hal::{
macros::ram, ram,
system::{RadioClockController, RadioPeripherals}, system::{RadioClockController, RadioPeripherals},
}, },
}; };

View File

@ -4,7 +4,7 @@ use super::phy_init_data::PHY_INIT_DATA_DEFAULT;
use crate::{ use crate::{
binary::include::*, binary::include::*,
hal::{ hal::{
macros::ram, ram,
system::{RadioClockController, RadioPeripherals}, system::{RadioClockController, RadioPeripherals},
}, },
}; };

View File

@ -1,5 +1,5 @@
use esp_wifi_sys::include::timeval; use esp_wifi_sys::include::timeval;
use hal::macros::ram; use hal::ram;
use crate::{ use crate::{
binary::include::{esp_event_base_t, esp_timer_get_time}, binary::include::{esp_event_base_t, esp_timer_get_time},

View File

@ -67,8 +67,8 @@ use crate::{
common_adapter::*, common_adapter::*,
esp_wifi_result, esp_wifi_result,
hal::{ hal::{
macros::ram,
peripheral::{Peripheral, PeripheralRef}, peripheral::{Peripheral, PeripheralRef},
ram,
}, },
EspWifiController, EspWifiController,
}; };

View File

@ -12,12 +12,7 @@ use core::cell::RefCell;
use critical_section::Mutex; use critical_section::Mutex;
use esp_backtrace as _; use esp_backtrace as _;
use esp_hal::{ use esp_hal::{assist_debug::DebugAssist, entry, handler, interrupt::InterruptConfigurable};
assist_debug::DebugAssist,
entry,
interrupt::InterruptConfigurable,
macros::handler,
};
use esp_println::println; use esp_println::println;
static DA: Mutex<RefCell<Option<DebugAssist>>> = Mutex::new(RefCell::new(None)); static DA: Mutex<RefCell<Option<DebugAssist>>> = Mutex::new(RefCell::new(None));

View File

@ -3,7 +3,7 @@
//! Uses flash address 0x9000 (default NVS) //! Uses flash address 0x9000 (default NVS)
//! See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#built-in-partition-tables //! See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#built-in-partition-tables
//% FEATURES: esp-storage //% FEATURES: esp-storage esp-hal/unstable
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
#![no_std] #![no_std]

View File

@ -8,6 +8,7 @@
//! - BUTTON => GPIO0 (ESP32, ESP32-S2, ESP32-S3) / GPIO9 //! - BUTTON => GPIO0 (ESP32, ESP32-S2, ESP32-S3) / GPIO9
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: esp-hal/unstable
#![no_std] #![no_std]
#![no_main] #![no_main]
@ -20,8 +21,9 @@ use esp_hal::{
delay::Delay, delay::Delay,
entry, entry,
gpio::{Event, Input, Io, Level, Output, Pull}, gpio::{Event, Input, Io, Level, Output, Pull},
handler,
interrupt::InterruptConfigurable, interrupt::InterruptConfigurable,
macros::{handler, ram}, ram,
}; };
static BUTTON: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None)); static BUTTON: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None));

View File

@ -18,8 +18,8 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
entry, entry,
gpio::lp_io::LowPowerOutput, gpio::lp_io::LowPowerOutput,
load_lp_code,
lp_core::{LpCore, LpCoreWakeupSource}, lp_core::{LpCore, LpCoreWakeupSource},
macros::load_lp_code,
}; };
use esp_println::{print, println}; use esp_println::{print, println};

View File

@ -20,8 +20,9 @@ use esp_hal::{
delay::Delay, delay::Delay,
entry, entry,
gpio::GpioPin, gpio::GpioPin,
handler,
interrupt::InterruptConfigurable, interrupt::InterruptConfigurable,
macros::{handler, ram}, ram,
rtc_cntl::Rtc, rtc_cntl::Rtc,
touch::{Continuous, Touch, TouchConfig, TouchPad}, touch::{Continuous, Touch, TouchConfig, TouchPad},
Blocking, Blocking,

View File

@ -12,8 +12,8 @@ use critical_section::Mutex;
use esp_hal::{ use esp_hal::{
clock::CpuClock, clock::CpuClock,
delay::Delay, delay::Delay,
handler,
interrupt::software::{SoftwareInterrupt, SoftwareInterruptControl}, interrupt::software::{SoftwareInterrupt, SoftwareInterruptControl},
macros::handler,
peripherals::Peripherals, peripherals::Peripherals,
rng::Rng, rng::Rng,
timer::timg::TimerGroup, timer::timg::TimerGroup,

View File

@ -7,19 +7,20 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
#[cfg(feature = "unstable")] // unused in stable build
use core::cell::RefCell; use core::cell::RefCell;
#[cfg(feature = "unstable")] // unused in stable build
use critical_section::Mutex; use critical_section::Mutex;
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
use embassy_time::{Duration, Timer}; use embassy_time::{Duration, Timer};
use esp_hal::{ use esp_hal::gpio::{AnyPin, Input, Level, Output, Pin, Pull};
delay::Delay,
gpio::{AnyPin, Input, Level, Output, OutputOpenDrain, Pin, Pull},
macros::handler,
};
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
use esp_hal::{ use esp_hal::{
gpio::{Event, Flex, Io}, // OutputOpenDrain is here because will be unused otherwise
delay::Delay,
gpio::{Event, Flex, Io, OutputOpenDrain},
handler,
interrupt::InterruptConfigurable, interrupt::InterruptConfigurable,
timer::timg::TimerGroup, timer::timg::TimerGroup,
}; };
@ -27,16 +28,20 @@ use hil_test as _;
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
use portable_atomic::{AtomicUsize, Ordering}; use portable_atomic::{AtomicUsize, Ordering};
#[cfg(feature = "unstable")] // unused in stable build
static COUNTER: Mutex<RefCell<u32>> = Mutex::new(RefCell::new(0)); static COUNTER: Mutex<RefCell<u32>> = Mutex::new(RefCell::new(0));
#[cfg(feature = "unstable")] // unused in stable build
static INPUT_PIN: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None)); static INPUT_PIN: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None));
struct Context { struct Context {
test_gpio1: AnyPin, test_gpio1: AnyPin,
test_gpio2: AnyPin, test_gpio2: AnyPin,
#[cfg(feature = "unstable")]
delay: Delay, delay: Delay,
} }
#[handler] #[cfg_attr(feature = "unstable", handler)]
#[cfg(feature = "unstable")]
pub fn interrupt_handler() { pub fn interrupt_handler() {
critical_section::with(|cs| { critical_section::with(|cs| {
*COUNTER.borrow_ref_mut(cs) += 1; *COUNTER.borrow_ref_mut(cs) += 1;
@ -56,6 +61,7 @@ mod tests {
fn init() -> Context { fn init() -> Context {
let peripherals = esp_hal::init(esp_hal::Config::default()); let peripherals = esp_hal::init(esp_hal::Config::default());
#[cfg(feature = "unstable")]
let delay = Delay::new(); let delay = Delay::new();
let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals); let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals);
@ -74,6 +80,7 @@ mod tests {
Context { Context {
test_gpio1: gpio1.degrade(), test_gpio1: gpio1.degrade(),
test_gpio2: gpio2.degrade(), test_gpio2: gpio2.degrade(),
#[cfg(feature = "unstable")]
delay, delay,
} }
} }
@ -244,6 +251,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(feature = "unstable")] // delay is unstable
fn gpio_od(ctx: Context) { fn gpio_od(ctx: Context) {
let mut test_gpio1 = OutputOpenDrain::new(ctx.test_gpio1, Level::High, Pull::Up); let mut test_gpio1 = OutputOpenDrain::new(ctx.test_gpio1, Level::High, Pull::Up);
let mut test_gpio2 = OutputOpenDrain::new(ctx.test_gpio2, Level::High, Pull::Up); let mut test_gpio2 = OutputOpenDrain::new(ctx.test_gpio2, Level::High, Pull::Up);

View File

@ -14,8 +14,8 @@
use embassy_time::{Duration, Timer}; use embassy_time::{Duration, Timer};
use esp_hal::{ use esp_hal::{
gpio::{AnyPin, Flex, Input, Io, Level, Output, Pull}, gpio::{AnyPin, Flex, Input, Io, Level, Output, Pull},
handler,
interrupt::InterruptConfigurable, interrupt::InterruptConfigurable,
macros::handler,
timer::timg::TimerGroup, timer::timg::TimerGroup,
}; };
use hil_test as _; use hil_test as _;

View File

@ -13,7 +13,7 @@ use critical_section::Mutex;
use embedded_hal::delay::DelayNs; use embedded_hal::delay::DelayNs;
use esp_hal::{ use esp_hal::{
delay::Delay, delay::Delay,
macros::handler, handler,
time::ExtU64, time::ExtU64,
timer::{ timer::{
systimer::{Alarm, SystemTimer}, systimer::{Alarm, SystemTimer},

View File

@ -16,7 +16,7 @@ use embassy_executor::{raw::TaskStorage, Spawner};
use esp_backtrace as _; use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::{Clock, CpuClock}, clock::{Clock, CpuClock},
macros::handler, handler,
time::Duration, time::Duration,
timer::{systimer::SystemTimer, OneShotTimer}, timer::{systimer::SystemTimer, OneShotTimer},
}; };

View File

@ -18,7 +18,7 @@
#![no_main] #![no_main]
use esp_backtrace as _; use esp_backtrace as _;
use esp_hal::{delay::Delay, entry, macros::ram, rtc_cntl::Rtc, time::ExtU64}; use esp_hal::{delay::Delay, entry, ram, rtc_cntl::Rtc, time::ExtU64};
use esp_println::println; use esp_println::println;
#[ram(rtc_fast)] #[ram(rtc_fast)]