Skip to content

Commit

Permalink
Mark unstable modules, make macros private (#2900)
Browse files Browse the repository at this point in the history
* Mark unstable APIs + make `macros` private

* address reviews

* use `instability` instead of feature

* fix dependencies

* More tagging

* `Persistable` and `procmacros` - unstable

* Adjust for changes

* sure...
  • Loading branch information
playfulFence authored Jan 10, 2025
1 parent e62141f commit 8d948ba
Show file tree
Hide file tree
Showing 55 changed files with 245 additions and 148 deletions.
2 changes: 1 addition & 1 deletion esp-hal-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub fn init(time_driver: impl TimerCollection) {
unsafe {
use esp_hal::interrupt::software::SoftwareInterrupt;

#[esp_hal::macros::ram]
#[esp_hal::ram]
extern "C" fn software3_interrupt() {
// This interrupt is fired when the thread-mode executor's core needs to be
// woken. It doesn't matter which core handles this interrupt first, the
Expand Down
2 changes: 2 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SPI: Fix naming violations for `Mode` enum variants (#2902)
- 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)
- Removed the `I` prefix from `DriveStrength` enum variants. (#2922)
- Removed the `Attenuation` prefix from `Attenuation` enum variants. (#2922)
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 @@ -483,3 +483,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);
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 @@ -1026,6 +1026,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 @@ -2324,7 +2324,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

0 comments on commit 8d948ba

Please sign in to comment.