diff --git a/Cargo.toml b/Cargo.toml index c759158..b2a2622 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ license = "MIT/Apache-2.0" [features] default = ["ble", "embassy"] -embassy = ["dep:embassy-time", "dep:embassy-sync"] +embassy = ["dep:embassy-sync"] ble = [] [dependencies] @@ -36,15 +36,12 @@ nb = "1.1.0" embedded-hal-02 = { package = "embedded-hal", version = "0.2.7", features = [ "unproven", ] } -embedded-hal-1 = { version = "=1.0.0-rc.2", package = "embedded-hal" } -embedded-hal-nb = "1.0.0-rc.1" -embedded-hal-async = "1.0.0-rc.1" +embedded-hal-1 = { version = "1.0.0", package = "embedded-hal" } +embedded-hal-nb = "1.0.0" +embedded-hal-async = "1.0.0" -# embassy time driver -embassy-time = { version = "0.2.0", features = [ - "tick-hz-32_768", -], optional = true } embassy-sync = { version = "0.5.0", optional = true } +embassy-time-driver = { version = "0.1.0", features = ["tick-hz-32_768"] } [dev-dependencies] display-interface = "0.4.1" @@ -54,12 +51,14 @@ panic-halt = "0.2.0" ssd1306 = "0.8.4" embassy-futures = "0.1.1" -embassy-executor = { version = "0.4.0", features = [ +embassy-executor = { version = "0.5.0", features = [ "nightly", "integrated-timers", "arch-riscv32", "executor-thread", ] } +embassy-time = { version = "0.3.0" } +# embassy time driver heapless = "0.8.0" embedded-alloc = "0.5.0" embedded-sdmmc = "0.6.0" diff --git a/src/embassy/time_driver_systick.rs b/src/embassy/time_driver_systick.rs index 295dd06..7de165f 100644 --- a/src/embassy/time_driver_systick.rs +++ b/src/embassy/time_driver_systick.rs @@ -5,7 +5,7 @@ use core::sync::atomic::{AtomicU32, AtomicU8, Ordering}; use core::{mem, ptr}; use critical_section::{CriticalSection, Mutex}; -use embassy_time::driver::{AlarmHandle, Driver}; +use embassy_time_driver::{AlarmHandle, Driver}; // use super::AlarmState; use crate::pac; @@ -40,7 +40,7 @@ pub struct SystickDriver { } const ALARM_STATE_NEW: AlarmState = AlarmState::new(); -embassy_time::time_driver_impl!(static DRIVER: SystickDriver = SystickDriver { +embassy_time_driver::time_driver_impl!(static DRIVER: SystickDriver = SystickDriver { period: AtomicU32::new(1), // avoid div by zero alarm_count: AtomicU8::new(0), alarms: Mutex::new([ALARM_STATE_NEW; ALARM_COUNT]), @@ -52,7 +52,7 @@ impl SystickDriver { let hclk = crate::sysctl::clocks().hclk.to_Hz() as u64; let cnt_per_second = hclk / 8; - let cnt_per_tick = cnt_per_second / embassy_time::TICK_HZ; + let cnt_per_tick = cnt_per_second / embassy_time_driver::TICK_HZ; self.period.store(cnt_per_tick as u32, Ordering::Relaxed); @@ -60,7 +60,7 @@ impl SystickDriver { rb.cmp().write(|w| unsafe { w.bits(u64::MAX - 1) }); critical_section::with(|_| { rb.sr().write(|w| w.cntif().bit(false)); // clear - // Configration: Upcount, No reload, HCLK/8 as clock source + // Configration: Upcount, No reload, HCLK/8 as clock source rb.ctlr().modify(|_, w| { w.init() .set_bit() @@ -163,8 +163,6 @@ impl Driver for SystickDriver { } } - - #[allow(non_snake_case)] #[link_section = ".trap"] #[no_mangle] diff --git a/src/gpio.rs b/src/gpio.rs index 346b9e4..ee3b401 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -303,12 +303,11 @@ pub(crate) unsafe fn init() { fn irq_handler(port: u8, wakers: &[AtomicWaker; N]) { let gpioctl = unsafe { &*pac::GPIOCTL::PTR }; - let int_if = - if port == 0 { - gpioctl.pa_int_if().read().bits() - } else { - gpioctl.pb_int_if().read().bits() - }; + let int_if = if port == 0 { + gpioctl.pa_int_if().read().bits() + } else { + gpioctl.pb_int_if().read().bits() + }; for pin in 0..16 { if int_if & (1 << pin) == 0 { continue; @@ -866,7 +865,7 @@ mod eh02 { mod eh1 { use core::convert::Infallible; - use embedded_hal_1::digital::{ErrorType, InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin}; + use embedded_hal_1::digital::{ErrorType, InputPin, OutputPin, StatefulOutputPin}; use super::*; @@ -876,13 +875,13 @@ mod eh1 { impl<'d, T: Pin> InputPin for Input<'d, T> { #[inline] - fn is_high(&self) -> Result { - Ok(self.is_high()) + fn is_high(&mut self) -> Result { + Ok((*self).is_high()) } #[inline] - fn is_low(&self) -> Result { - Ok(self.is_low()) + fn is_low(&mut self) -> Result { + Ok((*self).is_low()) } } @@ -904,33 +903,26 @@ mod eh1 { impl<'d, T: Pin> StatefulOutputPin for Output<'d, T> { #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + fn is_set_high(&mut self) -> Result { + Ok((*self).is_set_high()) } /// Is the output pin set as low? #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> ToggleableOutputPin for Output<'d, T> { - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) + fn is_set_low(&mut self) -> Result { + Ok((*self).is_set_low()) } } impl<'d, T: Pin> InputPin for Flex<'d, T> { #[inline] - fn is_high(&self) -> Result { - Ok(self.is_high()) + fn is_high(&mut self) -> Result { + Ok((*self).is_high()) } #[inline] - fn is_low(&self) -> Result { - Ok(self.is_low()) + fn is_low(&mut self) -> Result { + Ok((*self).is_low()) } } @@ -946,27 +938,20 @@ mod eh1 { } } - impl<'d, T: Pin> ToggleableOutputPin for Flex<'d, T> { - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) - } - } - impl<'d, T: Pin> ErrorType for Flex<'d, T> { type Error = Infallible; } impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + fn is_set_high(&mut self) -> Result { + Ok((*self).is_set_high()) } /// Is the output pin set as low? #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + fn is_set_low(&mut self) -> Result { + Ok((*self).is_set_low()) } } } diff --git a/src/rtc.rs b/src/rtc.rs index 3e9c15f..332e1b2 100644 --- a/src/rtc.rs +++ b/src/rtc.rs @@ -119,7 +119,6 @@ impl Rtc { } let millisecond = ((cnt_32k % 0x8000) as u32 * 1000 / 32768) as u16; - let mut year: u16 = YEAR_OFFSET; while days >= days_in_year(year) { days -= days_in_year(year); @@ -138,7 +137,6 @@ impl Rtc { sec %= 60; let second = (sec) as u8; - DateTime { year, month, @@ -146,7 +144,7 @@ impl Rtc { hour, minute, second, - millisecond + millisecond, } } }