Move Spi to mod (without NoDma defaults)
This commit is contained in:
parent
aeb69a7665
commit
e1cccc8391
@ -1,16 +1,19 @@
|
||||
#![macro_use]
|
||||
|
||||
use crate::dma;
|
||||
use crate::gpio::{AnyPin, NoPin, OptionalPin};
|
||||
use crate::pac::spi::vals;
|
||||
use crate::peripherals;
|
||||
use crate::rcc::RccPeripheral;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
#[cfg_attr(spi_v1, path = "v1.rs")]
|
||||
#[cfg_attr(spi_f1, path = "v1.rs")]
|
||||
#[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::*;
|
||||
|
||||
use crate::gpio::{NoPin, OptionalPin};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub enum Error {
|
||||
@ -89,6 +92,16 @@ impl Default for Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Spi<'d, T: Instance, Tx, Rx> {
|
||||
sck: Option<AnyPin>,
|
||||
mosi: Option<AnyPin>,
|
||||
miso: Option<AnyPin>,
|
||||
txdma: Tx,
|
||||
rxdma: Rx,
|
||||
current_word_size: WordSize,
|
||||
phantom: PhantomData<&'d mut T>,
|
||||
}
|
||||
|
||||
pub(crate) mod sealed {
|
||||
use super::*;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
use crate::dma::NoDma;
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::gpio::sealed::Pin;
|
||||
use crate::gpio::AnyPin;
|
||||
use crate::pac::spi;
|
||||
use crate::spi::{
|
||||
ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel,
|
||||
@ -20,15 +19,7 @@ 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;
|
||||
|
||||
pub struct Spi<'d, T: Instance, Tx, Rx> {
|
||||
sck: Option<AnyPin>,
|
||||
mosi: Option<AnyPin>,
|
||||
miso: Option<AnyPin>,
|
||||
txdma: Tx,
|
||||
rxdma: Rx,
|
||||
current_word_size: WordSize,
|
||||
phantom: PhantomData<&'d mut T>,
|
||||
}
|
||||
use super::Spi;
|
||||
|
||||
impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
||||
pub fn new<F>(
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use crate::dma::NoDma;
|
||||
use crate::gpio::sealed::Pin;
|
||||
use crate::gpio::AnyPin;
|
||||
use crate::pac::spi;
|
||||
use crate::spi::{
|
||||
ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel,
|
||||
@ -18,15 +17,7 @@ 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};
|
||||
|
||||
pub struct Spi<'d, T: Instance, Tx, Rx> {
|
||||
sck: Option<AnyPin>,
|
||||
mosi: Option<AnyPin>,
|
||||
miso: Option<AnyPin>,
|
||||
txdma: Tx,
|
||||
rxdma: Rx,
|
||||
current_word_size: WordSize,
|
||||
phantom: PhantomData<&'d mut T>,
|
||||
}
|
||||
use super::Spi;
|
||||
|
||||
impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
||||
pub fn new<F>(
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use crate::dma::NoDma;
|
||||
use crate::gpio::sealed::Pin;
|
||||
use crate::gpio::AnyPin;
|
||||
use crate::pac::spi;
|
||||
use crate::spi::{
|
||||
ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel,
|
||||
@ -19,16 +18,7 @@ pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_
|
||||
|
||||
use futures::future::join3;
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct Spi<'d, T: Instance, Tx = NoDma, Rx = NoDma> {
|
||||
sck: Option<AnyPin>,
|
||||
mosi: Option<AnyPin>,
|
||||
miso: Option<AnyPin>,
|
||||
txdma: Tx,
|
||||
rxdma: Rx,
|
||||
current_word_size: WordSize,
|
||||
phantom: PhantomData<&'d mut T>,
|
||||
}
|
||||
use super::Spi;
|
||||
|
||||
impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
||||
pub fn new<F>(
|
||||
@ -338,7 +328,7 @@ impl<'d, T: Instance, Tx, Rx> Drop for Spi<'d, T, Tx, Rx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u8> for Spi<'d, T, NoDma> {
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u8> for Spi<'d, T, NoDma, NoDma> {
|
||||
type Error = Error;
|
||||
|
||||
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
|
||||
@ -386,7 +376,7 @@ impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u8> for Spi<'d, T, NoDm
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Transfer<u8> for Spi<'d, T, NoDma> {
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Transfer<u8> for Spi<'d, T, NoDma, NoDma> {
|
||||
type Error = Error;
|
||||
|
||||
fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> {
|
||||
@ -443,7 +433,7 @@ impl<'d, T: Instance> embedded_hal::blocking::spi::Transfer<u8> for Spi<'d, T, N
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u16> for Spi<'d, T, NoDma> {
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u16> for Spi<'d, T, NoDma, NoDma> {
|
||||
type Error = Error;
|
||||
|
||||
fn write(&mut self, words: &[u16]) -> Result<(), Self::Error> {
|
||||
@ -492,7 +482,7 @@ impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u16> for Spi<'d, T, NoD
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Transfer<u16> for Spi<'d, T, NoDma> {
|
||||
impl<'d, T: Instance> embedded_hal::blocking::spi::Transfer<u16> for Spi<'d, T, NoDma, NoDma> {
|
||||
type Error = Error;
|
||||
|
||||
fn transfer<'w>(&mut self, words: &'w mut [u16]) -> Result<&'w [u16], Self::Error> {
|
||||
|
Loading…
Reference in New Issue
Block a user