mirror of
https://github.com/esp-rs/esp-idf-hal.git
synced 2025-09-27 04:10:30 +00:00
Prep for a new release
This commit is contained in:
parent
c8f5bd88f0
commit
5532468962
@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [?.??.?] - ????-??-??
|
||||
* MSRV 1.75; remove the nightly feature flag from all async trait implementations
|
||||
* Update public dependencies `e-hal` to 1.0.0-rc3 and `embassy-sync` to 0.5 and private dependency `heapless` to 0.8
|
||||
* Allow `cargo check --all-features` to work correctly (there used to be a build error when both the `esp-idf-sys` and the `riscv-ulp-hal` features were enabled)
|
||||
* #351 - Remove the `OutputPin` requirement from SPI SDI pin
|
||||
* #350 - Not checking for ESP_FAIL in AsyncCanDriver::transmit
|
||||
|
18
Cargo.toml
18
Cargo.toml
@ -13,7 +13,7 @@ readme = "README.md"
|
||||
links = "esp_idf_hal"
|
||||
build = "build.rs"
|
||||
documentation = "https://esp-rs.github.io/esp-idf-hal/"
|
||||
rust-version = "1.71"
|
||||
rust-version = "1.75"
|
||||
|
||||
[patch.crates-io]
|
||||
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys" }
|
||||
@ -22,7 +22,7 @@ esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys" }
|
||||
default = ["std", "binstart"]
|
||||
std = ["alloc", "esp-idf-sys/std"]
|
||||
alloc = []
|
||||
nightly = ["embedded-hal-async", "embedded-io-async"]
|
||||
nightly = []
|
||||
esp-idf-sys = ["dep:esp-idf-sys", "atomic-waker"]
|
||||
riscv-ulp-hal = []
|
||||
wake-from-isr = [] # Only enable if you plan to use the `edge-executor` crate
|
||||
@ -39,20 +39,20 @@ libstart = ["esp-idf-sys/libstart"]
|
||||
[dependencies]
|
||||
nb = "1.0.0"
|
||||
embedded-can = "0.4.1"
|
||||
embedded-hal = "=1.0.0-rc.1"
|
||||
embedded-hal = "=1.0.0-rc.3"
|
||||
embedded-hal-0-2 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"] }
|
||||
embedded-hal-nb = "=1.0.0-rc.1"
|
||||
embedded-hal-async = { version = "=1.0.0-rc.1", optional = true }
|
||||
embedded-hal-nb = "=1.0.0-rc.3"
|
||||
embedded-hal-async = "=1.0.0-rc.3"
|
||||
embedded-io = "0.6"
|
||||
embedded-io-async = { version = "0.6", optional = true }
|
||||
esp-idf-sys = { version = "0.33.5", optional = true, default-features = false, features = ["native"] }
|
||||
embedded-io-async = "0.6"
|
||||
esp-idf-sys = { version = "0.33.7", optional = true, default-features = false }
|
||||
critical-section = { version = "1.1.1", optional = true }
|
||||
heapless = "0.7"
|
||||
heapless = "0.8"
|
||||
num_enum = { version = "0.7", default-features = false }
|
||||
enumset = { version = "1", default-features = false }
|
||||
log = { version = "0.4", default-features = false }
|
||||
atomic-waker = { version = "1.1.1", optional = true, default-features = false }
|
||||
embassy-sync = { version = "0.3" }
|
||||
embassy-sync = { version = "0.5" }
|
||||
|
||||
[build-dependencies]
|
||||
embuild = "0.31.3"
|
||||
|
@ -1 +1 @@
|
||||
future-size-threshold = 50
|
||||
future-size-threshold = 900
|
||||
|
@ -1344,7 +1344,6 @@ pub mod continuous {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
#[cfg(not(esp_idf_adc_continuous_isr_iram_safe))]
|
||||
impl<'d> embedded_io_async::Read for AdcDriver<'d> {
|
||||
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
|
||||
|
59
src/delay.rs
59
src/delay.rs
@ -99,9 +99,14 @@ extern "C" {
|
||||
}
|
||||
|
||||
impl Ets {
|
||||
#[deprecated = "Use delay_ns instead"]
|
||||
pub fn delay_us(us: u32) {
|
||||
Self::delay_ns(us)
|
||||
}
|
||||
|
||||
pub fn delay_ns(ns: u32) {
|
||||
unsafe {
|
||||
ets_delay_us(us);
|
||||
ets_delay_us(ns);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,19 +119,19 @@ impl Ets {
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u32> for Ets {
|
||||
fn delay_us(&mut self, us: u32) {
|
||||
Ets::delay_us(us);
|
||||
Ets::delay_ns(us);
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u16> for Ets {
|
||||
fn delay_us(&mut self, us: u16) {
|
||||
Ets::delay_us(us as _);
|
||||
Ets::delay_ns(us as _);
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u8> for Ets {
|
||||
fn delay_us(&mut self, us: u8) {
|
||||
Ets::delay_us(us as _);
|
||||
Ets::delay_ns(us as _);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,9 +153,9 @@ impl embedded_hal_0_2::blocking::delay::DelayMs<u8> for Ets {
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal::delay::DelayUs for Ets {
|
||||
fn delay_us(&mut self, us: u32) {
|
||||
Ets::delay_us(us)
|
||||
impl embedded_hal::delay::DelayNs for Ets {
|
||||
fn delay_ns(&mut self, ns: u32) {
|
||||
Ets::delay_ns(ns)
|
||||
}
|
||||
|
||||
fn delay_ms(&mut self, ms: u32) {
|
||||
@ -166,8 +171,13 @@ impl embedded_hal::delay::DelayUs for Ets {
|
||||
pub struct FreeRtos;
|
||||
|
||||
impl FreeRtos {
|
||||
#[deprecated = "Use delay_ns instead"]
|
||||
pub fn delay_us(us: u32) {
|
||||
let ms = us / 1000;
|
||||
Self::delay_ns(us)
|
||||
}
|
||||
|
||||
pub fn delay_ns(ns: u32) {
|
||||
let ms = ns / 1000;
|
||||
|
||||
Self::delay_ms(ms);
|
||||
}
|
||||
@ -184,19 +194,19 @@ impl FreeRtos {
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u32> for FreeRtos {
|
||||
fn delay_us(&mut self, us: u32) {
|
||||
FreeRtos::delay_us(us);
|
||||
FreeRtos::delay_ns(us);
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u16> for FreeRtos {
|
||||
fn delay_us(&mut self, us: u16) {
|
||||
FreeRtos::delay_us(us as _);
|
||||
FreeRtos::delay_ns(us as _);
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u8> for FreeRtos {
|
||||
fn delay_us(&mut self, us: u8) {
|
||||
FreeRtos::delay_us(us as _);
|
||||
FreeRtos::delay_ns(us as _);
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,9 +228,9 @@ impl embedded_hal_0_2::blocking::delay::DelayMs<u8> for FreeRtos {
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal::delay::DelayUs for FreeRtos {
|
||||
fn delay_us(&mut self, us: u32) {
|
||||
FreeRtos::delay_us(us)
|
||||
impl embedded_hal::delay::DelayNs for FreeRtos {
|
||||
fn delay_ns(&mut self, ns: u32) {
|
||||
FreeRtos::delay_ns(ns)
|
||||
}
|
||||
|
||||
fn delay_ms(&mut self, ms: u32) {
|
||||
@ -243,11 +253,16 @@ impl Delay {
|
||||
Self(threshold)
|
||||
}
|
||||
|
||||
#[deprecated = "Use delay_ns instead"]
|
||||
pub fn delay_us(&self, us: u32) {
|
||||
if us < self.0 {
|
||||
Ets::delay_us(us);
|
||||
self.delay_ns(us)
|
||||
}
|
||||
|
||||
pub fn delay_ns(&self, ns: u32) {
|
||||
if ns < self.0 {
|
||||
Ets::delay_ns(ns);
|
||||
} else {
|
||||
FreeRtos::delay_us(us);
|
||||
FreeRtos::delay_ns(ns);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,9 +275,9 @@ impl Delay {
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal::delay::DelayUs for Delay {
|
||||
fn delay_us(&mut self, us: u32) {
|
||||
Delay::delay_us(self, us)
|
||||
impl embedded_hal::delay::DelayNs for Delay {
|
||||
fn delay_ns(&mut self, us: u32) {
|
||||
Delay::delay_ns(self, us)
|
||||
}
|
||||
|
||||
fn delay_ms(&mut self, ms: u32) {
|
||||
@ -272,13 +287,13 @@ impl embedded_hal::delay::DelayUs for Delay {
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u16> for Delay {
|
||||
fn delay_us(&mut self, us: u16) {
|
||||
Delay::delay_us(self, us as _);
|
||||
Delay::delay_ns(self, us as _);
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_hal_0_2::blocking::delay::DelayUs<u32> for Delay {
|
||||
fn delay_us(&mut self, us: u32) {
|
||||
Delay::delay_us(self, us);
|
||||
Delay::delay_ns(self, us);
|
||||
}
|
||||
}
|
||||
|
||||
|
40
src/gpio.rs
40
src/gpio.rs
@ -1420,11 +1420,24 @@ impl<'d, T: Pin, MODE> embedded_hal::digital::InputPin for PinDriver<'d, T, MODE
|
||||
where
|
||||
MODE: InputMode,
|
||||
{
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(PinDriver::is_high(self))
|
||||
}
|
||||
|
||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(PinDriver::is_low(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin, MODE> embedded_hal::digital::InputPin for &PinDriver<'d, T, MODE>
|
||||
where
|
||||
MODE: InputMode,
|
||||
{
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(PinDriver::is_high(self))
|
||||
}
|
||||
|
||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(PinDriver::is_low(self))
|
||||
}
|
||||
}
|
||||
@ -1461,15 +1474,29 @@ impl<'d, T: Pin, MODE> embedded_hal::digital::StatefulOutputPin for PinDriver<'d
|
||||
where
|
||||
MODE: OutputMode,
|
||||
{
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(self.get_output_level().into())
|
||||
}
|
||||
|
||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(!bool::from(self.get_output_level()))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Will become possible once the `PinDriver::setXXX`` methods become non-`&mut`, which they really are, internally
|
||||
// impl<'d, T: Pin, MODE> embedded_hal::digital::StatefulOutputPin for &PinDriver<'d, T, MODE>
|
||||
// where
|
||||
// MODE: OutputMode,
|
||||
// {
|
||||
// fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
// Ok(self.get_output_level().into())
|
||||
// }
|
||||
|
||||
// fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||
// Ok(!bool::from(self.get_output_level()))
|
||||
// }
|
||||
// }
|
||||
|
||||
impl<'d, T: Pin, MODE> embedded_hal_0_2::digital::v2::StatefulOutputPin for PinDriver<'d, T, MODE>
|
||||
where
|
||||
MODE: OutputMode,
|
||||
@ -1504,10 +1531,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
not(all(feature = "riscv-ulp-hal", not(feature = "esp-idf-sys"))),
|
||||
feature = "nightly"
|
||||
))]
|
||||
#[cfg(not(all(feature = "riscv-ulp-hal", not(feature = "esp-idf-sys"))))]
|
||||
impl<T: Pin, MODE: InputMode> embedded_hal_async::digital::Wait for PinDriver<'_, T, MODE> {
|
||||
async fn wait_for_high(&mut self) -> Result<(), GpioError> {
|
||||
self.wait_for_high().await?;
|
||||
|
@ -1236,7 +1236,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
#[cfg(not(esp_idf_version_major = "4"))]
|
||||
impl<'d, Dir> embedded_io_async::Read for I2sDriver<'d, Dir>
|
||||
where
|
||||
@ -1247,7 +1246,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
#[cfg(not(esp_idf_version_major = "4"))]
|
||||
impl<'d, Dir> embedded_io_async::Write for I2sDriver<'d, Dir>
|
||||
where
|
||||
|
@ -30,7 +30,6 @@ impl Display for EspIOError {
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for EspIOError {}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
pub mod asynch {
|
||||
pub use embedded_io_async::*;
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ fn to_pwm_err(err: EspError) -> PwmError {
|
||||
}
|
||||
|
||||
impl<'d> embedded_hal::pwm::SetDutyCycle for LedcDriver<'d> {
|
||||
fn get_max_duty_cycle(&self) -> u16 {
|
||||
fn max_duty_cycle(&self) -> u16 {
|
||||
let duty = self.get_max_duty();
|
||||
let duty_cap: u16 = if duty > u16::MAX as u32 {
|
||||
u16::MAX
|
||||
@ -354,7 +354,7 @@ impl<'d> embedded_hal::pwm::SetDutyCycle for LedcDriver<'d> {
|
||||
}
|
||||
|
||||
fn set_duty_cycle_fraction(&mut self, num: u16, denom: u16) -> Result<(), PwmError> {
|
||||
let duty = num as u32 * self.get_max_duty_cycle() as u32 / denom as u32;
|
||||
let duty = num as u32 * self.max_duty_cycle() as u32 / denom as u32;
|
||||
self.set_duty_cycle(duty as u16)
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![allow(stable_features)]
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(async_fn_in_trait)]
|
||||
#![allow(clippy::unused_unit)] // enumset
|
||||
#![warn(clippy::large_futures)]
|
||||
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
|
||||
#![cfg_attr(feature = "nightly", allow(async_fn_in_trait))]
|
||||
#![cfg_attr(feature = "nightly", feature(impl_trait_projections))]
|
||||
#![cfg_attr(feature = "nightly", feature(doc_cfg))]
|
||||
#![cfg_attr(target_arch = "xtensa", feature(asm_experimental_arch))]
|
||||
|
||||
|
15
src/spi.rs
15
src/spi.rs
@ -673,7 +673,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
#[cfg(not(esp_idf_spi_master_isr_in_iram))]
|
||||
impl<'d, T> embedded_hal_async::spi::SpiBus for SpiBusDriver<'d, T>
|
||||
where
|
||||
@ -904,7 +903,7 @@ where
|
||||
|
||||
while spi_operations.peek().is_some() {
|
||||
if let Some(SpiOperation::Delay(delay)) = spi_operations.peek() {
|
||||
delay_impl.delay_us(*delay);
|
||||
delay_impl.delay_ns(*delay);
|
||||
spi_operations.next();
|
||||
} else {
|
||||
let transactions = core::iter::from_fn(|| {
|
||||
@ -965,7 +964,7 @@ where
|
||||
|
||||
while spi_operations.peek().is_some() {
|
||||
if let Some(SpiOperation::Delay(delay)) = spi_operations.peek() {
|
||||
delay_impl.delay_us(*delay);
|
||||
delay_impl.delay_ns(*delay);
|
||||
spi_operations.next();
|
||||
} else {
|
||||
let transactions = core::iter::from_fn(|| {
|
||||
@ -1091,7 +1090,7 @@ where
|
||||
spi_transfer_in_place_transactions(words, chunk_size)
|
||||
.map(SpiOperation::Transaction),
|
||||
),
|
||||
Operation::DelayUs(delay) => {
|
||||
Operation::DelayNs(delay) => {
|
||||
OperationsIter::Delay(core::iter::once(SpiOperation::Delay(delay)))
|
||||
}
|
||||
})
|
||||
@ -1241,7 +1240,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
#[cfg(not(esp_idf_spi_master_isr_in_iram))]
|
||||
impl<'d, T> embedded_hal_async::spi::SpiDevice for SpiDeviceDriver<'d, T>
|
||||
where
|
||||
@ -1473,7 +1471,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
#[cfg(not(esp_idf_spi_master_isr_in_iram))]
|
||||
impl<'d, DEVICE, DRIVER> embedded_hal_async::spi::SpiDevice
|
||||
for SpiSoftCsDeviceDriver<'d, DEVICE, DRIVER>
|
||||
@ -1573,7 +1570,7 @@ where
|
||||
|
||||
// TODO: Need to wait asnchronously if in async mode
|
||||
if let Some(delay) = pre_delay {
|
||||
Ets::delay_us(*delay);
|
||||
Ets::delay_ns(*delay);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1586,7 +1583,7 @@ where
|
||||
|
||||
// TODO: Need to wait asnchronously if in async mode
|
||||
if let Some(delay) = post_delay {
|
||||
Ets::delay_us(*delay);
|
||||
Ets::delay_ns(*delay);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1898,7 +1895,7 @@ fn copy_operation<'b>(operation: &'b mut Operation<'_, u8>) -> Operation<'b, u8>
|
||||
Operation::Write(write) => Operation::Write(write),
|
||||
Operation::Transfer(read, write) => Operation::Transfer(read, write),
|
||||
Operation::TransferInPlace(write) => Operation::TransferInPlace(write),
|
||||
Operation::DelayUs(delay) => Operation::DelayUs(*delay),
|
||||
Operation::DelayNs(delay) => Operation::DelayNs(*delay),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -803,8 +803,8 @@ pub mod embassy_sync {
|
||||
|
||||
#[cfg(all(feature = "alloc", target_has_atomic = "ptr"))]
|
||||
pub mod notification {
|
||||
use core::marker::PhantomData;
|
||||
use core::num::NonZeroU32;
|
||||
use core::ptr;
|
||||
use core::sync::atomic::{AtomicPtr, Ordering};
|
||||
|
||||
extern crate alloc;
|
||||
@ -821,13 +821,13 @@ pub mod notification {
|
||||
#[cfg(not(esp_idf_version_major = "4"))]
|
||||
type Task = esp_idf_sys::tskTaskControlBlock;
|
||||
|
||||
pub struct Notification(Arc<Notifier>, *const ());
|
||||
pub struct Notification(Arc<Notifier>, PhantomData<*const ()>);
|
||||
|
||||
impl Notification {
|
||||
pub fn new() -> Self {
|
||||
Self(
|
||||
Arc::new(Notifier(AtomicPtr::new(task::current().unwrap()))),
|
||||
ptr::null(),
|
||||
PhantomData,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -466,10 +466,9 @@ impl<'d> Drop for TimerDriver<'d> {
|
||||
|
||||
unsafe impl<'d> Send for TimerDriver<'d> {}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<'d> embedded_hal_async::delay::DelayUs for TimerDriver<'d> {
|
||||
async fn delay_us(&mut self, us: u32) {
|
||||
let counter = core::cmp::max((self.tick_hz() * us as u64) / 1000000, 1);
|
||||
impl<'d> embedded_hal_async::delay::DelayNs for TimerDriver<'d> {
|
||||
async fn delay_ns(&mut self, ns: u32) {
|
||||
let counter = core::cmp::max((self.tick_hz() * ns as u64) / 1000000, 1);
|
||||
|
||||
self.delay(counter).await.unwrap();
|
||||
}
|
||||
|
@ -1493,7 +1493,6 @@ where
|
||||
type Error = EspIOError;
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<'d, T> embedded_io_async::Read for AsyncUartDriver<'d, T>
|
||||
where
|
||||
T: BorrowMut<UartDriver<'d>>,
|
||||
@ -1503,7 +1502,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<'d, T> embedded_io_async::Write for AsyncUartDriver<'d, T>
|
||||
where
|
||||
T: BorrowMut<UartDriver<'d>>,
|
||||
@ -1613,7 +1611,6 @@ where
|
||||
type Error = EspIOError;
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<'d, T> embedded_io_async::Read for AsyncUartRxDriver<'d, T>
|
||||
where
|
||||
T: BorrowMut<UartRxDriver<'d>>,
|
||||
@ -1732,7 +1729,6 @@ where
|
||||
type Error = EspIOError;
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<'d, T> embedded_io_async::Write for AsyncUartTxDriver<'d, T>
|
||||
where
|
||||
T: BorrowMut<UartTxDriver<'d>>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user