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

Support for the STM32L0x0 subfamily #146

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
enable dma for i2c on l0x0
jglauche committed Mar 1, 2021
commit 480c488f3a6a5b4d1965526d17d897b6bb67a0b2
15 changes: 9 additions & 6 deletions src/i2c.rs
Original file line number Diff line number Diff line change
@@ -2,13 +2,16 @@

use core::ops::Deref;

#[cfg(feature = "stm32l0x0")]
use core::{marker::PhantomData};

#[cfg(feature = "stm32l0x2")]
use core::{marker::PhantomData, ops::DerefMut, pin::Pin};

#[cfg(feature = "stm32l0x2")]
use as_slice::{AsMutSlice, AsSlice};

#[cfg(feature = "stm32l0x2")]
#[cfg(any(feature = "stm32l0x0", feature = "stm32l0x2"))]
use crate::dma::{self, Buffer};
use crate::pac::i2c1::{
cr2::{AUTOEND_A, RD_WRN_A},
@@ -658,24 +661,24 @@ i2c!(
///
/// This is an implementation detail. The user doesn't have to deal with this
/// directly.
#[cfg(feature = "stm32l0x2")]
#[cfg(any(feature = "stm32l0x0", feature = "stm32l0x2"))]
pub struct Tx<I>(PhantomData<I>);

/// Token used for DMA transfers
///
/// This is an implementation detail. The user doesn't have to deal with this
/// directly.
#[cfg(feature = "stm32l0x2")]
#[cfg(any(feature = "stm32l0x0", feature = "stm32l0x2"))]
pub struct Rx<I>(PhantomData<I>);

/// I2C-specific wrapper around [`dma::Transfer`]
#[cfg(feature = "stm32l0x2")]
#[cfg(any(feature = "stm32l0x0", feature = "stm32l0x2"))]
pub struct Transfer<Target, Token, Channel, Buffer, State> {
target: Target,
inner: dma::Transfer<Token, Channel, Buffer, State>,
}

#[cfg(feature = "stm32l0x2")]
#[cfg(any(feature = "stm32l0x0", feature = "stm32l0x2"))]
impl<Target, Token, Channel, Buffer> Transfer<Target, Token, Channel, Buffer, dma::Ready>
where
Token: dma::Target<Channel>,
@@ -701,7 +704,7 @@ where
}
}

#[cfg(feature = "stm32l0x2")]
#[cfg(any(feature = "stm32l0x0", feature = "stm32l0x2"))]
impl<Target, Token, Channel, Buffer> Transfer<Target, Token, Channel, Buffer, dma::Started>
where
Channel: dma::Channel,