Move WordSize methods to mod
This commit is contained in:
parent
d426caefbf
commit
d51885c0eb
4 changed files with 43 additions and 41 deletions
|
@ -5,6 +5,7 @@
|
|||
#[cfg_attr(spi_v2, path = "v2.rs")]
|
||||
#[cfg_attr(spi_v3, path = "v3.rs")]
|
||||
mod _version;
|
||||
use crate::pac::spi::vals;
|
||||
use crate::{dma, peripherals, rcc::RccPeripheral};
|
||||
pub use _version::*;
|
||||
|
||||
|
@ -31,6 +32,48 @@ enum WordSize {
|
|||
SixteenBit,
|
||||
}
|
||||
|
||||
impl WordSize {
|
||||
#[cfg(any(spi_v1, spi_f1))]
|
||||
fn dff(&self) -> vals::Dff {
|
||||
match self {
|
||||
WordSize::EightBit => vals::Dff::EIGHTBIT,
|
||||
WordSize::SixteenBit => vals::Dff::SIXTEENBIT,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(spi_v2)]
|
||||
fn ds(&self) -> vals::Ds {
|
||||
match self {
|
||||
WordSize::EightBit => vals::Ds::EIGHTBIT,
|
||||
WordSize::SixteenBit => vals::Ds::SIXTEENBIT,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(spi_v2)]
|
||||
fn frxth(&self) -> vals::Frxth {
|
||||
match self {
|
||||
WordSize::EightBit => vals::Frxth::QUARTER,
|
||||
WordSize::SixteenBit => vals::Frxth::HALF,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(spi_v3)]
|
||||
fn dsize(&self) -> u8 {
|
||||
match self {
|
||||
WordSize::EightBit => 0b0111,
|
||||
WordSize::SixteenBit => 0b1111,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(spi_v3)]
|
||||
fn _frxth(&self) -> vals::Fthlv {
|
||||
match self {
|
||||
WordSize::EightBit => vals::Fthlv::ONEFRAME,
|
||||
WordSize::SixteenBit => vals::Fthlv::ONEFRAME,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
pub struct Config {
|
||||
pub mode: Mode,
|
||||
|
|
|
@ -20,15 +20,6 @@ pub use embedded_hal::blocking;
|
|||
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
|
||||
use futures::future::join3;
|
||||
|
||||
impl WordSize {
|
||||
fn dff(&self) -> spi::vals::Dff {
|
||||
match self {
|
||||
WordSize::EightBit => spi::vals::Dff::EIGHTBIT,
|
||||
WordSize::SixteenBit => spi::vals::Dff::SIXTEENBIT,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Spi<'d, T: Instance, Tx, Rx> {
|
||||
sck: Option<AnyPin>,
|
||||
mosi: Option<AnyPin>,
|
||||
|
|
|
@ -18,22 +18,6 @@ use embassy_traits::spi as traits;
|
|||
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
|
||||
use futures::future::{join, join3};
|
||||
|
||||
impl WordSize {
|
||||
fn ds(&self) -> spi::vals::Ds {
|
||||
match self {
|
||||
WordSize::EightBit => spi::vals::Ds::EIGHTBIT,
|
||||
WordSize::SixteenBit => spi::vals::Ds::SIXTEENBIT,
|
||||
}
|
||||
}
|
||||
|
||||
fn frxth(&self) -> spi::vals::Frxth {
|
||||
match self {
|
||||
WordSize::EightBit => spi::vals::Frxth::QUARTER,
|
||||
WordSize::SixteenBit => spi::vals::Frxth::HALF,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Spi<'d, T: Instance, Tx, Rx> {
|
||||
sck: Option<AnyPin>,
|
||||
mosi: Option<AnyPin>,
|
||||
|
|
|
@ -19,22 +19,6 @@ pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_
|
|||
|
||||
use futures::future::join3;
|
||||
|
||||
impl WordSize {
|
||||
fn dsize(&self) -> u8 {
|
||||
match self {
|
||||
WordSize::EightBit => 0b0111,
|
||||
WordSize::SixteenBit => 0b1111,
|
||||
}
|
||||
}
|
||||
|
||||
fn _frxth(&self) -> spi::vals::Fthlv {
|
||||
match self {
|
||||
WordSize::EightBit => spi::vals::Fthlv::ONEFRAME,
|
||||
WordSize::SixteenBit => spi::vals::Fthlv::ONEFRAME,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct Spi<'d, T: Instance, Tx = NoDma, Rx = NoDma> {
|
||||
sck: Option<AnyPin>,
|
||||
|
|
Loading…
Reference in a new issue