aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHybridChild <[email protected]>2025-07-27 10:53:48 +0200
committerHybridChild <[email protected]>2025-08-23 08:48:46 +0200
commitb690a0314f0f2e42137ad4b3e867e056c1d3c14e (patch)
tree3a195fa5486c65a80bc7fbf62d747b3ff24091b7
parent399ec8d90f1c4f62fd20d21dabbb9ce64c6986eb (diff)
stm32/i2c: v1 and v2 now has separate definitions for the State struct
-rw-r--r--embassy-stm32/src/i2c/mod.rs17
-rw-r--r--embassy-stm32/src/i2c/v1.rs15
-rw-r--r--embassy-stm32/src/i2c/v2.rs15
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")]
6mod _version; 6mod _version;
7 7
8// Type alias for the peri_trait! macro
9type State = _version::State;
10
8mod config; 11mod config;
9 12
10use core::future::Future; 13use core::future::Future;
@@ -13,7 +16,6 @@ use core::marker::PhantomData;
13 16
14pub use config::*; 17pub use config::*;
15use embassy_hal_internal::Peri; 18use embassy_hal_internal::Peri;
16use embassy_sync::waitqueue::AtomicWaker;
17#[cfg(feature = "time")] 19#[cfg(feature = "time")]
18use embassy_time::{Duration, Instant}; 20use embassy_time::{Duration, Instant};
19use mode::MasterMode; 21use mode::MasterMode;
@@ -274,19 +276,6 @@ impl Timeout {
274 } 276 }
275} 277}
276 278
277struct State {
278 #[allow(unused)]
279 waker: AtomicWaker,
280}
281
282impl State {
283 const fn new() -> Self {
284 Self {
285 waker: AtomicWaker::new(),
286 }
287 }
288}
289
290struct Info { 279struct 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::*;
17use crate::mode::Mode; 17use crate::mode::Mode;
18use crate::pac::i2c; 18use crate::pac::i2c;
19 19
20use embassy_sync::waitqueue::AtomicWaker;
21
22/// I2C v2 peripheral state
23pub(crate) struct State {
24 pub(crate) waker: AtomicWaker,
25}
26
27impl 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};
12use super::*; 12use super::*;
13use crate::pac::i2c; 13use crate::pac::i2c;
14 14
15use embassy_sync::waitqueue::AtomicWaker;
16
17/// I2C v2 peripheral state
18pub(crate) struct State {
19 pub(crate) waker: AtomicWaker,
20}
21
22impl State {
23 pub(crate) const fn new() -> Self {
24 Self {
25 waker: AtomicWaker::new(),
26 }
27 }
28}
29
15impl From<AddrMask> for Oamsk { 30impl From<AddrMask> for Oamsk {
16 fn from(value: AddrMask) -> Self { 31 fn from(value: AddrMask) -> Self {
17 match value { 32 match value {