Skip to content

Commit 681f4ef

Browse files
authored
Implement UART type erasure (#2381)
* Simplify test * Remove unnecessary refs * Improve readability * Require Instance: PeripheralMarker * Take &self * Avoid unsafe code on non-s2 * SImplify drain_fifo * Simplify read_bytes * Avoid a register read on ESP32 * Deduplicate is_idle functions * Add missing inlines * Move code out of trait * Erase UART instances * Disable LTO
1 parent 561b582 commit 681f4ef

File tree

18 files changed

+683
-609
lines changed

18 files changed

+683
-609
lines changed

esp-hal/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Added `AnySpi` and `AnySpiDmaChannel`. (#2334)
1717
- Added `AnyI2s` and `AnyI2sDmaChannel`. (#2367)
1818
- Added `AnyTwai`. (#2359)
19+
- Added `AnyUart`. (#2381)
1920
- `Pins::steal()` to unsafely obtain GPIO. (#2335)
2021
- `I2c::with_timeout` (#2361)
2122
- `Spi::half_duplex_read` and `Spi::half_duplex_write` (#2373)
@@ -28,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2829
- Peripheral type erasure for TWAI (#2359)
2930
- The SPI driver has been rewritten to allow using half-duplex and full-duplex functionality on the same bus. See the migration guide for details. (#2373)
3031
- Renamed `SpiDma` functions: `dma_transfer` to `transfer`, `dma_write` to `write`, `dma_read` to `read`. (#2373)
32+
- Peripheral type erasure for UART (#2381)
3133

3234
### Fixed
3335

esp-hal/MIGRATING-0.21.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ peripherals:
3232
- I2S
3333
- I2C
3434
- TWAI
35+
- UART
3536

3637
```diff
3738
-Spi<'static, SPI2, FullDuplexMode>

esp-hal/src/soc/esp32/peripherals.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ crate::peripherals! {
6868
TIMG1 <= TIMG1,
6969
TOUCH <= virtual,
7070
[Twai0] TWAI0 <= TWAI0,
71-
UART0 <= UART0,
72-
UART1 <= UART1,
73-
UART2 <= UART2,
71+
[Uart0] UART0 <= UART0,
72+
[Uart1] UART1 <= UART1,
73+
[Uart2] UART2 <= UART2,
7474
UHCI0 <= UHCI0,
7575
UHCI1 <= UHCI1,
7676
WIFI <= virtual,

esp-hal/src/soc/esp32c2/peripherals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ crate::peripherals! {
4545
SYSTIMER <= SYSTIMER,
4646
SW_INTERRUPT <= virtual,
4747
TIMG0 <= TIMG0,
48-
UART0 <= UART0,
49-
UART1 <= UART1,
48+
[Uart0] UART0 <= UART0,
49+
[Uart1] UART1 <= UART1,
5050
WIFI <= virtual,
5151
XTS_AES <= XTS_AES,
5252
MEM2MEM1 <= virtual,

esp-hal/src/soc/esp32c3/peripherals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ crate::peripherals! {
5454
TIMG0 <= TIMG0,
5555
TIMG1 <= TIMG1,
5656
[Twai0] TWAI0 <= TWAI0,
57-
UART0 <= UART0,
58-
UART1 <= UART1,
57+
[Uart0] UART0 <= UART0,
58+
[Uart1] UART1 <= UART1,
5959
UHCI0 <= UHCI0,
6060
UHCI1 <= UHCI1,
6161
USB_DEVICE <= USB_DEVICE,

esp-hal/src/soc/esp32c6/peripherals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ crate::peripherals! {
8383
TRACE0 <= TRACE,
8484
[Twai0] TWAI0 <= TWAI0,
8585
[Twai1] TWAI1 <= TWAI1,
86-
UART0 <= UART0,
87-
UART1 <= UART1,
86+
[Uart0] UART0 <= UART0,
87+
[Uart1] UART1 <= UART1,
8888
UHCI0 <= UHCI0,
8989
USB_DEVICE <= USB_DEVICE,
9090
WIFI <= virtual,

esp-hal/src/soc/esp32h2/peripherals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ crate::peripherals! {
7474
TIMG1 <= TIMG1,
7575
TRACE0 <= TRACE,
7676
[Twai0] TWAI0 <= TWAI0,
77-
UART0 <= UART0,
78-
UART1 <= UART1,
77+
[Uart0] UART0 <= UART0,
78+
[Uart1] UART1 <= UART1,
7979
UHCI0 <= UHCI0,
8080
USB_DEVICE <= USB_DEVICE,
8181
MEM2MEM1 <= virtual,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ crate::peripherals! {
6161
TIMG0 <= TIMG0,
6262
TIMG1 <= TIMG1,
6363
[Twai0] TWAI0 <= TWAI0,
64-
UART0 <= UART0,
65-
UART1 <= UART1,
64+
[Uart0] UART0 <= UART0,
65+
[Uart1] UART1 <= UART1,
6666
UHCI0 <= UHCI0,
6767
ULP_RISCV_CORE <= virtual,
6868
USB0 <= USB0,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ crate::peripherals! {
6767
TIMG0 <= TIMG0,
6868
TIMG1 <= TIMG1,
6969
[Twai0] TWAI0 <= TWAI0,
70-
UART0 <= UART0,
71-
UART1 <= UART1,
72-
UART2 <= UART2,
70+
[Uart0] UART0 <= UART0,
71+
[Uart1] UART1 <= UART1,
72+
[Uart2] UART2 <= UART2,
7373
UHCI0 <= UHCI0,
7474
UHCI1 <= UHCI1,
7575
ULP_RISCV_CORE <= virtual,

0 commit comments

Comments
 (0)