Touch up dependencies (#4280)

* Remove esp-metadata dependency

* Update dependencies

* Remove litrs
This commit is contained in:
Dániel Buga 2025-10-07 15:18:33 +02:00 committed by GitHub
parent a179a9c810
commit 6869eedc92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
49 changed files with 754 additions and 352 deletions

View File

@ -31,10 +31,10 @@ test = false
[dependencies]
allocator-api2 = { version = "0.3.0", default-features = false }
defmt = { version = "1.0.1", optional = true }
cfg-if = "1.0.0"
enumset = "1.1.6"
cfg-if = "1"
enumset = "1"
esp-sync = { version = "0.0.0", path = "../esp-sync" }
document-features = "0.2.11"
document-features = "0.2"
linked_list_allocator = { version = "0.10.5", default-features = false, features = ["const_mut_refs"] }
rlsf = { version = "0.2", features = ["unstable"] }

View File

@ -32,14 +32,14 @@ bench = false
test = false
[dependencies]
cfg-if = "1.0.0"
cfg-if = "1"
defmt = { version = "1", optional = true }
esp-config = { version = "0.5.0", path = "../esp-config" }
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated" }
esp-println = { version = "0.15.0", optional = true, default-features = false, path = "../esp-println" }
heapless = "0.8"
heapless = "0.9"
semihosting = { version = "0.1.20", optional = true }
document-features = "0.2.11"
document-features = "0.2"
[target.'cfg(target_arch = "riscv32")'.dependencies]
riscv = { version = "0.15.0" }

View File

@ -29,14 +29,14 @@ bench = false
test = true
[dependencies]
cfg-if = "1.0.0"
cfg-if = "1"
defmt = { version = "1.0.1", optional = true }
document-features = "0.2.11"
document-features = "0.2"
esp-config = { version = "0.5.0", path = "../esp-config" }
esp-rom-sys = { version = "0.1.1", path = "../esp-rom-sys", optional = true }
embedded-storage = "0.3.1"
log-04 = { package = "log", version = "0.4.26", optional = true }
strum = { version = "0.27.1", default-features = false, features = ["derive"] }
log-04 = { package = "log", version = "0.4", optional = true }
strum = { version = "0.27", default-features = false, features = ["derive"] }
crc = { version = "3.3.0", optional = true }
md-5 = { version = "0.10.6", default-features = false, optional = true }

View File

@ -27,24 +27,23 @@ name = "esp-config"
required-features = ["tui"]
[dependencies]
document-features = "0.2.11"
document-features = "0.2"
# used by the `build` and `tui` feature
serde = { version = "1.0.197", default-features = false, features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde_yaml = { version = "0.9", optional = true }
somni-expr = { version = "0.2.0", optional = true }
esp-metadata = { version = "0.8.0", path = "../esp-metadata", features = ["clap"], optional = true }
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated", features = ["build-script"], optional = true }
# used by the `tui` feature
clap = { version = "4.5.32", features = ["derive"], optional = true }
crossterm = { version = "0.28.1", optional = true }
env_logger = { version = "0.11.7", optional = true }
log = { version = "0.4.26", optional = true }
ratatui = { version = "0.29.0", features = ["crossterm", "unstable"], optional = true }
toml_edit = { version = "0.22.26", optional = true }
tui-textarea = { version = "0.7.0", optional = true }
cargo_metadata = { version = "0.19.2", optional = true }
clap = { version = "4.5", features = ["derive"], optional = true }
env_logger = { version = "0.11", optional = true }
log = { version = "0.4", optional = true }
ratatui = { version = "0.29", features = ["crossterm", "unstable"], optional = true }
toml_edit = { version = "0.23", optional = true }
tui-textarea = { version = "0.7", optional = true }
cargo_metadata = { version = "0.23", optional = true }
[dev-dependencies]
temp-env = "0.3.6"
@ -57,7 +56,6 @@ build = ["dep:serde", "dep:serde_yaml", "dep:somni-expr", "dep:esp-metadata-gene
## The TUI
tui = [
"dep:clap",
"dep:crossterm",
"dep:env_logger",
"dep:log",
"dep:ratatui",

View File

@ -1,12 +1,16 @@
use std::{collections::HashMap, error::Error, io};
use crossterm::{
ExecutableCommand,
event::{self, Event, KeyCode, KeyEventKind},
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
};
use esp_config::{DisplayHint, Stability, Validator, Value};
use ratatui::{prelude::*, style::palette::tailwind, widgets::*};
use ratatui::{
crossterm::{
ExecutableCommand,
event::{self, Event, KeyCode, KeyEventKind},
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
},
prelude::*,
style::palette::tailwind,
widgets::*,
};
use tui_textarea::{CursorMove, TextArea};
use crate::CrateConfig;

View File

@ -24,14 +24,13 @@ features = ["has-ulp-core", "interrupt", "ram", "is-ulp-core"]
proc-macro = true
[dependencies]
document-features = "0.2.11"
litrs = "0.4.1"
object = { version = "0.36.7", default-features = false, features = ["read_core", "elf"], optional = true }
proc-macro-crate = "3.3.0"
proc-macro2 = "1.0.95"
quote = "1.0.40"
syn = { version = "2.0.100", features = ["extra-traits", "full"] }
termcolor = "1.4.1"
document-features = "0.2"
object = { version = "0.37", default-features = false, features = ["read_core", "elf"], optional = true }
proc-macro-crate = "3.4"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["extra-traits", "full"] }
termcolor = "1.4"
[features]
## Indicates the target device has RTC slow memory available.

View File

@ -205,12 +205,11 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
pub fn load_lp_code(input: TokenStream) -> TokenStream {
use std::{fs, path::Path};
use litrs::StringLit;
use object::{File, Object, ObjectSection, ObjectSymbol, Section, SectionKind};
use parse::Error;
use proc_macro::Span;
use proc_macro_crate::{FoundCrate, crate_name};
use syn::{Ident, parse};
use syn::{Ident, LitStr, parse};
let hal_crate = if cfg!(any(feature = "is-lp-core", feature = "is-ulp-core")) {
crate_name("esp-lp-hal")
@ -225,31 +224,14 @@ pub fn load_lp_code(input: TokenStream) -> TokenStream {
quote!(crate)
};
let first_token = match input.into_iter().next() {
Some(token) => token,
None => {
return Error::new(
Span::call_site().into(),
"You need to give the path to an ELF file",
)
.to_compile_error()
.into();
}
let lit: LitStr = match syn::parse(input) {
Ok(lit) => lit,
Err(e) => return e.into_compile_error().into(),
};
let arg = match StringLit::try_from(&first_token) {
Ok(arg) => arg,
Err(_) => {
return Error::new(
Span::call_site().into(),
"You need to give the path to an ELF file",
)
.to_compile_error()
.into();
}
};
let elf_file = arg.value();
if !Path::new(elf_file).exists() {
let elf_file = lit.value();
if !Path::new(&elf_file).exists() {
return Error::new(Span::call_site().into(), "File not found")
.to_compile_error()
.into();

View File

@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `rmt::Error` now implements `core::error::Error` (#4247)
- `ram(reclaimed)` as an alias for `link_section = ".dram2_uninit"` (#4245)
- `rmt::MAX_TX_LOOPCOUNT` and `rmt::MAX_RX_IDLE_THRESHOLD` constants have been added (#4276)
- Added support for `embedded-io 0.7` (#4280)
### Changed

View File

@ -45,22 +45,22 @@ bench = false
test = false
[dependencies]
bitflags = "2.9.0"
bytemuck = "1.22.0"
cfg-if = "1.0.0"
critical-section = { version = "1.2.0", features = ["restore-state-u32"], optional = true }
bitflags = "2.9"
bytemuck = "1.24"
cfg-if = "1"
critical-section = { version = "1", features = ["restore-state-u32"], optional = true }
embedded-hal = "1.0.0"
embedded-hal-async = "1.0.0"
enumset = "1.1.6"
enumset = "1.1"
paste = "1.0.15"
portable-atomic = { version = "1.11.0", default-features = false }
portable-atomic = { version = "1.11", default-features = false }
esp-rom-sys = { version = "0.1.1", path = "../esp-rom-sys" }
# Unstable dependencies that are not (strictly) part of the public API
bitfield = "0.19.0"
delegate = "0.13.3"
document-features = "0.2.11"
bitfield = "0.19"
delegate = "0.13"
document-features = "0.2"
embassy-futures = "0.1"
embassy-sync = "0.7"
fugit = "0.3.7"
@ -75,15 +75,15 @@ procmacros = { version = "0.19.0", package = "esp-hal-procmacros",
# Dependencies that are optional because they are used by unstable drivers.
# They are needed when using the `unstable` feature.
digest = { version = "0.10.7", default-features = false, optional = true }
embassy-usb-driver = { version = "0.2.0", optional = true }
embassy-usb-synopsys-otg = { version = "0.3.0", optional = true }
embassy-usb-driver = { version = "0.2", optional = true }
embassy-usb-synopsys-otg = { version = "0.3", optional = true }
embedded-can = { version = "0.4.1", optional = true }
esp-synopsys-usb-otg = { version = "0.4.2", optional = true }
nb = { version = "1.1.0", optional = true }
nb = { version = "1.1", optional = true }
# Logging interfaces, they are mutually exclusive so they need to be behind separate features.
defmt = { version = "1.0.1", optional = true }
log-04 = { package = "log", version = "0.4.27", optional = true }
log-04 = { package = "log", version = "0.4", optional = true }
# ESP32-only fallback SHA algorithms
sha1 = { version = "0.10", default-features = false, optional = true }
@ -92,12 +92,14 @@ sha2 = { version = "0.10", default-features = false, optiona
# Optional dependencies that enable ecosystem support.
# We could support individually enabling them, but there is no big downside to just
# enabling them all via the `unstable` feature.
embassy-embedded-hal = { version = "0.5.0", optional = true }
embedded-io = { version = "0.6.1", optional = true }
embedded-io-async = { version = "0.6.1", optional = true }
rand_core-06 = { package = "rand_core", version = "0.6.4", optional = true }
rand_core-09 = { package = "rand_core", version = "0.9.0", optional = true }
ufmt-write = { version = "0.1.0", optional = true }
embassy-embedded-hal = { version = "0.5", optional = true }
embedded-io-06 = { package = "embedded-io", version = "0.6", optional = true }
embedded-io-async-06 = { package = "embedded-io-async", version = "0.6", optional = true }
embedded-io-07 = { package = "embedded-io", version = "0.7", optional = true }
embedded-io-async-07 = { package = "embedded-io-async", version = "0.7", optional = true }
rand_core-06 = { package = "rand_core", version = "0.6", optional = true }
rand_core-09 = { package = "rand_core", version = "0.9", optional = true }
ufmt-write = { version = "0.1", optional = true }
# IMPORTANT:
# Each supported device MUST have its PAC included below along with a
@ -119,14 +121,12 @@ xtensa-lx = { version = "0.12.0", path = "../xtensa-lx" }
xtensa-lx-rt = { version = "0.20.0", path = "../xtensa-lx-rt", optional = true }
[build-dependencies]
cfg-if = "1.0.0"
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated", features = ["build-script"] }
esp-config = { version = "0.5.0", path = "../esp-config", features = ["build"] }
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
[dev-dependencies]
crypto-bigint = { version = "0.5.5", default-features = false }
jiff = { version = "0.2.10", default-features = false, features = ["static"] }
jiff = { version = "0.2", default-features = false, features = ["static"] }
[features]
default = ["rt", "exception-handler"]
@ -241,9 +241,10 @@ defmt = [
"dep:defmt",
"embassy-futures/defmt",
"embassy-sync/defmt",
"embedded-hal/defmt-03",
"embedded-io?/defmt-03",
"embedded-io-async?/defmt-03",
"embedded-io-06?/defmt-03",
"embedded-io-async-06?/defmt-03",
"embedded-io-07?/defmt",
"embedded-io-async-07?/defmt",
"enumset/defmt",
"esp32?/defmt",
"esp32c2?/defmt",
@ -274,8 +275,10 @@ unstable = [
"dep:digest",
"dep:embassy-embedded-hal",
"dep:embedded-can",
"dep:embedded-io",
"dep:embedded-io-async",
"dep:embedded-io-06",
"dep:embedded-io-async-06",
"dep:embedded-io-07",
"dep:embedded-io-async-07",
"dep:rand_core-06",
"dep:rand_core-09",
"dep:nb",

View File

@ -47,7 +47,10 @@ impl<const SIZE: usize> Stack<SIZE> {
/// Construct a stack of length SIZE, uninitialized
#[instability::unstable]
pub const fn new() -> Stack<SIZE> {
::core::assert!(SIZE % 16 == 0); // Make sure stack top is aligned, too.
const {
// Make sure stack top is aligned, too.
::core::assert!(SIZE.is_multiple_of(16));
}
Stack {
mem: MaybeUninit::uninit(),

View File

@ -48,7 +48,10 @@ impl<const SIZE: usize> Stack<SIZE> {
/// Construct a stack of length SIZE, uninitialized
#[instability::unstable]
pub const fn new() -> Stack<SIZE> {
::core::assert!(SIZE % 16 == 0); // Make sure stack top is aligned, too.
const {
// Make sure stack top is aligned, too.
::core::assert!(SIZE.is_multiple_of(16));
}
Stack {
mem: MaybeUninit::uninit(),

View File

@ -37,9 +37,9 @@
//! with this driver.
//!
//! [embedded-hal]: embedded_hal
//! [embedded-io]: embedded_io
//! [embedded-io]: embedded_io_07
//! [embedded-hal-async]: embedded_hal_async
//! [embedded-io-async]: embedded_io_async
//! [embedded-io-async]: embedded_io_async_07
/// UHCI wrapper around UART
// TODO add support for PDMA and multiple UHCI for 32/S2 support
@ -49,8 +49,6 @@ pub mod uhci;
use core::{marker::PhantomData, sync::atomic::Ordering, task::Poll};
#[cfg(feature = "unstable")]
use embedded_io::ReadExactError;
use enumset::{EnumSet, EnumSetType};
use portable_atomic::AtomicBool;
@ -122,9 +120,16 @@ impl core::fmt::Display for RxError {
}
#[instability::unstable]
impl embedded_io::Error for RxError {
fn kind(&self) -> embedded_io::ErrorKind {
embedded_io::ErrorKind::Other
impl embedded_io_06::Error for RxError {
fn kind(&self) -> embedded_io_06::ErrorKind {
embedded_io_06::ErrorKind::Other
}
}
#[instability::unstable]
impl embedded_io_07::Error for RxError {
fn kind(&self) -> embedded_io_07::ErrorKind {
embedded_io_07::ErrorKind::Other
}
}
@ -143,9 +148,15 @@ impl core::fmt::Display for TxError {
impl core::error::Error for TxError {}
#[instability::unstable]
impl embedded_io::Error for TxError {
fn kind(&self) -> embedded_io::ErrorKind {
embedded_io::ErrorKind::Other
impl embedded_io_06::Error for TxError {
fn kind(&self) -> embedded_io_06::ErrorKind {
embedded_io_06::ErrorKind::Other
}
}
#[instability::unstable]
impl embedded_io_07::Error for TxError {
fn kind(&self) -> embedded_io_07::ErrorKind {
embedded_io_07::ErrorKind::Other
}
}
@ -2012,9 +2023,16 @@ impl core::fmt::Display for IoError {
}
#[instability::unstable]
impl embedded_io::Error for IoError {
fn kind(&self) -> embedded_io::ErrorKind {
embedded_io::ErrorKind::Other
impl embedded_io_06::Error for IoError {
fn kind(&self) -> embedded_io_06::ErrorKind {
embedded_io_06::ErrorKind::Other
}
}
#[instability::unstable]
impl embedded_io_07::Error for IoError {
fn kind(&self) -> embedded_io_07::ErrorKind {
embedded_io_07::ErrorKind::Other
}
}
@ -2033,22 +2051,22 @@ impl From<TxError> for IoError {
}
#[instability::unstable]
impl<Dm: DriverMode> embedded_io::ErrorType for Uart<'_, Dm> {
impl<Dm: DriverMode> embedded_io_06::ErrorType for Uart<'_, Dm> {
type Error = IoError;
}
#[instability::unstable]
impl<Dm: DriverMode> embedded_io::ErrorType for UartTx<'_, Dm> {
impl<Dm: DriverMode> embedded_io_06::ErrorType for UartTx<'_, Dm> {
type Error = TxError;
}
#[instability::unstable]
impl<Dm: DriverMode> embedded_io::ErrorType for UartRx<'_, Dm> {
impl<Dm: DriverMode> embedded_io_06::ErrorType for UartRx<'_, Dm> {
type Error = RxError;
}
#[instability::unstable]
impl<Dm> embedded_io::Read for Uart<'_, Dm>
impl<Dm> embedded_io_06::Read for Uart<'_, Dm>
where
Dm: DriverMode,
{
@ -2058,7 +2076,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::Read for UartRx<'_, Dm>
impl<Dm> embedded_io_06::Read for UartRx<'_, Dm>
where
Dm: DriverMode,
{
@ -2068,7 +2086,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::ReadReady for Uart<'_, Dm>
impl<Dm> embedded_io_06::ReadReady for Uart<'_, Dm>
where
Dm: DriverMode,
{
@ -2078,7 +2096,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::ReadReady for UartRx<'_, Dm>
impl<Dm> embedded_io_06::ReadReady for UartRx<'_, Dm>
where
Dm: DriverMode,
{
@ -2088,7 +2106,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::Write for Uart<'_, Dm>
impl<Dm> embedded_io_06::Write for Uart<'_, Dm>
where
Dm: DriverMode,
{
@ -2102,7 +2120,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::Write for UartTx<'_, Dm>
impl<Dm> embedded_io_06::Write for UartTx<'_, Dm>
where
Dm: DriverMode,
{
@ -2116,7 +2134,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::WriteReady for UartTx<'_, Dm>
impl<Dm> embedded_io_06::WriteReady for UartTx<'_, Dm>
where
Dm: DriverMode,
{
@ -2126,7 +2144,110 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::WriteReady for Uart<'_, Dm>
impl<Dm> embedded_io_06::WriteReady for Uart<'_, Dm>
where
Dm: DriverMode,
{
fn write_ready(&mut self) -> Result<bool, Self::Error> {
Ok(self.tx.write_ready())
}
}
#[instability::unstable]
impl<Dm: DriverMode> embedded_io_07::ErrorType for Uart<'_, Dm> {
type Error = IoError;
}
#[instability::unstable]
impl<Dm: DriverMode> embedded_io_07::ErrorType for UartTx<'_, Dm> {
type Error = TxError;
}
#[instability::unstable]
impl<Dm: DriverMode> embedded_io_07::ErrorType for UartRx<'_, Dm> {
type Error = RxError;
}
#[instability::unstable]
impl<Dm> embedded_io_07::Read for Uart<'_, Dm>
where
Dm: DriverMode,
{
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.rx.read(buf).map_err(IoError::Rx)
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::Read for UartRx<'_, Dm>
where
Dm: DriverMode,
{
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read(buf)
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::ReadReady for Uart<'_, Dm>
where
Dm: DriverMode,
{
fn read_ready(&mut self) -> Result<bool, Self::Error> {
Ok(self.rx.read_ready())
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::ReadReady for UartRx<'_, Dm>
where
Dm: DriverMode,
{
fn read_ready(&mut self) -> Result<bool, Self::Error> {
Ok(self.read_ready())
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::Write for Uart<'_, Dm>
where
Dm: DriverMode,
{
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.tx.write(buf).map_err(IoError::Tx)
}
fn flush(&mut self) -> Result<(), Self::Error> {
self.tx.flush().map_err(IoError::Tx)
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::Write for UartTx<'_, Dm>
where
Dm: DriverMode,
{
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write(buf)
}
fn flush(&mut self) -> Result<(), Self::Error> {
self.flush()
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::WriteReady for UartTx<'_, Dm>
where
Dm: DriverMode,
{
fn write_ready(&mut self) -> Result<bool, Self::Error> {
Ok(self.write_ready())
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::WriteReady for Uart<'_, Dm>
where
Dm: DriverMode,
{
@ -2272,33 +2393,39 @@ impl Drop for UartTxFuture {
}
#[instability::unstable]
impl embedded_io_async::Read for Uart<'_, Async> {
impl embedded_io_async_06::Read for Uart<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read_async(buf).await.map_err(IoError::Rx)
}
async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError<Self::Error>> {
async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), embedded_io_06::ReadExactError<Self::Error>> {
self.read_exact_async(buf)
.await
.map_err(|e| ReadExactError::Other(IoError::Rx(e)))
.map_err(|e| embedded_io_06::ReadExactError::Other(IoError::Rx(e)))
}
}
#[instability::unstable]
impl embedded_io_async::Read for UartRx<'_, Async> {
impl embedded_io_async_06::Read for UartRx<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read_async(buf).await
}
async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError<Self::Error>> {
async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), embedded_io_06::ReadExactError<Self::Error>> {
self.read_exact_async(buf)
.await
.map_err(ReadExactError::Other)
.map_err(embedded_io_06::ReadExactError::Other)
}
}
#[instability::unstable]
impl embedded_io_async::Write for Uart<'_, Async> {
impl embedded_io_async_06::Write for Uart<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_async(buf).await.map_err(IoError::Tx)
}
@ -2309,7 +2436,61 @@ impl embedded_io_async::Write for Uart<'_, Async> {
}
#[instability::unstable]
impl embedded_io_async::Write for UartTx<'_, Async> {
impl embedded_io_async_06::Write for UartTx<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_async(buf).await
}
async fn flush(&mut self) -> Result<(), Self::Error> {
self.flush_async().await
}
}
#[instability::unstable]
impl embedded_io_async_07::Read for Uart<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read_async(buf).await.map_err(IoError::Rx)
}
async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), embedded_io_07::ReadExactError<Self::Error>> {
self.read_exact_async(buf)
.await
.map_err(|e| embedded_io_07::ReadExactError::Other(IoError::Rx(e)))
}
}
#[instability::unstable]
impl embedded_io_async_07::Read for UartRx<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read_async(buf).await
}
async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), embedded_io_07::ReadExactError<Self::Error>> {
self.read_exact_async(buf)
.await
.map_err(embedded_io_07::ReadExactError::Other)
}
}
#[instability::unstable]
impl embedded_io_async_07::Write for Uart<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_async(buf).await.map_err(IoError::Tx)
}
async fn flush(&mut self) -> Result<(), Self::Error> {
self.flush_async().await.map_err(IoError::Tx)
}
}
#[instability::unstable]
impl embedded_io_async_07::Write for UartTx<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_async(buf).await
}

View File

@ -537,7 +537,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::ErrorType for UsbSerialJtag<'_, Dm>
impl<Dm> embedded_io_06::ErrorType for UsbSerialJtag<'_, Dm>
where
Dm: DriverMode,
{
@ -545,7 +545,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::ErrorType for UsbSerialJtagTx<'_, Dm>
impl<Dm> embedded_io_06::ErrorType for UsbSerialJtagTx<'_, Dm>
where
Dm: DriverMode,
{
@ -553,7 +553,7 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::ErrorType for UsbSerialJtagRx<'_, Dm>
impl<Dm> embedded_io_06::ErrorType for UsbSerialJtagRx<'_, Dm>
where
Dm: DriverMode,
{
@ -561,17 +561,17 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::Read for UsbSerialJtag<'_, Dm>
impl<Dm> embedded_io_06::Read for UsbSerialJtag<'_, Dm>
where
Dm: DriverMode,
{
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
embedded_io::Read::read(&mut self.rx, buf)
embedded_io_06::Read::read(&mut self.rx, buf)
}
}
#[instability::unstable]
impl<Dm> embedded_io::Read for UsbSerialJtagRx<'_, Dm>
impl<Dm> embedded_io_06::Read for UsbSerialJtagRx<'_, Dm>
where
Dm: DriverMode,
{
@ -586,21 +586,100 @@ where
}
#[instability::unstable]
impl<Dm> embedded_io::Write for UsbSerialJtag<'_, Dm>
impl<Dm> embedded_io_06::Write for UsbSerialJtag<'_, Dm>
where
Dm: DriverMode,
{
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
embedded_io::Write::write(&mut self.tx, buf)
embedded_io_06::Write::write(&mut self.tx, buf)
}
fn flush(&mut self) -> Result<(), Self::Error> {
embedded_io::Write::flush(&mut self.tx)
embedded_io_06::Write::flush(&mut self.tx)
}
}
#[instability::unstable]
impl<Dm> embedded_io::Write for UsbSerialJtagTx<'_, Dm>
impl<Dm> embedded_io_06::Write for UsbSerialJtagTx<'_, Dm>
where
Dm: DriverMode,
{
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write(buf)?;
Ok(buf.len())
}
fn flush(&mut self) -> Result<(), Self::Error> {
self.flush_tx()
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::ErrorType for UsbSerialJtag<'_, Dm>
where
Dm: DriverMode,
{
type Error = Error;
}
#[instability::unstable]
impl<Dm> embedded_io_07::ErrorType for UsbSerialJtagTx<'_, Dm>
where
Dm: DriverMode,
{
type Error = Error;
}
#[instability::unstable]
impl<Dm> embedded_io_07::ErrorType for UsbSerialJtagRx<'_, Dm>
where
Dm: DriverMode,
{
type Error = Error;
}
#[instability::unstable]
impl<Dm> embedded_io_07::Read for UsbSerialJtag<'_, Dm>
where
Dm: DriverMode,
{
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
embedded_io_07::Read::read(&mut self.rx, buf)
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::Read for UsbSerialJtagRx<'_, Dm>
where
Dm: DriverMode,
{
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
loop {
let count = self.drain_rx_fifo(buf);
if count > 0 {
return Ok(count);
}
}
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::Write for UsbSerialJtag<'_, Dm>
where
Dm: DriverMode,
{
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
embedded_io_07::Write::write(&mut self.tx, buf)
}
fn flush(&mut self) -> Result<(), Self::Error> {
embedded_io_07::Write::flush(&mut self.tx)
}
}
#[instability::unstable]
impl<Dm> embedded_io_07::Write for UsbSerialJtagTx<'_, Dm>
where
Dm: DriverMode,
{
@ -771,18 +850,18 @@ impl UsbSerialJtagRx<'_, Async> {
}
#[instability::unstable]
impl embedded_io_async::Write for UsbSerialJtag<'_, Async> {
impl embedded_io_async_06::Write for UsbSerialJtag<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
embedded_io_async::Write::write(&mut self.tx, buf).await
embedded_io_async_06::Write::write(&mut self.tx, buf).await
}
async fn flush(&mut self) -> Result<(), Self::Error> {
embedded_io_async::Write::flush(&mut self.tx).await
embedded_io_async_06::Write::flush(&mut self.tx).await
}
}
#[instability::unstable]
impl embedded_io_async::Write for UsbSerialJtagTx<'_, Async> {
impl embedded_io_async_06::Write for UsbSerialJtagTx<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_async(buf).await?;
@ -795,14 +874,51 @@ impl embedded_io_async::Write for UsbSerialJtagTx<'_, Async> {
}
#[instability::unstable]
impl embedded_io_async::Read for UsbSerialJtag<'_, Async> {
impl embedded_io_async_06::Read for UsbSerialJtag<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
embedded_io_async::Read::read(&mut self.rx, buf).await
embedded_io_async_06::Read::read(&mut self.rx, buf).await
}
}
#[instability::unstable]
impl embedded_io_async::Read for UsbSerialJtagRx<'_, Async> {
impl embedded_io_async_06::Read for UsbSerialJtagRx<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read_async(buf).await
}
}
#[instability::unstable]
impl embedded_io_async_07::Write for UsbSerialJtag<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
embedded_io_async_07::Write::write(&mut self.tx, buf).await
}
async fn flush(&mut self) -> Result<(), Self::Error> {
embedded_io_async_07::Write::flush(&mut self.tx).await
}
}
#[instability::unstable]
impl embedded_io_async_07::Write for UsbSerialJtagTx<'_, Async> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_async(buf).await?;
Ok(buf.len())
}
async fn flush(&mut self) -> Result<(), Self::Error> {
self.flush_tx_async().await
}
}
#[instability::unstable]
impl embedded_io_async_07::Read for UsbSerialJtag<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
embedded_io_async_07::Read::read(&mut self.rx, buf).await
}
}
#[instability::unstable]
impl embedded_io_async_07::Read for UsbSerialJtagRx<'_, Async> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read_async(buf).await
}

View File

@ -35,11 +35,12 @@ bench = false
test = false
[dependencies]
cfg-if = "1.0.0"
document-features = "0.2.10"
cfg-if = "1"
document-features = "0.2"
embedded-hal = { version = "1.0.0", optional = true }
embedded-hal-nb = { version = "1.0.0", optional = true }
embedded-io = { version = "0.6.1", optional = true }
embedded-io-06 = { package = "embedded-io", version = "0.6", optional = true }
embedded-io-07 = { package = "embedded-io", version = "0.7", optional = true }
esp32c6-lp = { version = "0.3.0", features = ["critical-section"], optional = true }
esp32s2-ulp = { version = "0.3.0", features = ["critical-section"], optional = true }
esp32s3-ulp = { version = "0.3.0", features = ["critical-section"], optional = true }
@ -77,7 +78,7 @@ esp32s3 = ["dep:esp32s3-ulp", "esp-metadata-generated/esp32s3", "procmacros/is-u
## `embedded-hal-nb` for the relevant peripherals.
embedded-hal = ["dep:embedded-hal", "dep:embedded-hal-nb"]
## Implement the traits defined in `embedded-io` for the relevant peripherals.
embedded-io = ["dep:embedded-io"]
embedded-io = ["dep:embedded-io-06", "dep:embedded-io-07"]
[[example]]
name = "blinky"

View File

@ -51,6 +51,16 @@ pub unsafe fn conjure() -> LpUart {
#[derive(Debug)]
pub enum Error {}
#[cfg(feature = "embedded-io")]
impl core::error::Error for Error {}
#[cfg(feature = "embedded-io")]
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "UART error")
}
}
#[cfg(feature = "embedded-hal")]
impl embedded_hal_nb::serial::Error for Error {
fn kind(&self) -> embedded_hal_nb::serial::ErrorKind {
@ -59,9 +69,16 @@ impl embedded_hal_nb::serial::Error for Error {
}
#[cfg(feature = "embedded-io")]
impl embedded_io::Error for Error {
fn kind(&self) -> embedded_io::ErrorKind {
embedded_io::ErrorKind::Other
impl embedded_io_06::Error for Error {
fn kind(&self) -> embedded_io_06::ErrorKind {
embedded_io_06::ErrorKind::Other
}
}
#[cfg(feature = "embedded-io")]
impl embedded_io_07::Error for Error {
fn kind(&self) -> embedded_io_07::ErrorKind {
embedded_io_07::ErrorKind::Other
}
}
@ -257,12 +274,12 @@ impl embedded_hal_nb::serial::Write for LpUart {
}
#[cfg(feature = "embedded-io")]
impl embedded_io::ErrorType for LpUart {
impl embedded_io_06::ErrorType for LpUart {
type Error = Error;
}
#[cfg(feature = "embedded-io")]
impl embedded_io::Read for LpUart {
impl embedded_io_06::Read for LpUart {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
if buf.is_empty() {
return Ok(0);
@ -283,14 +300,67 @@ impl embedded_io::Read for LpUart {
}
#[cfg(feature = "embedded-io")]
impl embedded_io::ReadReady for LpUart {
impl embedded_io_06::ReadReady for LpUart {
fn read_ready(&mut self) -> Result<bool, Self::Error> {
Ok(self.rx_fifo_count() > 0)
}
}
#[cfg(feature = "embedded-io")]
impl embedded_io::Write for LpUart {
impl embedded_io_06::Write for LpUart {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_bytes(buf)
}
fn flush(&mut self) -> Result<(), Self::Error> {
loop {
match self.flush_tx() {
Ok(_) => break,
Err(nb::Error::WouldBlock) => { /* Wait */ }
#[allow(unreachable_patterns)]
Err(nb::Error::Other(e)) => return Err(e),
}
}
Ok(())
}
}
#[cfg(feature = "embedded-io")]
impl embedded_io_07::ErrorType for LpUart {
type Error = Error;
}
#[cfg(feature = "embedded-io")]
impl embedded_io_07::Read for LpUart {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
if buf.is_empty() {
return Ok(0);
}
while self.rx_fifo_count() == 0 {
// Block until we have received at least one byte
}
let mut count = 0;
while self.rx_fifo_count() > 0 && count < buf.len() {
buf[count] = self.uart.fifo().read().rxfifo_rd_byte().bits();
count += 1;
}
Ok(count)
}
}
#[cfg(feature = "embedded-io")]
impl embedded_io_07::ReadReady for LpUart {
fn read_ready(&mut self) -> Result<bool, Self::Error> {
Ok(self.rx_fifo_count() > 0)
}
}
#[cfg(feature = "embedded-io")]
impl embedded_io_07::Write for LpUart {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write_bytes(buf)
}

View File

@ -17,9 +17,6 @@ clippy-configs = [] # don't waste time on this
[dependencies]
[build-dependencies]
esp-metadata = { version = "0.8.0", path = "../esp-metadata" } # TODO: remove
[features]
build-script = []
_device-selected = []

View File

@ -26,13 +26,13 @@ features = ["esp32c6"]
bench = false
[dependencies]
cfg-if = "1"
esp-hal = { version = "1.0.0-rc.0", path = "../esp-hal", default-features = false, features = ["requires-unstable"] }
esp-wifi-sys = "0.8.1"
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated" }
esp-sync = { version = "0.0.0", path = "../esp-sync" }
cfg-if = "1.0.1"
defmt = { version = "1.0.1", optional = true }
log-04 = { version = "0.4.27", package = "log", optional = true }

View File

@ -36,21 +36,21 @@ bench = false
test = false
[dependencies]
document-features = "0.2.11"
document-features = "0.2"
# Unstable dependencies that are not (strictly) part of the public API
esp-sync = { version = "0.0.0", path = "../esp-sync", optional = true }
# Optional dependencies
portable-atomic = { version = "1.11.0", optional = true, default-features = false }
portable-atomic = { version = "1.11", optional = true, default-features = false }
# Logging interfaces, they are mutually exclusive so they need to be behind separate features.
defmt = { version = "1.0.1", optional = true }
log-04 = { package = "log", version = "0.4.27", optional = true }
log-04 = { package = "log", version = "0.4", optional = true }
[build-dependencies]
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated", features = ["build-script"] }
log-04 = { package = "log", version = "0.4.27" }
log-04 = { package = "log", version = "0.4" }
[features]
default = ["auto", "colors", "critical-section"]

View File

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `dtim_period` parameter for `PowerSaveMode` (#4040)
- `WifiConfig`, `CountryInfo` and `OperatingClass` (#4121)
- Configuration options for `BleController` (#4223, #4254, #4259)
- BLE controller: Added support for `embedded-io 0.7` (#4280)
### Changed

View File

@ -40,20 +40,18 @@ bench = false
test = false
[dependencies]
cfg-if = "1"
esp-hal = { version = "1.0.0-rc.0", path = "../esp-hal", default-features = false, features = ["requires-unstable"] }
cfg-if = "1.0.0"
portable-atomic = { version = "1.11.0", default-features = false }
enumset = { version = "1.1.6", default-features = false, optional = true }
portable-atomic = { version = "1.11", default-features = false }
enumset = { version = "1.1", default-features = false, optional = true }
# ⚠️ Unstable dependencies
embedded-io = { version = "0.6.1", default-features = false }
embedded-io-async = "0.6.1"
esp-radio-rtos-driver = { version = "0.0.1", path = "../esp-radio-rtos-driver" }
instability = "0.3.9"
# Unstable dependencies that are not (strictly) part of the public API
allocator-api2 = { version = "0.3.0", default-features = false, features = ["alloc"] }
document-features = "0.2.11"
document-features = "0.2"
esp-alloc = { version = "0.8.0", path = "../esp-alloc", optional = true }
esp-config = { version = "0.5.0", path = "../esp-config" }
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated" }
@ -70,6 +68,10 @@ ieee802154 = { version = "0.6.1", optional = true }
heapless = "0.9"
# Optional dependencies enabling ecosystem features
embedded-io-06 = { package = "embedded-io", version = "0.6", default-features = false, optional = true }
embedded-io-async-06 = { package = "embedded-io-async", version = "0.6", default-features = false, optional = true }
embedded-io-07 = { package = "embedded-io", version = "0.7", default-features = false, optional = true }
embedded-io-async-07 = { package = "embedded-io-async", version = "0.7", default-features = false, optional = true }
serde = { version = "1.0.218", default-features = false, features = ["derive"], optional = true }
smoltcp = { version = "0.12.0", default-features = false, features = [
"medium-ethernet",
@ -205,7 +207,12 @@ defmt = ["dep:defmt", "smoltcp?/defmt", "esp-hal/defmt", "bt-hci?/defmt", "esp-w
#! ### Unstable APIs
#! Unstable APIs are drivers and features that are not yet ready for general use.
#! They may be incomplete, have bugs, or be subject to change without notice.
unstable = []
unstable = [
"dep:embedded-io-06",
"dep:embedded-io-async-06",
"dep:embedded-io-07",
"dep:embedded-io-async-07",
]
## Libraries that depend on `esp-radio` should enable this feature to indicate their use of unstable APIs.
## However, they must **not** enable the `unstable` feature themselves.

View File

@ -83,7 +83,7 @@ extern "C" fn notify_host_recv(data: *mut u8, len: u16) -> i32 {
super::dump_packet_info(data);
crate::ble::controller::asynch::hci_read_data_available();
crate::ble::controller::hci_read_data_available();
0
}

View File

@ -1,10 +1,19 @@
use embedded_io::{Error, ErrorType, Read, Write};
use core::task::Poll;
use bt_hci::{
ControllerToHostPacket,
FromHciBytes,
FromHciBytesError,
HostToControllerPacket,
WriteHci,
transport::{Transport, WithIndicator},
};
use esp_hal::asynch::AtomicWaker;
use esp_phy::PhyInitGuard;
use super::{read_hci, read_next, send_hci};
use crate::{
Controller,
ble::{Config, InvalidConfigError},
ble::{Config, InvalidConfigError, have_hci_read_data, read_hci, read_next, send_hci},
};
/// A blocking HCI connector
@ -38,6 +47,45 @@ impl<'d> BleConnector<'d> {
pub fn next(&mut self, buf: &mut [u8]) -> Result<usize, BleConnectorError> {
Ok(read_next(buf))
}
/// Read from HCI.
#[instability::unstable]
pub fn read(&mut self, mut buf: &mut [u8]) -> Result<usize, BleConnectorError> {
let mut total = 0;
while !buf.is_empty() {
let len = read_hci(buf);
if len == 0 {
break;
}
buf = &mut buf[len..];
total += len;
}
Ok(total)
}
/// Read from HCI.
#[instability::unstable]
pub async fn read_async(&mut self, buf: &mut [u8]) -> Result<usize, BleConnectorError> {
if buf.is_empty() {
return Ok(0);
}
if !have_hci_read_data() {
HciReadyEventFuture.await;
}
self.read(buf)
}
/// Write to HCI.
#[instability::unstable]
pub fn write(&mut self, buf: &[u8]) -> Result<usize, BleConnectorError> {
for b in buf {
send_hci(&[*b]);
}
Ok(buf.len())
}
}
#[derive(Debug)]
@ -48,9 +96,15 @@ pub enum BleConnectorError {
Unknown,
}
impl Error for BleConnectorError {
fn kind(&self) -> embedded_io::ErrorKind {
embedded_io::ErrorKind::Other
impl embedded_io_06::Error for BleConnectorError {
fn kind(&self) -> embedded_io_06::ErrorKind {
embedded_io_06::ErrorKind::Other
}
}
impl embedded_io_07::Error for BleConnectorError {
fn kind(&self) -> embedded_io_07::ErrorKind {
embedded_io_07::ErrorKind::Other
}
}
@ -64,32 +118,19 @@ impl core::fmt::Display for BleConnectorError {
}
}
impl ErrorType for BleConnector<'_> {
impl embedded_io_06::ErrorType for BleConnector<'_> {
type Error = BleConnectorError;
}
impl Read for BleConnector<'_> {
fn read(&mut self, mut buf: &mut [u8]) -> Result<usize, Self::Error> {
let mut total = 0;
while !buf.is_empty() {
let len = read_hci(buf);
if len == 0 {
break;
}
buf = &mut buf[len..];
total += len;
}
Ok(total)
impl embedded_io_06::Read for BleConnector<'_> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read(buf)
}
}
impl Write for BleConnector<'_> {
impl embedded_io_06::Write for BleConnector<'_> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
for b in buf {
send_hci(&[*b]);
}
Ok(buf.len())
self.write(buf)
}
fn flush(&mut self) -> Result<(), Self::Error> {
@ -98,132 +139,133 @@ impl Write for BleConnector<'_> {
}
}
/// Async Interface
pub(crate) mod asynch {
use core::task::Poll;
impl embedded_io_07::ErrorType for BleConnector<'_> {
type Error = BleConnectorError;
}
use bt_hci::{
ControllerToHostPacket,
FromHciBytes,
FromHciBytesError,
HostToControllerPacket,
WriteHci,
transport::{Transport, WithIndicator},
};
use esp_hal::asynch::AtomicWaker;
impl embedded_io_07::Read for BleConnector<'_> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
self.read(buf)
}
}
use super::*;
use crate::ble::have_hci_read_data;
static HCI_WAKER: AtomicWaker = AtomicWaker::new();
pub(crate) fn hci_read_data_available() {
HCI_WAKER.wake();
impl embedded_io_07::Write for BleConnector<'_> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
self.write(buf)
}
impl embedded_io_async::Read for BleConnector<'_> {
async fn read(&mut self, mut buf: &mut [u8]) -> Result<usize, BleConnectorError> {
if buf.is_empty() {
return Ok(0);
}
fn flush(&mut self) -> Result<(), Self::Error> {
// nothing to do
Ok(())
}
}
let mut total = 0;
if !have_hci_read_data() {
HciReadyEventFuture.await;
}
while !buf.is_empty() {
let len = read_hci(buf);
if len == 0 {
break;
}
static HCI_WAKER: AtomicWaker = AtomicWaker::new();
buf = &mut buf[len..];
total += len;
}
Ok(total)
}
pub(crate) fn hci_read_data_available() {
HCI_WAKER.wake();
}
impl embedded_io_async_06::Read for BleConnector<'_> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, BleConnectorError> {
self.read_async(buf).await
}
}
impl embedded_io_async_06::Write for BleConnector<'_> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, BleConnectorError> {
send_hci(buf);
Ok(buf.len())
}
impl embedded_io_async::Write for BleConnector<'_> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, BleConnectorError> {
send_hci(buf);
Ok(buf.len())
}
async fn flush(&mut self) -> Result<(), BleConnectorError> {
// nothing to do
Ok(())
}
}
async fn flush(&mut self) -> Result<(), BleConnectorError> {
// nothing to do
Ok(())
}
impl embedded_io_async_07::Read for BleConnector<'_> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, BleConnectorError> {
self.read_async(buf).await
}
}
impl embedded_io_async_07::Write for BleConnector<'_> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, BleConnectorError> {
send_hci(buf);
Ok(buf.len())
}
impl From<FromHciBytesError> for BleConnectorError {
fn from(_e: FromHciBytesError) -> Self {
BleConnectorError::Unknown
}
async fn flush(&mut self) -> Result<(), BleConnectorError> {
// nothing to do
Ok(())
}
}
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub(crate) struct HciReadyEventFuture;
impl core::future::Future for HciReadyEventFuture {
type Output = ();
fn poll(
self: core::pin::Pin<&mut Self>,
cx: &mut core::task::Context<'_>,
) -> Poll<Self::Output> {
HCI_WAKER.register(cx.waker());
if have_hci_read_data() {
Poll::Ready(())
} else {
Poll::Pending
}
}
impl From<FromHciBytesError> for BleConnectorError {
fn from(_e: FromHciBytesError) -> Self {
BleConnectorError::Unknown
}
}
fn parse_hci(data: &[u8]) -> Result<Option<ControllerToHostPacket<'_>>, BleConnectorError> {
match ControllerToHostPacket::from_hci_bytes_complete(data) {
Ok(p) => Ok(Some(p)),
Err(e) => {
warn!("[hci] error parsing packet: {:?}", e);
Err(BleConnectorError::Unknown)
}
}
}
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub(crate) struct HciReadyEventFuture;
impl Transport for BleConnector<'_> {
/// Read a complete HCI packet into the rx buffer
async fn read<'a>(
&self,
rx: &'a mut [u8],
) -> Result<ControllerToHostPacket<'a>, Self::Error> {
loop {
if !have_hci_read_data() {
HciReadyEventFuture.await;
}
impl core::future::Future for HciReadyEventFuture {
type Output = ();
// Workaround for borrow checker.
// Safety: we only return a reference to x once, if parsing is successful.
let rx =
unsafe { &mut *core::ptr::slice_from_raw_parts_mut(rx.as_mut_ptr(), rx.len()) };
fn poll(
self: core::pin::Pin<&mut Self>,
cx: &mut core::task::Context<'_>,
) -> Poll<Self::Output> {
HCI_WAKER.register(cx.waker());
let len = crate::ble::read_next(rx);
if let Some(packet) = parse_hci(&rx[..len])? {
return Ok(packet);
}
}
}
/// Write a complete HCI packet from the tx buffer
async fn write<T: HostToControllerPacket>(&self, val: &T) -> Result<(), Self::Error> {
let mut buf: [u8; 259] = [0; 259];
let w = WithIndicator::new(val);
let len = w.size();
w.write_hci(&mut buf[..])
.map_err(|_| BleConnectorError::Unknown)?;
send_hci(&buf[..len]);
Ok(())
if have_hci_read_data() {
Poll::Ready(())
} else {
Poll::Pending
}
}
}
fn parse_hci(data: &[u8]) -> Result<Option<ControllerToHostPacket<'_>>, BleConnectorError> {
match ControllerToHostPacket::from_hci_bytes_complete(data) {
Ok(p) => Ok(Some(p)),
Err(e) => {
warn!("[hci] error parsing packet: {:?}", e);
Err(BleConnectorError::Unknown)
}
}
}
impl Transport for BleConnector<'_> {
/// Read a complete HCI packet into the rx buffer
async fn read<'a>(&self, rx: &'a mut [u8]) -> Result<ControllerToHostPacket<'a>, Self::Error> {
loop {
if !have_hci_read_data() {
HciReadyEventFuture.await;
}
// Workaround for borrow checker.
// Safety: we only return a reference to x once, if parsing is successful.
let rx =
unsafe { &mut *core::ptr::slice_from_raw_parts_mut(rx.as_mut_ptr(), rx.len()) };
let len = crate::ble::read_next(rx);
if let Some(packet) = parse_hci(&rx[..len])? {
return Ok(packet);
}
}
}
/// Write a complete HCI packet from the tx buffer
async fn write<T: HostToControllerPacket>(&self, val: &T) -> Result<(), Self::Error> {
let mut buf: [u8; 259] = [0; 259];
let w = WithIndicator::new(val);
let len = w.size();
w.write_hci(&mut buf[..])
.map_err(|_| BleConnectorError::Unknown)?;
send_hci(&buf[..len]);
Ok(())
}
}

View File

@ -1377,7 +1377,7 @@ unsafe extern "C" fn ble_hs_hci_rx_evt(cmd: *const u8, arg: *const c_void) -> i3
r_ble_hci_trans_buf_free(cmd);
}
crate::ble::controller::asynch::hci_read_data_available();
crate::ble::controller::hci_read_data_available();
0
}
@ -1406,7 +1406,7 @@ unsafe extern "C" fn ble_hs_rx_data(om: *const OsMbuf, arg: *const c_void) -> i3
r_os_mbuf_free_chain(om as *mut _);
}
crate::ble::controller::asynch::hci_read_data_available();
crate::ble::controller::hci_read_data_available();
0
}

View File

@ -27,8 +27,8 @@ bench = false
test = false
[dependencies]
document-features = "0.2.11"
defmt = {version = "1.0.1", optional = true}
document-features = "0.2"
defmt = { version = "1.0.1", optional = true }
riscv = "0.15.0"
# We use the `single-hart` feature since starting up harts != 0 is handled by the HAL, not the runtime.
riscv-rt = {version = "0.16.0", features = ["pre-init", "no-exceptions", "no-interrupts", "single-hart", "v-trap", "pre-default-start-trap"]}

View File

@ -25,8 +25,8 @@ bench = false
test = false
[dependencies]
cfg-if = "1.0.1"
document-features = "0.2.11"
cfg-if = "1"
document-features = "0.2"
[build-dependencies]
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated", features = ["build-script"] }

View File

@ -41,14 +41,14 @@ rtos-trace = { version = "0.2.0", optional = true }
# Unstable dependencies that are not (strictly) part of the public API
allocator-api2 = { version = "0.3.0", default-features = false, features = ["alloc"], optional = true }
document-features = "0.2.11"
document-features = "0.2"
embassy-sync = "0.7"
esp-alloc = { version = "0.8.0", path = "../esp-alloc", optional = true }
esp-config = { version = "0.5.0", path = "../esp-config" }
esp-sync = { version = "0.0.0", path = "../esp-sync" }
esp-radio-rtos-driver = { version = "0.0.1", path = "../esp-radio-rtos-driver", optional = true }
macros = { version = "0.19.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
portable-atomic = { version = "1.11.0", default-features = false }
portable-atomic = { version = "1.11", default-features = false }
# Optional dependencies that enable ecosystem support.
embassy-time-driver = { version = "0.2.1", features = [ "tick-hz-1_000_000" ], optional = true }
@ -57,7 +57,7 @@ embassy-time-queue-utils = { version = "0.3.0", optional = true }
# Logging interfaces, they are mutually exclusive so they need to be behind separate features.
defmt = { version = "1.0", optional = true }
log-04 = { package = "log", version = "0.4.27", optional = true }
log-04 = { package = "log", version = "0.4", optional = true }
[build-dependencies]
esp-config = { version = "0.5.0", path = "../esp-config", features = ["build"] }

View File

@ -37,13 +37,7 @@ esp-rom-sys = { version = "0.1.1", path = "../esp-rom-sys", optional = true
defmt = { version = "1.0.1", optional = true }
# Unstable dependencies that are not (strictly) part of the public API
document-features = "0.2.11"
[target.'cfg(target_arch = "riscv32")'.dependencies]
riscv = { version = "0.14.0", optional = true}
[target.'cfg(target_arch = "xtensa")'.dependencies]
xtensa-lx = { version = "0.12.0", path = "../xtensa-lx", optional = true }
document-features = "0.2"
[build-dependencies]
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated", features = ["build-script"] }
@ -72,10 +66,10 @@ esp32c6 = ["esp-hal/esp32c6", "esp-hal/unstable", "esp-rom-sys/esp32c6", "esp-
##
esp32h2 = ["esp-hal/esp32h2", "esp-hal/unstable", "esp-rom-sys/esp32h2", "esp-sync/esp32h2"]
##
esp32 = ["esp-hal/esp32", "esp-hal/unstable", "esp-rom-sys/esp32", "esp-sync/esp32", "xtensa-lx"]
esp32 = ["esp-hal/esp32", "esp-hal/unstable", "esp-rom-sys/esp32", "esp-sync/esp32"]
##
esp32s2 = ["esp-hal/esp32s2", "esp-hal/unstable", "esp-rom-sys/esp32s2", "esp-sync/esp32s2"]
##
esp32s3 = ["esp-hal/esp32s3", "esp-hal/unstable", "esp-rom-sys/esp32s3", "esp-sync/esp32s3", "xtensa-lx"]
esp32s3 = ["esp-hal/esp32s3", "esp-hal/unstable", "esp-rom-sys/esp32s3", "esp-sync/esp32s3"]
## Used for testing on a host.
emulation = []

View File

@ -30,10 +30,10 @@ defmt = { version = "1.0.1", optional = true }
log-04 = { package = "log", version = "0.4", optional = true }
[target.'cfg(target_arch = "riscv32")'.dependencies]
riscv = { version = "0.15.0" }
riscv = { version = "0.15" }
[target.'cfg(target_arch = "xtensa")'.dependencies]
xtensa-lx = { version = "0.12.0", path = "../xtensa-lx" }
xtensa-lx = { version = "0.12", path = "../xtensa-lx" }
[build-dependencies]
esp-metadata-generated = { version = "0.1.0", path = "../esp-metadata-generated", features = ["build-script"] }

View File

@ -6,7 +6,7 @@ publish = false
[dependencies]
embassy-executor = "0.9.0"
embassy-sync = "0.7.0"
embassy-sync = "0.7"
embassy-time = "0.5.0"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",

View File

@ -6,7 +6,7 @@ publish = false
[dependencies]
embassy-executor = "0.9.0"
embassy-sync = "0.7.0"
embassy-sync = "0.7"
embassy-time = "0.5.0"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.1"
cfg-if = "1"
embassy-executor = "0.9.0"
embassy-time = "0.5.0"
esp-backtrace = { path = "../../../esp-backtrace", features = [

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.1"
cfg-if = "1"
embassy-executor = "0.9.0"
embassy-time = "0.5.0"
esp-backtrace = { path = "../../../esp-backtrace", features = [

View File

@ -5,10 +5,10 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.1"
cfg-if = "1"
embassy-executor = "0.9.0"
embassy-sync = "0.7.0"
embedded-io-async = "0.6.1"
embassy-sync = "0.7"
embedded-io-async = "0.7.0"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",
"println",

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.0"
cfg-if = "1"
embassy-executor = "0.9.0"
embassy-time = "0.5.0"
embedded-hal-async = "1.0.0"

View File

@ -6,8 +6,8 @@ publish = false
[dependencies]
embassy-executor = "0.9.0"
embassy-sync = "0.7.0"
embedded-io-async = "0.6.1"
embassy-sync = "0.7"
embedded-io-async = "0.7.0"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",
"println",

View File

@ -7,7 +7,7 @@ publish = false
[dependencies]
embassy-executor = "0.9.0"
embassy-futures = "0.1"
embassy-sync = "0.7.2"
embassy-sync = "0.7"
embassy-time = "0.5.0"
esp-alloc = { path = "../../../esp-alloc" }
esp-backtrace = { path = "../../../esp-backtrace", features = [

View File

@ -6,7 +6,7 @@ publish = false
[dependencies]
embassy-executor = "0.9.0"
embassy-sync = "0.6.2"
embassy-sync = "0.7"
embassy-time = "0.5.0"
esp-alloc = { path = "../../../esp-alloc" }
esp-backtrace = { path = "../../../esp-backtrace", features = [

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.0"
cfg-if = "1"
esp-alloc = { path = "../../../esp-alloc" }
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",

View File

@ -5,8 +5,8 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.0"
critical-section = "1.1.3"
cfg-if = "1"
critical-section = "1"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",
"println",

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.0"
cfg-if = "1"
embedded-storage = "0.3.1"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",

View File

@ -5,8 +5,8 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.0"
critical-section = "1.1.3"
cfg-if = "1"
critical-section = "1"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",
"println",

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.0"
cfg-if = "1"
esp-backtrace = { path = "../../../../esp-backtrace", features = [
"panic-handler",
"println",

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
cfg-if = "1.0.0"
cfg-if = "1"
esp-backtrace = { path = "../../../../esp-backtrace", features = [
"panic-handler",
"println",

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
critical-section = "1.1.3"
critical-section = "1"
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",
"println",

View File

@ -5,7 +5,7 @@ edition = "2024"
publish = false
[dependencies]
critical-section = "1.1.3"
critical-section = "1"
esp-alloc = { path = "../../../esp-alloc" }
esp-backtrace = { path = "../../../esp-backtrace", features = [
"panic-handler",

View File

@ -206,29 +206,29 @@ required-features = ["esp-radio", "esp-alloc"]
[dependencies]
allocator-api2 = { version = "0.3.0", default-features = false, features = ["alloc"] }
cfg-if = "1.0.0"
critical-section = "1.1.3"
cfg-if = "1"
critical-section = "1"
defmt = "1.0.1"
defmt-rtt = { version = "1.0.0", optional = true }
embassy-executor = { version = "0.9.0", default-features = false }
embassy-futures = "0.1"
embedded-storage = "0.3.1"
embassy-sync = "0.6.0"
embassy-sync = "0.7.2"
embassy-time = "0.5.0"
embedded-hal = "1.0.0"
embedded-io = "0.6.1"
embedded-io-async = "0.6.1"
embedded-io = "0.7.1"
embedded-io-async = "0.7.0"
embedded-can = "0.4.1"
embedded-hal-async = "1.0.0"
esp-alloc = { path = "../esp-alloc", optional = true }
esp-bootloader-esp-idf = { path = "../esp-bootloader-esp-idf" }
esp-hal = { path = "../esp-hal", features = ["defmt"] }
esp-rtos = { path = "../esp-rtos", features = ["defmt"], optional = true }
esp-rtos = { path = "../esp-rtos", features = ["defmt"], optional = true }
esp-storage = { path = "../esp-storage", optional = true }
esp-sync = { path = "../esp-sync" }
esp-radio = { path = "../esp-radio", features = ["defmt"], optional = true }
esp-radio-rtos-driver = { path = "../esp-radio-rtos-driver", optional = true }
portable-atomic = "1.11.0"
portable-atomic = "1.11"
static_cell = { version = "2.1.0" }
semihosting = { version = "0.1", features= ["stdio", "panic-handler"] }

View File

@ -7,12 +7,12 @@ publish = false
[dependencies]
blocking-network-stack = { git = "https://github.com/bjoernQ/blocking-network-stack.git", rev = "b3ecefc", optional = true }
cfg-if = "1.0.0"
cfg-if = "1"
embassy-executor = "0.9.0"
embassy-time = "0.5.0"
embassy-futures = "0.1"
embassy-net = { version = "0.7.0", features = [ "tcp", "udp", "dhcpv4", "medium-ethernet"] }
embassy-sync = "0.6.1"
embassy-sync = "0.7"
embedded-graphics = "0.8.1"
embedded-hal-async = "1.0.0"
embedded-io = { version = "0.6.1", default-features = false }

View File

@ -19,7 +19,7 @@ bench = false
test = false
[dependencies]
document-features = "0.2.11"
document-features = "0.2"
defmt = {version = "1.0.1", optional = true}
macros = { version = "0.4.0", package = "xtensa-lx-rt-proc-macros", path = "../xtensa-lx-rt-proc-macros" }
xtensa-lx = { version = "0.12.0", path = "../xtensa-lx" }

View File

@ -18,6 +18,6 @@ bench = false
test = false
[dependencies]
critical-section = "1.2.0"
critical-section = "1"
[features]