Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
David-OConnor committed Dec 2, 2024
2 parents 083d910 + ace420c commit 7b87ddd
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 170 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stm32-hal2"
version = "1.8.3"
version = "1.8.4"
edition = "2021"
authors = ["David O'Connor <the_alchemist@fastmail.com>"]
description = "Hardware abstraction layer for the STM32 MCUs"
Expand Down
2 changes: 1 addition & 1 deletion src/clocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cfg_if::cfg_if! {
// todo: Continue working through DRY between the clock modules.

/// Speed out of limits.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, defmt::Format)]
pub enum RccError {
Speed,
Hardware,
Expand Down
2 changes: 1 addition & 1 deletion src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl Default for Polynomial {
}

/// Errors generated when trying to create invalid polynomials.
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, defmt::Format)]
pub enum PolynomialError {
/// Tried to create an even polynomial.
/// The hardware CRC unit only supports odd polynomials.
Expand Down
2 changes: 1 addition & 1 deletion src/flash/non_trustzone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Bank {
B2 = 1,
}

#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, defmt::Format)]
/// Possible error states for flash operations.
pub enum Error {
/// Flash controller is not done yet
Expand Down
2 changes: 1 addition & 1 deletion src/flash/trustzone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Bank {
B2 = 1,
}

#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, defmt::Format)]
/// Possible error states for flash operations.
pub enum Error {
/// Flash controller is not done yet
Expand Down
324 changes: 166 additions & 158 deletions src/i2c.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/i2c_f4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum I2cDevice {
Three,
}

#[derive(Debug)]
#[derive(Debug, defmt::Format)]
pub enum Error {
OVERRUN,
NACK,
Expand Down
2 changes: 1 addition & 1 deletion src/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub enum SamplingEdge {
}

/// Indicates an error with the QSPI peripheral.
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, defmt::Format)]
pub enum QspiError {
Busy,
Underflow,
Expand Down
2 changes: 1 addition & 1 deletion src/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum RtcClockSource {
}

/// RTC error type
#[derive(Debug)]
#[derive(Debug, defmt::Format)]
pub enum Error {
/// Invalid input error
InvalidInputData,
Expand Down
2 changes: 1 addition & 1 deletion src/spi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ macro_rules! check_errors {

/// SPI error
#[non_exhaustive]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, defmt::Format)]
pub enum SpiError {
/// Overrun occurred
Overrun,
Expand Down
20 changes: 18 additions & 2 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub static TICK_OVERFLOW_COUNT: AtomicU32 = AtomicU32::new(0);

// todo: Low power timer enabling etc. eg on L4, RCC_APB1ENR1.LPTIM1EN

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, defmt::Format)]
/// Used for when attempting to set a timer period that is out of range.
pub struct ValueError {}

Expand Down Expand Up @@ -2033,9 +2033,25 @@ pub fn clear_update_interrupt(tim_num: u8) {
let bits = 0xffff_ffff;

match tim_num {
#[cfg(not(any(feature = "f373")))]
1 => periphs.TIM1.sr.write(|w| w.bits(bits).uif().clear_bit()),
#[cfg(not(any(
feature = "f410",
feature = "g070",
feature = "l5", // todo PAC bug?
feature = "wb55", // todo PAC bug?
)))]
2 => periphs.TIM2.sr.write(|w| w.bits(bits).uif().clear_bit()),
#[cfg(not(any(feature = "wl")))]
#[cfg(not(any(
feature = "f301",
feature = "l4x1",
// feature = "l412",
feature = "l5", // todo PAC bug?
feature = "l4x3",
feature = "f410",
feature = "wb",
feature = "wl"
)))]
3 => periphs.TIM3.sr.write(|w| w.bits(bits).uif().clear_bit()),
#[cfg(not(any(
feature = "f301",
Expand Down
2 changes: 1 addition & 1 deletion src/usart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub enum IrdaMode {

/// Serial error
#[non_exhaustive]
#[derive(Debug)]
#[derive(Debug, defmt::Format)]
pub enum UartError {
/// Framing error
Framing,
Expand Down
7 changes: 7 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ impl RccPeriph for pac::I2C3 {
}
}

#[cfg(feature = "h7")]
impl RccPeriph for pac::I2C4 {
fn en_reset(rcc: &RegisterBlock) {
rcc_en_reset!(apb4, i2c4, rcc);
}
}

#[cfg(not(feature = "f301"))] // todo: Not sure what's going on here.
impl RccPeriph for pac::SPI1 {
fn en_reset(rcc: &RegisterBlock) {
Expand Down

0 comments on commit 7b87ddd

Please sign in to comment.