mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 06:40:47 +00:00
Flatten Uart module, remove unnecessary data, replace methods with apply_config
(#2449)
* Flatten uart config * Do not remember at_command config * Don't save config values in memory * Move config implementations to Info * Changelog * Remove unused methods * apply_config, SetConfig * Fix test * simplify futures * Update esp-hal/CHANGELOG.md Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com> --------- Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com>
This commit is contained in:
parent
ed7960ce8b
commit
665fb0e278
@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- `gpio::{GpioPin, AnyPin, Flex, Output, OutputOpenDrain}::split()` to obtain peripheral interconnect signals. (#2418)
|
- `gpio::{GpioPin, AnyPin, Flex, Output, OutputOpenDrain}::split()` to obtain peripheral interconnect signals. (#2418)
|
||||||
- `gpio::Input::{split(), into_peripheral_output()}` when used with output pins. (#2418)
|
- `gpio::Input::{split(), into_peripheral_output()}` when used with output pins. (#2418)
|
||||||
- `gpio::Output::peripheral_input()` (#2418)
|
- `gpio::Output::peripheral_input()` (#2418)
|
||||||
|
- `{Uart, UartRx, UartTx}::apply_config()` (#2449)
|
||||||
|
- `{Uart, UartRx, UartTx}` now implement `embassy_embedded_hal::SetConfig` (#2449)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Allow users to create DMA `Preparation`s (#2455)
|
- Allow users to create DMA `Preparation`s (#2455)
|
||||||
- The `rmt::asynch::RxChannelAsync` and `rmt::asynch::TxChannelAsync` traits have been moved to `rmt` (#2430)
|
- The `rmt::asynch::RxChannelAsync` and `rmt::asynch::TxChannelAsync` traits have been moved to `rmt` (#2430)
|
||||||
- Calling `AnyPin::output_signals` on an input-only pin (ESP32 GPIO 34-39) will now result in a panic. (#2418)
|
- Calling `AnyPin::output_signals` on an input-only pin (ESP32 GPIO 34-39) will now result in a panic. (#2418)
|
||||||
|
- UART configuration types have been moved to `esp_hal::uart` (#2449)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
@ -74,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Removed the pin type parameters from `lcd_cam::cam::{RxEightBits, RxSixteenBits}` (#2388)
|
- Removed the pin type parameters from `lcd_cam::cam::{RxEightBits, RxSixteenBits}` (#2388)
|
||||||
- Most of the async-specific constructors (`new_async`, `new_async_no_transceiver`) have been removed. (#2430)
|
- Most of the async-specific constructors (`new_async`, `new_async_no_transceiver`) have been removed. (#2430)
|
||||||
- The `configure_for_async` DMA functions have been removed (#2430)
|
- The `configure_for_async` DMA functions have been removed (#2430)
|
||||||
|
- The `Uart::{change_baud, change_stop_bits}` functions have been removed (#2449)
|
||||||
|
|
||||||
## [0.21.1]
|
## [0.21.1]
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ defmt = { version = "0.3.8", optional = true }
|
|||||||
delegate = "0.12.0"
|
delegate = "0.12.0"
|
||||||
digest = { version = "0.10.7", default-features = false, optional = true }
|
digest = { version = "0.10.7", default-features = false, optional = true }
|
||||||
document-features = "0.2.10"
|
document-features = "0.2.10"
|
||||||
|
embassy-embedded-hal = "0.2.0"
|
||||||
embassy-futures = "0.1.1"
|
embassy-futures = "0.1.1"
|
||||||
embassy-sync = "0.6.0"
|
embassy-sync = "0.6.0"
|
||||||
embassy-usb-driver = { version = "0.1.0", optional = true }
|
embassy-usb-driver = { version = "0.1.0", optional = true }
|
||||||
|
@ -230,3 +230,17 @@ The previous signal function have been replaced by `split`. This change affects
|
|||||||
|
|
||||||
`into_peripheral_output`, `split` (for output pins only) and `peripheral_input` have been added to
|
`into_peripheral_output`, `split` (for output pins only) and `peripheral_input` have been added to
|
||||||
the GPIO drivers (`Input`, `Output`, `OutputOpenDrain` and `Flex`) instead.
|
the GPIO drivers (`Input`, `Output`, `OutputOpenDrain` and `Flex`) instead.
|
||||||
|
|
||||||
|
## Changes to peripheral configuration
|
||||||
|
|
||||||
|
### The `uart::config` module has been removed
|
||||||
|
|
||||||
|
The module's contents have been moved into `uart`.
|
||||||
|
|
||||||
|
```diff
|
||||||
|
-use esp_hal::uart::config::Config;
|
||||||
|
+use esp_hal::uart::Config;
|
||||||
|
```
|
||||||
|
|
||||||
|
If you work with multiple configurable peripherals, you may want to import the `uart` module and
|
||||||
|
refer to the `Config` struct as `uart::Config`.
|
||||||
|
1190
esp-hal/src/uart.rs
1190
esp-hal/src/uart.rs
File diff suppressed because it is too large
Load Diff
@ -15,12 +15,7 @@ use esp_backtrace as _;
|
|||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
gpio::Io,
|
gpio::Io,
|
||||||
timer::timg::TimerGroup,
|
timer::timg::TimerGroup,
|
||||||
uart::{
|
uart::{AtCmdConfig, Config, Uart, UartRx, UartTx},
|
||||||
config::{AtCmdConfig, Config},
|
|
||||||
Uart,
|
|
||||||
UartRx,
|
|
||||||
UartTx,
|
|
||||||
},
|
|
||||||
Async,
|
Async,
|
||||||
};
|
};
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
|
@ -22,7 +22,7 @@ use esp_hal::{
|
|||||||
},
|
},
|
||||||
lp_core::{LpCore, LpCoreWakeupSource},
|
lp_core::{LpCore, LpCoreWakeupSource},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
uart::{config::Config, lp_uart::LpUart, Uart},
|
uart::{lp_uart::LpUart, Config, Uart},
|
||||||
};
|
};
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
|
|
||||||
|
@ -15,11 +15,7 @@ use esp_hal::{
|
|||||||
delay::Delay,
|
delay::Delay,
|
||||||
gpio::Io,
|
gpio::Io,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
uart::{
|
uart::{AtCmdConfig, Config, Uart, UartInterrupt},
|
||||||
config::{AtCmdConfig, Config},
|
|
||||||
Uart,
|
|
||||||
UartInterrupt,
|
|
||||||
},
|
|
||||||
Blocking,
|
Blocking,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use embedded_hal_02::serial::{Read, Write};
|
|||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
gpio::Io,
|
gpio::Io,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
uart::{ClockSource, Uart},
|
uart::{self, ClockSource, Uart},
|
||||||
Blocking,
|
Blocking,
|
||||||
};
|
};
|
||||||
use hil_test as _;
|
use hil_test as _;
|
||||||
@ -91,8 +91,14 @@ mod tests {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let mut byte_to_write = 0xA5;
|
let mut byte_to_write = 0xA5;
|
||||||
for (baud, clock_source) in &configs {
|
for (baudrate, clock_source) in configs {
|
||||||
ctx.uart.change_baud(*baud, *clock_source);
|
ctx.uart
|
||||||
|
.apply_config(&uart::Config {
|
||||||
|
baudrate,
|
||||||
|
clock_source,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
ctx.uart.write(byte_to_write).ok();
|
ctx.uart.write(byte_to_write).ok();
|
||||||
let read = block!(ctx.uart.read());
|
let read = block!(ctx.uart.read());
|
||||||
assert_eq!(read, Ok(byte_to_write));
|
assert_eq!(read, Ok(byte_to_write));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user