diff options
| author | HybridChild <[email protected]> | 2025-07-27 10:53:48 +0200 |
|---|---|---|
| committer | HybridChild <[email protected]> | 2025-08-23 08:48:46 +0200 |
| commit | b690a0314f0f2e42137ad4b3e867e056c1d3c14e (patch) | |
| tree | 3a195fa5486c65a80bc7fbf62d747b3ff24091b7 | |
| parent | 399ec8d90f1c4f62fd20d21dabbb9ce64c6986eb (diff) | |
stm32/i2c: v1 and v2 now has separate definitions for the State struct
| -rw-r--r-- | embassy-stm32/src/i2c/mod.rs | 17 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/v1.rs | 15 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/v2.rs | 15 |
3 files changed, 33 insertions, 14 deletions
diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index f51682900..58225d937 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs | |||
| @@ -5,6 +5,9 @@ | |||
| 5 | #[cfg_attr(any(i2c_v2, i2c_v3), path = "v2.rs")] | 5 | #[cfg_attr(any(i2c_v2, i2c_v3), path = "v2.rs")] |
| 6 | mod _version; | 6 | mod _version; |
| 7 | 7 | ||
| 8 | // Type alias for the peri_trait! macro | ||
| 9 | type State = _version::State; | ||
| 10 | |||
| 8 | mod config; | 11 | mod config; |
| 9 | 12 | ||
| 10 | use core::future::Future; | 13 | use core::future::Future; |
| @@ -13,7 +16,6 @@ use core::marker::PhantomData; | |||
| 13 | 16 | ||
| 14 | pub use config::*; | 17 | pub use config::*; |
| 15 | use embassy_hal_internal::Peri; | 18 | use embassy_hal_internal::Peri; |
| 16 | use embassy_sync::waitqueue::AtomicWaker; | ||
| 17 | #[cfg(feature = "time")] | 19 | #[cfg(feature = "time")] |
| 18 | use embassy_time::{Duration, Instant}; | 20 | use embassy_time::{Duration, Instant}; |
| 19 | use mode::MasterMode; | 21 | use mode::MasterMode; |
| @@ -274,19 +276,6 @@ impl Timeout { | |||
| 274 | } | 276 | } |
| 275 | } | 277 | } |
| 276 | 278 | ||
| 277 | struct State { | ||
| 278 | #[allow(unused)] | ||
| 279 | waker: AtomicWaker, | ||
| 280 | } | ||
| 281 | |||
| 282 | impl State { | ||
| 283 | const fn new() -> Self { | ||
| 284 | Self { | ||
| 285 | waker: AtomicWaker::new(), | ||
| 286 | } | ||
| 287 | } | ||
| 288 | } | ||
| 289 | |||
| 290 | struct Info { | 279 | struct Info { |
| 291 | regs: crate::pac::i2c::I2c, | 280 | regs: crate::pac::i2c::I2c, |
| 292 | rcc: RccInfo, | 281 | rcc: RccInfo, |
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index 7d2b731d5..78abb85ea 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -17,6 +17,21 @@ use super::*; | |||
| 17 | use crate::mode::Mode; | 17 | use crate::mode::Mode; |
| 18 | use crate::pac::i2c; | 18 | use crate::pac::i2c; |
| 19 | 19 | ||
| 20 | use embassy_sync::waitqueue::AtomicWaker; | ||
| 21 | |||
| 22 | /// I2C v2 peripheral state | ||
| 23 | pub(crate) struct State { | ||
| 24 | pub(crate) waker: AtomicWaker, | ||
| 25 | } | ||
| 26 | |||
| 27 | impl State { | ||
| 28 | pub(crate) const fn new() -> Self { | ||
| 29 | Self { | ||
| 30 | waker: AtomicWaker::new(), | ||
| 31 | } | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 20 | // /!\ /!\ | 35 | // /!\ /!\ |
| 21 | // /!\ Implementation note! /!\ | 36 | // /!\ Implementation note! /!\ |
| 22 | // /!\ /!\ | 37 | // /!\ /!\ |
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 3b09f1b34..72a7d05ab 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -12,6 +12,21 @@ use stm32_metapac::i2c::vals::{Addmode, Oamsk}; | |||
| 12 | use super::*; | 12 | use super::*; |
| 13 | use crate::pac::i2c; | 13 | use crate::pac::i2c; |
| 14 | 14 | ||
| 15 | use embassy_sync::waitqueue::AtomicWaker; | ||
| 16 | |||
| 17 | /// I2C v2 peripheral state | ||
| 18 | pub(crate) struct State { | ||
| 19 | pub(crate) waker: AtomicWaker, | ||
| 20 | } | ||
| 21 | |||
| 22 | impl State { | ||
| 23 | pub(crate) const fn new() -> Self { | ||
| 24 | Self { | ||
| 25 | waker: AtomicWaker::new(), | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 15 | impl From<AddrMask> for Oamsk { | 30 | impl From<AddrMask> for Oamsk { |
| 16 | fn from(value: AddrMask) -> Self { | 31 | fn from(value: AddrMask) -> Self { |
| 17 | match value { | 32 | match value { |
