From 392112960ec42db4739b7a92802e23430fb5aefa Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Sun, 26 Jan 2025 16:26:26 +0300 Subject: [PATCH] update staging 0.18 --- CHANGELOG.md | 2 +- Cargo.toml | 34 +++++++++---------- examples/analog-stopwatch-with-spi-ssd1306.rs | 22 ++++++++++-- examples/ist7920-bidi-normal-spi.rs | 2 +- ...with-ssd1306-and-interrupts-and-dma-i2c.rs | 2 +- src/dsi.rs | 14 ++++---- src/i2c.rs | 16 ++++----- src/i2c/dma.rs | 4 +-- 8 files changed, 57 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21663ab7..86249016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - Use `write` instead of `modify` to clear flags -- Bump `stm32f4-staging` +- Bump `stm32f4-staging` to 0.18, update other dependencies ## [v0.22.1] - 2024-11-03 diff --git a/Cargo.toml b/Cargo.toml index caeaab35..ed41e401 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,10 +27,10 @@ features = [ targets = ["thumbv7em-none-eabihf"] [dependencies] -defmt = { version = "0.3.5", optional = true } -bxcan = { version = "0.7", optional = true } +defmt = { version = "0.3.10", optional = true } +bxcan = { version = "0.8", optional = true } cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] } -cortex-m-rt = "0.7.3" +cortex-m-rt = "0.7.5" nb = "1.1" rand_core = "0.6.4" synopsys-usb-otg = { version = "0.4.0", features = [ @@ -54,12 +54,12 @@ cortex-m-rtic = { version = "1.1.4", features = [ # rtic2 rtic-time = { version = "2.0", optional = true } embedded-hal-async = { version = "1.0", optional = true } -rtic = { version = "2.0.1", features = ["thumbv7-backend"], optional = true } +rtic = { version = "2.1.2", features = ["thumbv7-backend"], optional = true } atomic-polyfill = { version = "1.0.3", optional = true } -stm32-fmc = { version = "0.3.2", optional = true } +stm32-fmc = { version = "0.4.0", optional = true } -enumflags2 = "0.7.8" +enumflags2 = "0.7.11" embedded-storage = "0.3" document-features = "0.2" @@ -67,11 +67,11 @@ micromath = { version = "2.1.0", optional = true } [dependencies.stm32f4] package = "stm32f4-staging" -version = "0.17.0" +version = "0.18.0" features = ["atomics"] [dependencies.time] -version = "0.3.14" +version = "0.3.37" default-features = false [dependencies.embedded-hal-02] @@ -95,21 +95,22 @@ optional = true [dev-dependencies] defmt = "0.3.4" defmt-rtt = "0.4.0" -panic-probe = { version = "0.3.0", features = ["print-defmt"] } +panic-probe = { version = "0.3.2", features = ["print-defmt"] } panic-semihosting = "0.6.0" cortex-m-semihosting = "0.5.0" heapless = "0.8" -panic-halt = "0.2.0" -ssd1306 = "0.8.4" +panic-halt = "1.0.0" +ssd1306 = "0.9.0" embedded-graphics = "0.8.1" embedded-graphics-07 = { package = "embedded-graphics", version = "0.7.1" } +embedded-hal-bus = "0.3.0" usb-device = "0.3.1" usbd-serial = "0.2.0" micromath = "2" dwt-systick-monotonic = "1.1" st7789 = "0.7.0" -rtt-target = { version = "0.5.0" } -display-interface-spi = "0.4.1" +rtt-target = { version = "0.6.1" } +display-interface-spi-04 = { package = "display-interface-spi", version = "0.4.1" } ist7920 = "0.1.1" smart-leds = "0.3.0" ws2812-spi = { version = "0.4.0", features = [] } @@ -118,7 +119,7 @@ display-interface = "0.5" display-interface-04 = { package = "display-interface", version = "0.4.1" } ft6x06 = "0.1.2" otm8009a = "0.1" -ushell = "0.3.5" +ushell = "0.3.6" [dev-dependencies.time] version = "0.3" @@ -144,9 +145,9 @@ stm32f412 = ["stm32f4/stm32f412", "gpio-f412"] stm32f413 = ["stm32f4/stm32f413", "gpio-f413"] stm32f423 = ["stm32f4/stm32f413", "gpio-f413", "aes"] stm32f427 = ["stm32f4/stm32f427", "gpio-f427", "fsmc"] -stm32f429 = ["stm32f4/stm32f429", "gpio-f427", "fmc"] +stm32f429 = ["stm32f4/stm32f429", "gpio-f427", "fmc", "ltdc"] stm32f437 = ["stm32f4/stm32f427", "gpio-f427", "fsmc", "cryp"] -stm32f439 = ["stm32f4/stm32f429", "gpio-f427", "fmc", "cryp"] +stm32f439 = ["stm32f4/stm32f429", "gpio-f427", "fmc", "cryp", "ltdc"] stm32f446 = ["stm32f4/stm32f446", "gpio-f446"] stm32f469 = ["stm32f4/stm32f469", "gpio-f469"] stm32f479 = ["stm32f4/stm32f469", "gpio-f469", "cryp"] @@ -335,7 +336,6 @@ gpio-f427 = [ "dma2d", "eth", "i2c3", - "ltdc", "otg-fs", "otg-hs", "rng", diff --git a/examples/analog-stopwatch-with-spi-ssd1306.rs b/examples/analog-stopwatch-with-spi-ssd1306.rs index fa57ea0c..216f190d 100644 --- a/examples/analog-stopwatch-with-spi-ssd1306.rs +++ b/examples/analog-stopwatch-with-spi-ssd1306.rs @@ -19,9 +19,12 @@ use crate::hal::{ timer::{CounterUs, Event, FTimer, Flag, Timer}, }; -use core::cell::{Cell, RefCell}; use core::fmt::Write; use core::ops::DerefMut; +use core::{ + cell::{Cell, RefCell}, + convert::Infallible, +}; use cortex_m::interrupt::{free, CriticalSection, Mutex}; use heapless::String; @@ -34,6 +37,7 @@ use embedded_graphics::{ primitives::{Circle, Line, PrimitiveStyle, PrimitiveStyleBuilder}, text::Text, }; +use embedded_hal_bus::spi::ExclusiveDevice; use micromath::F32Ext; use ssd1306::{prelude::*, Ssd1306}; @@ -61,6 +65,19 @@ enum StopwatchState { Stopped, } +struct DummyPin; +impl embedded_hal::digital::ErrorType for DummyPin { + type Error = Infallible; +} +impl embedded_hal::digital::OutputPin for DummyPin { + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(()) + } + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(()) + } +} + #[entry] fn main() -> ! { let mut dp = pac::Peripherals::take().unwrap(); @@ -117,7 +134,8 @@ fn main() -> ! { ss.set_low(); // Set up the display - let interface = SPIInterfaceNoCS::new(spi, dc); + let spi_device = ExclusiveDevice::new_no_delay(spi, DummyPin).unwrap(); + let interface = SPIInterface::new(spi_device, dc); let mut disp = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate0) .into_buffered_graphics_mode(); disp.init().unwrap(); diff --git a/examples/ist7920-bidi-normal-spi.rs b/examples/ist7920-bidi-normal-spi.rs index 65277b18..5d8612fe 100644 --- a/examples/ist7920-bidi-normal-spi.rs +++ b/examples/ist7920-bidi-normal-spi.rs @@ -11,7 +11,7 @@ use crate::hal::{pac, prelude::*, timer::Timer}; use hal::spi::{Mode, Phase, Polarity}; -use display_interface_spi::SPIInterface; +use display_interface_spi_04::SPIInterface; use ist7920::Ist7920; #[entry] diff --git a/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs b/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs index ebef349f..0cd79283 100644 --- a/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs +++ b/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs @@ -38,7 +38,7 @@ use core::ops::DerefMut; use core::sync::atomic::{AtomicBool, Ordering}; use cortex_m::interrupt::{free, CriticalSection, Mutex}; use cortex_m_rt::entry; -use display_interface_04::{DataFormat, DisplayError, WriteOnlyDataCommand}; +use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; use embedded_graphics::{ mono_font::{ ascii::{FONT_6X12, FONT_9X15}, diff --git a/src/dsi.rs b/src/dsi.rs index c6eb260c..0ad6b43c 100644 --- a/src/dsi.rs +++ b/src/dsi.rs @@ -175,7 +175,7 @@ impl DsiHost { dsi.wrpcr().modify(|_, w| w.regen().set_bit()); // Wait for it to be ready block_with_timeout( - || dsi.wisr().read().rrs() == false, + || dsi.wisr().read().rrs().bit_is_clear(), DSI_TIMEOUT_MS, cycles_1ms, Error::RegTimeout, @@ -201,7 +201,7 @@ impl DsiHost { cortex_m::asm::delay(cycles_1ms / 2); // Wait for the lock block_with_timeout( - || dsi.wisr().read().pllls() == false, + || dsi.wisr().read().pllls().bit_is_clear(), DSI_TIMEOUT_MS, cycles_1ms, Error::PllTimeout, @@ -221,7 +221,7 @@ impl DsiHost { ); // Configure the number of active data lanes - dsi.pcconfr() + dsi.pconfr() .modify(|_, w| unsafe { w.nl().bits(dsi_config.lane_count as u8) }); // 0b00 - 1 lanes, 0b01 - 2 lanes // Set TX escape clock division factor @@ -244,7 +244,7 @@ impl DsiHost { / odf; let f_pix_khz = f_phy_hz / 1_000 / 8; let uix4 = 4_000_000_000 / f_phy_hz; - dsi.wpcr1() + dsi.wpcr0() .modify(|_, w| unsafe { w.uix4().bits(uix4 as u8) }); match dsi_config.interrupts { @@ -474,12 +474,12 @@ impl DsiHost { w.lp2hs_time().bits(phy_timers.dataline_lp2hs) }); self.dsi - .pcconfr() + .pconfr() .modify(|_, w| unsafe { w.sw_time().bits(phy_timers.stop_wait_time) }); } pub fn force_rx_low_power(&mut self, force: bool) { - self.dsi.wpcr2().modify(|_, w| w.flprxlpm().bit(force)); + self.dsi.wpcr1().modify(|_, w| w.flprxlpm().bit(force)); } fn long_write(&mut self, cmd: u8, buf: &[u8], ghcr_dt: u8) -> Result<(), Error> { @@ -588,7 +588,7 @@ impl DsiHostCtrlIo for DsiHost { // debug!("DSI write: {:x?}", kind); // wait for command fifo to be empty block_with_timeout( - || self.dsi.gpsr().read().cmdfe() == false, + || self.dsi.gpsr().read().cmdfe().bit_is_clear(), DSI_TIMEOUT_MS, self.cycles_1ms, Error::FifoTimeout, diff --git a/src/i2c.rs b/src/i2c.rs index 67c4e30b..48273b45 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -287,14 +287,14 @@ impl I2c { Address::Seven(addr) => { self.i2c .dr() - .write(|w| unsafe { w.bits(u32::from(addr) << 1) }); + .write(|w| unsafe { w.bits(u16::from(addr) << 1) }); } Address::Ten(addr) => { let [msbs, lsbs] = addr.to_be_bytes(); let msbs = ((msbs & 0b11) << 1) & 0b11110000; let dr = self.i2c.dr(); - dr.write(|w| unsafe { w.bits(u32::from(msbs)) }); - dr.write(|w| unsafe { w.bits(u32::from(lsbs)) }); + dr.write(|w| unsafe { w.bits(u16::from(msbs)) }); + dr.write(|w| unsafe { w.bits(u16::from(lsbs)) }); } } @@ -348,20 +348,20 @@ impl I2c { Address::Seven(addr) => { self.i2c .dr() - .write(|w| unsafe { w.bits((u32::from(addr) << 1) | 1) }); + .write(|w| unsafe { w.bits((u16::from(addr) << 1) | 1) }); } Address::Ten(addr) => { let [msbs, lsbs] = addr.to_be_bytes(); let msbs = ((msbs & 0b11) << 1) | 0b11110000; let dr = self.i2c.dr(); if first_transaction { - dr.write(|w| unsafe { w.bits(u32::from(msbs)) }); - dr.write(|w| unsafe { w.bits(u32::from(lsbs)) }); + dr.write(|w| unsafe { w.bits(u16::from(msbs)) }); + dr.write(|w| unsafe { w.bits(u16::from(lsbs)) }); } self.i2c.cr1().modify(|_, w| w.start().set_bit()); // Wait until START condition was generated while self.i2c.sr1().read().sb().bit_is_clear() {} - dr.write(|w| unsafe { w.bits(u32::from(msbs | 1)) }); + dr.write(|w| unsafe { w.bits(u16::from(msbs | 1)) }); } } @@ -401,7 +401,7 @@ impl I2c { {} // Push out a byte of data - self.i2c.dr().write(|w| unsafe { w.bits(u32::from(byte)) }); + self.i2c.dr().write(|w| unsafe { w.bits(u16::from(byte)) }); // Wait until byte is transferred // Check for any potential error conditions. diff --git a/src/i2c/dma.rs b/src/i2c/dma.rs index 16918b5e..3b441ab5 100644 --- a/src/i2c/dma.rs +++ b/src/i2c/dma.rs @@ -460,9 +460,9 @@ where fn send_address(&mut self, addr: u8, read: bool) -> Result<(), super::Error> { let i2c = &self.hal_i2c.i2c; - let mut to_send_addr = u32::from(addr) << 1; + let mut to_send_addr = u16::from(addr) << 1; if read { - to_send_addr += 1; + to_send_addr |= 1; } // Set up current address, we're trying to talk to