Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update staging 0.18 #831

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -54,24 +54,24 @@ 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"

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]
Expand All @@ -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 = [] }
Expand All @@ -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"
Expand All @@ -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"]
Expand Down Expand Up @@ -335,7 +336,6 @@ gpio-f427 = [
"dma2d",
"eth",
"i2c3",
"ltdc",
"otg-fs",
"otg-hs",
"rng",
Expand Down
22 changes: 20 additions & 2 deletions examples/analog-stopwatch-with-spi-ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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};
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/ist7920-bidi-normal-spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
14 changes: 7 additions & 7 deletions src/dsi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@ impl<I2C: Instance> I2c<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)) });
}
}

Expand Down Expand Up @@ -348,20 +348,20 @@ impl<I2C: Instance> I2c<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)) });
}
}

Expand Down Expand Up @@ -401,7 +401,7 @@ impl<I2C: Instance> I2c<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.
Expand Down
4 changes: 2 additions & 2 deletions src/i2c/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading