Skip to content

Commit 7688504

Browse files
authored
Remove Gpio type aliasses (#2073)
* Remove Gpio type aliasses * Clean up examples
1 parent 9bec6a1 commit 7688504

File tree

15 files changed

+106
-105
lines changed

15 files changed

+106
-105
lines changed

esp-hal/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
- Removed `NoPinType` in favour of `DummyPin`. (#2068)
2424
- Removed the `async`, `embedded-hal-02`, `embedded-hal`, `embedded-io`, `embedded-io-async`, and `ufmt` features (#2070)
25+
- Removed the `GpioN` type aliasses. Use `GpioPin<N>` instead. (#2073)
2526

2627
## [0.20.1] - 2024-08-30
2728

esp-hal/MIGRATING-0.20.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ Instead of manually grabbing peripherals and setting up clocks, you should now c
3535
// ...
3636
}
3737
```
38+
39+
## GPIO changes
40+
41+
The `GpioN` type aliasses are no longer available. You can use `GpioPin<N>` instead.

esp-hal/src/analog/adc/esp32.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -359,29 +359,29 @@ where
359359
mod adc_implementation {
360360
crate::analog::adc::impl_adc_interface! {
361361
ADC1 [
362-
(Gpio36, 0), // Alt. name: SENSOR_VP
363-
(Gpio37, 1), // Alt. name: SENSOR_CAPP
364-
(Gpio38, 2), // Alt. name: SENSOR_CAPN
365-
(Gpio39, 3), // Alt. name: SENSOR_VN
366-
(Gpio33, 4), // Alt. name: 32K_XP
367-
(Gpio32, 5), // Alt. name: 32K_XN
368-
(Gpio34, 6), // Alt. name: VDET_1
369-
(Gpio35, 7), // Alt. name: VDET_2
362+
(GpioPin<36>, 0), // Alt. name: SENSOR_VP
363+
(GpioPin<37>, 1), // Alt. name: SENSOR_CAPP
364+
(GpioPin<38>, 2), // Alt. name: SENSOR_CAPN
365+
(GpioPin<39>, 3), // Alt. name: SENSOR_VN
366+
(GpioPin<33>, 4), // Alt. name: 32K_XP
367+
(GpioPin<32>, 5), // Alt. name: 32K_XN
368+
(GpioPin<34>, 6), // Alt. name: VDET_1
369+
(GpioPin<35>, 7), // Alt. name: VDET_2
370370
]
371371
}
372372

373373
crate::analog::adc::impl_adc_interface! {
374374
ADC2 [
375-
(Gpio4, 0),
376-
(Gpio0, 1),
377-
(Gpio2, 2),
378-
(Gpio15, 3), // Alt. name: MTDO
379-
(Gpio13, 4), // Alt. name: MTCK
380-
(Gpio12, 5), // Alt. name: MTDI
381-
(Gpio14, 6), // Alt. name: MTMS
382-
(Gpio27, 7),
383-
(Gpio25, 8),
384-
(Gpio26, 9),
375+
(GpioPin<4>, 0),
376+
(GpioPin<0>, 1),
377+
(GpioPin<2>, 2),
378+
(GpioPin<15>, 3), // Alt. name: MTDO
379+
(GpioPin<13>, 4), // Alt. name: MTCK
380+
(GpioPin<12>, 5), // Alt. name: MTDI
381+
(GpioPin<14>, 6), // Alt. name: MTMS
382+
(GpioPin<27>, 7),
383+
(GpioPin<25>, 8),
384+
(GpioPin<26>, 9),
385385
]
386386
}
387387
}

esp-hal/src/analog/adc/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ trait AdcCalEfuse {
252252

253253
macro_rules! impl_adc_interface {
254254
($adc:ident [
255-
$( ($pin:ident, $channel:expr) ,)+
255+
$( (GpioPin<$pin:literal>, $channel:expr) ,)+
256256
]) => {
257257
$(
258-
impl $crate::analog::adc::AdcChannel for crate::gpio::$pin {
258+
impl $crate::analog::adc::AdcChannel for crate::gpio::GpioPin<$pin> {
259259
const CHANNEL: u8 = $channel;
260260
}
261261

262-
impl embedded_hal_02::adc::Channel<crate::peripherals::$adc> for crate::gpio::$pin {
262+
impl embedded_hal_02::adc::Channel<crate::peripherals::$adc> for crate::gpio::GpioPin<$pin> {
263263
type ID = u8;
264264

265265
fn channel() -> u8 { $channel }

esp-hal/src/analog/adc/riscv.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,11 @@ where
548548
mod adc_implementation {
549549
crate::analog::adc::impl_adc_interface! {
550550
ADC1 [
551-
(Gpio0, 0),
552-
(Gpio1, 1),
553-
(Gpio2, 2),
554-
(Gpio3, 3),
555-
(Gpio4, 4),
551+
(GpioPin<0>, 0),
552+
(GpioPin<1>, 1),
553+
(GpioPin<2>, 2),
554+
(GpioPin<3>, 3),
555+
(GpioPin<4>, 4),
556556
]
557557
}
558558
}
@@ -561,17 +561,17 @@ mod adc_implementation {
561561
mod adc_implementation {
562562
crate::analog::adc::impl_adc_interface! {
563563
ADC1 [
564-
(Gpio0, 0),
565-
(Gpio1, 1),
566-
(Gpio2, 2),
567-
(Gpio3, 3),
568-
(Gpio4, 4),
564+
(GpioPin<0>, 0),
565+
(GpioPin<1>, 1),
566+
(GpioPin<2>, 2),
567+
(GpioPin<3>, 3),
568+
(GpioPin<4>, 4),
569569
]
570570
}
571571

572572
crate::analog::adc::impl_adc_interface! {
573573
ADC2 [
574-
(Gpio5, 0),
574+
(GpioPin<5>, 0),
575575
]
576576
}
577577
}
@@ -580,13 +580,13 @@ mod adc_implementation {
580580
mod adc_implementation {
581581
crate::analog::adc::impl_adc_interface! {
582582
ADC1 [
583-
(Gpio0, 0),
584-
(Gpio1, 1),
585-
(Gpio2, 2),
586-
(Gpio3, 3),
587-
(Gpio4, 4),
588-
(Gpio5, 5),
589-
(Gpio6, 6),
583+
(GpioPin<0>, 0),
584+
(GpioPin<1>, 1),
585+
(GpioPin<2>, 2),
586+
(GpioPin<3>, 3),
587+
(GpioPin<4>, 4),
588+
(GpioPin<5>, 5),
589+
(GpioPin<6>, 6),
590590
]
591591
}
592592
}
@@ -595,11 +595,11 @@ mod adc_implementation {
595595
mod adc_implementation {
596596
crate::analog::adc::impl_adc_interface! {
597597
ADC1 [
598-
(Gpio1, 0),
599-
(Gpio2, 1),
600-
(Gpio3, 2),
601-
(Gpio4, 3),
602-
(Gpio5, 4),
598+
(GpioPin<1>, 0),
599+
(GpioPin<2>, 1),
600+
(GpioPin<3>, 2),
601+
(GpioPin<4>, 3),
602+
(GpioPin<5>, 4),
603603
]
604604
}
605605
}

esp-hal/src/analog/adc/xtensa.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -607,31 +607,31 @@ where
607607
mod adc_implementation {
608608
crate::analog::adc::impl_adc_interface! {
609609
ADC1 [
610-
(Gpio1, 0),
611-
(Gpio2, 1),
612-
(Gpio3, 2),
613-
(Gpio4, 3),
614-
(Gpio5, 4),
615-
(Gpio6, 5),
616-
(Gpio7, 6),
617-
(Gpio8, 7),
618-
(Gpio9, 8),
619-
(Gpio10, 9),
610+
(GpioPin<1>, 0),
611+
(GpioPin<2>, 1),
612+
(GpioPin<3>, 2),
613+
(GpioPin<4>, 3),
614+
(GpioPin<5>, 4),
615+
(GpioPin<6>, 5),
616+
(GpioPin<7>, 6),
617+
(GpioPin<8>, 7),
618+
(GpioPin<9>, 8),
619+
(GpioPin<10>, 9),
620620
]
621621
}
622622

623623
crate::analog::adc::impl_adc_interface! {
624624
ADC2 [
625-
(Gpio11, 0),
626-
(Gpio12, 1),
627-
(Gpio13, 2),
628-
(Gpio14, 3),
629-
(Gpio15, 4),
630-
(Gpio16, 5),
631-
(Gpio17, 6),
632-
(Gpio18, 7),
633-
(Gpio19, 8),
634-
(Gpio20, 9),
625+
(GpioPin<11>, 0),
626+
(GpioPin<12>, 1),
627+
(GpioPin<13>, 2),
628+
(GpioPin<14>, 3),
629+
(GpioPin<15>, 4),
630+
(GpioPin<16>, 5),
631+
(GpioPin<17>, 6),
632+
(GpioPin<18>, 7),
633+
(GpioPin<19>, 8),
634+
(GpioPin<20>, 9),
635635
]
636636
}
637637
}

esp-hal/src/analog/dac.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ use crate::{
5151
// reason, we will type alias the pins for ease of use later in this module:
5252
cfg_if::cfg_if! {
5353
if #[cfg(esp32)] {
54-
type Dac1Gpio = gpio::Gpio25;
55-
type Dac2Gpio = gpio::Gpio26;
54+
type Dac1Gpio = gpio::GpioPin<25>;
55+
type Dac2Gpio = gpio::GpioPin<26>;
5656
} else if #[cfg(esp32s2)] {
57-
type Dac1Gpio = gpio::Gpio17;
58-
type Dac2Gpio = gpio::Gpio18;
57+
type Dac1Gpio = gpio::GpioPin<17>;
58+
type Dac2Gpio = gpio::GpioPin<18>;
5959
}
6060
}
6161

esp-hal/src/gpio/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,15 +1418,10 @@ macro_rules! gpio {
14181418
)+
14191419
}
14201420

1421-
$(
1422-
#[doc = concat!("Alias for GpioPin<MODE, ", $gpionum, ">")]
1423-
pub type [<Gpio $gpionum >] = GpioPin<$gpionum>;
1424-
)+
1425-
14261421
#[doc(hidden)]
14271422
pub enum ErasedPin {
14281423
$(
1429-
[<Gpio $gpionum >]([<Gpio $gpionum >]),
1424+
[<Gpio $gpionum >](GpioPin<$gpionum>),
14301425
)+
14311426
}
14321427

esp-hal/src/soc/esp32s2/gpio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,5 +443,5 @@ impl InterruptStatusRegisterAccess for InterruptStatusRegisterAccessBank1 {
443443
}
444444

445445
// implement marker traits on USB pins
446-
impl crate::otg_fs::UsbDm for Gpio19 {}
447-
impl crate::otg_fs::UsbDp for Gpio20 {}
446+
impl crate::otg_fs::UsbDm for GpioPin<19> {}
447+
impl crate::otg_fs::UsbDp for GpioPin<20> {}

esp-hal/src/soc/esp32s3/gpio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,5 +493,5 @@ impl InterruptStatusRegisterAccess for InterruptStatusRegisterAccessBank1 {
493493
}
494494

495495
// implement marker traits on USB pins
496-
impl crate::otg_fs::UsbDm for Gpio19 {}
497-
impl crate::otg_fs::UsbDp for Gpio20 {}
496+
impl crate::otg_fs::UsbDm for GpioPin<19> {}
497+
impl crate::otg_fs::UsbDp for GpioPin<20> {}

0 commit comments

Comments
 (0)