Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark unstable modules, make macros private #2900

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esp-hal-embassy/src/executor/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::marker::PhantomData;
use embassy_executor::{raw, Spawner};
use esp_hal::Cpu;
#[cfg(multi_core)]
use esp_hal::{interrupt::software::SoftwareInterrupt, macros::handler};
use esp_hal::{handler, interrupt::software::SoftwareInterrupt};
#[cfg(low_power_wait)]
use portable_atomic::{AtomicBool, Ordering};

Expand Down
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

- `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)

Expand Down
10 changes: 10 additions & 0 deletions esp-hal/MIGRATING-0.22.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,13 @@ The ADC attenuation variants are renamed from e.g. `Attenuation0dB` to `_0dB`.
-Attenuation::Attenuation0dB
+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};
```

20 changes: 10 additions & 10 deletions esp-hal/src/analog/adc/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ impl RegisterAccess for crate::peripherals::ADC1 {
fn set_init_code(data: u16) {
let [msb, lsb] = data.to_be_bytes();

crate::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_HIGH_ADDR, msb as u32);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro should probably live in an internal_analog or similar module, rom seems somewhat random to me - it's expanding into a rom function, sure, but if that would be the driving force behind code organization we could just have a big rust.rs file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this - should it get fixed in this PR or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm also not sure 😄

crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, lsb as u32);
}

fn reset() {
Expand All @@ -257,16 +257,16 @@ impl super::CalibrationAccess for crate::peripherals::ADC1 {
const ADC_VAL_MASK: u16 = ADC_VAL_MASK;

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) {
match source {
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 => {
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);
}
}
}
Expand Down Expand Up @@ -348,8 +348,8 @@ impl RegisterAccess for crate::peripherals::ADC2 {
fn set_init_code(data: u16) {
let [msb, lsb] = data.to_be_bytes();

crate::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_HIGH_ADDR, msb as u32);
crate::rom::regi2c_write_mask!(I2C_SAR_ADC, ADC_SAR2_INITIAL_CODE_LOW_ADDR, lsb as u32);
}

fn reset() {
Expand All @@ -371,16 +371,16 @@ impl super::CalibrationAccess for crate::peripherals::ADC2 {
const ADC_VAL_MASK: u16 = ADC_VAL_MASK;

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) {
match source {
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 => {
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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/clock/clocks_ll/esp32.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
clock::{Clock, PllClock, XtalClock},
regi2c_write,
rom::regi2c_write,
};

const REF_CLK_FREQ: u32 = 1000000;
Expand Down
3 changes: 1 addition & 2 deletions esp-hal/src/clock/clocks_ll/esp32c2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
clock::{ApbClock, Clock, CpuClock, PllClock, XtalClock},
regi2c_write,
regi2c_write_mask,
rom::{regi2c_write, regi2c_write_mask},
};

const I2C_BBPLL: u32 = 0x66;
Expand Down
3 changes: 1 addition & 2 deletions esp-hal/src/clock/clocks_ll/esp32c3.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
clock::{ApbClock, Clock, CpuClock, PllClock, XtalClock},
regi2c_write,
regi2c_write_mask,
rom::{regi2c_write, regi2c_write_mask},
};

const I2C_BBPLL: u32 = 0x66;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/dma/gdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use critical_section::CriticalSection;
use crate::{
dma::*,
interrupt::Priority,
macros::handler,
handler,
peripheral::{Peripheral, PeripheralRef},
peripherals::Interrupt,
};
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/dma/pdma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
asynch::AtomicWaker,
dma::*,
interrupt::Priority,
macros::handler,
handler,
peripheral::{Peripheral, PeripheralRef},
peripherals::Interrupt,
};
Expand Down
2 changes: 2 additions & 0 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,8 @@ macro_rules! io_type {
(Analog, $gpionum:literal) => {
// FIXME: the implementation shouldn't be in the GPIO module
#[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> {
/// Configures the pin for analog mode.
fn set_analog(&self, _: $crate::private::Internal) {
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/i2c/master/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,7 @@ macro_rules! instance {
($inst:ident, $peri:ident, $scl:ident, $sda:ident, $interrupt:ident) => {
impl Instance for crate::peripherals::$inst {
fn parts(&self) -> (&Info, &State) {
#[crate::macros::handler]
#[crate::handler]
pub(super) fn irq_handler() {
async_handler(&PERIPHERAL, &STATE);
}
Expand Down
4 changes: 3 additions & 1 deletion esp-hal/src/i2c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
pub mod master;

#[cfg(lp_i2c0)]
pub mod lp_i2c;
crate::unstable_module! {
pub mod lp_i2c;
}
2 changes: 1 addition & 1 deletion esp-hal/src/lcd_cam/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
asynch::AtomicWaker,
interrupt::{InterruptConfigurable, InterruptHandler},
lcd_cam::{cam::Cam, lcd::Lcd},
macros::handler,
handler,
peripheral::Peripheral,
peripherals::{Interrupt, LCD_CAM},
system::GenericPeripheralGuard,
Expand Down
Loading
Loading