From ff57aea39654952c46b05a7956d547ea5fe96bd9 Mon Sep 17 00:00:00 2001 From: ivmarkov Date: Thu, 2 Nov 2023 06:57:16 +0000 Subject: [PATCH] New release --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- src/interrupt.rs | 39 +++++++++++++++------------------------ src/spi.rs | 6 ++++++ 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5ca1e43..2930c62a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. 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). +## [0.42.4] - 2023-11-02 +* Remove dependency on `AtomicU64` which is no longer supported by the upstream `*-espidf` targets +* Fix some Clippy warnings in the `spi` driver + ## [0.42.3] - 2023-10-29 * Fix Timer array index bug #331 - prevented the use of TIMER10 on devices that support only 2 Timers * Fix wrong TIMER11 index definition that declared TIMER11 as TIMER10 #331 diff --git a/Cargo.toml b/Cargo.toml index 6b1ddbd66..46cd1d767 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "esp-idf-hal" -version = "0.42.3" +version = "0.42.4" authors = ["sapir ", "Ivan Markov "] edition = "2018" resolver = "2" diff --git a/src/interrupt.rs b/src/interrupt.rs index 0a045e40a..b67174dc8 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -1,6 +1,5 @@ -use core::sync::atomic::{AtomicU64, Ordering}; - use enumset::{EnumSet, EnumSetType}; + use esp_idf_sys::*; /// For backwards compatibility @@ -113,21 +112,20 @@ unsafe fn do_yield_signal(arg: *mut ()) { *signaled = true } -static ISR_YIELDER: AtomicU64 = AtomicU64::new(0); +static mut ISR_YIELDER: Option<(unsafe fn(*mut ()), *mut ())> = None; #[allow(clippy::type_complexity)] #[inline(always)] #[link_section = ".iram1.interrupt_get_isr_yielder"] pub(crate) unsafe fn get_isr_yielder() -> Option<(unsafe fn(*mut ()), *mut ())> { if active() { - let value = ISR_YIELDER.load(Ordering::SeqCst); - if value == 0 { - None - } else { - let func: fn(*mut ()) = core::mem::transmute((value >> 32) as usize); - let arg = (value & 0xffffffff) as usize as *mut (); - Some((func, arg)) - } + free(|| { + if let Some((func, arg)) = unsafe { ISR_YIELDER } { + Some((func, arg)) + } else { + None + } + }) } else { None } @@ -151,20 +149,13 @@ pub unsafe fn set_isr_yielder( yielder: Option<(unsafe fn(*mut ()), *mut ())>, ) -> Option<(unsafe fn(*mut ()), *mut ())> { if active() { - let value = if let Some((func, arg)) = yielder { - ((func as usize as u64) << 32) | (arg as usize as u64) - } else { - 0 - }; + free(|| { + let previous = unsafe { ISR_YIELDER }; - let value = ISR_YIELDER.swap(value, Ordering::SeqCst); - if value == 0 { - None - } else { - let func: fn(*mut ()) = core::mem::transmute((value >> 32) as usize); - let arg = (value & 0xffffffff) as usize as *mut (); - Some((func, arg)) - } + unsafe { ISR_YIELDER = yielder }; + + previous + }) } else { None } diff --git a/src/spi.rs b/src/spi.rs index 45916d977..75cf9bbcf 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -337,6 +337,7 @@ pub mod config { pub struct SpiDriver<'d> { host: u8, max_transfer_size: usize, + #[allow(dead_code)] bus_async_lock: Mutex, _p: PhantomData<&'d mut ()>, } @@ -926,6 +927,7 @@ where result } + #[allow(dead_code)] async fn run_async<'a, 'c, 'p, P, M>( &self, mut cs_pin: CsCtl<'c, 'p, P, M>, @@ -1269,6 +1271,7 @@ where { driver: UnsafeCell>, lock: CriticalSection, + #[allow(dead_code)] async_lock: Mutex, } @@ -1422,6 +1425,7 @@ where .lock(move |device| device.run(cs_pin, operations)) } + #[allow(dead_code)] async fn run_async<'a>( &mut self, operations: impl Iterator> + 'a, @@ -1799,6 +1803,7 @@ fn spi_transmit( Ok(()) } +#[allow(dead_code)] async fn spi_transmit_async( handle: spi_device_handle_t, transactions: impl Iterator, @@ -1902,6 +1907,7 @@ fn data_mode_to_u8(data_mode: config::Mode) -> u8 { | ((data_mode.phase == config::Phase::CaptureOnSecondTransition) as u8) } +#[allow(dead_code)] async fn with_completion(fut: F, dtor: D) -> F::Output where F: Future,