somethings wrong
All checks were successful
Rust/va108xx-rs/pipeline/pr-main This commit looks good

This commit is contained in:
2024-09-19 17:50:53 +02:00
parent c34fbb01f5
commit 6e48bf8d24
4 changed files with 119 additions and 26 deletions

View File

@ -17,7 +17,7 @@ use crate::{
PeripheralSelect,
};
use core::{convert::Infallible, fmt::Debug, marker::PhantomData, ops::Deref};
use embedded_hal::spi::{Mode, MODE_0, MODE_1, MODE_2, MODE_3};
use embedded_hal::spi::Mode;
//==================================================================================================
// Defintions
@ -226,6 +226,7 @@ hw_cs_pins!(
pub struct RomSck;
pub struct RomMosi;
pub struct RomMiso;
pub struct RomCs;
impl Sealed for RomSck {}
impl PinSck<pac::Spic> for RomSck {}
@ -233,6 +234,7 @@ impl Sealed for RomMosi {}
impl PinMosi<pac::Spic> for RomMosi {}
impl Sealed for RomMiso {}
impl PinMiso<pac::Spic> for RomMiso {}
impl Sealed for RomCs {}
hw_cs_pins!(
pac::Spic, SpiPort::Portc:
@ -250,6 +252,12 @@ hw_cs_pins!(
(PA20, AltFunc3, HwChipSelectId::Id4, HwCs4SpiCPortA),
);
impl HwCsProvider for RomCs {
const CS_ID: HwChipSelectId = HwChipSelectId::Id0;
const SPI_PORT: SpiPort = SpiPort::Portc;
}
impl OptionalHwCs<pac::Spic> for RomCs {}
//==================================================================================================
// Config
//==================================================================================================
@ -674,6 +682,18 @@ where
#[inline]
pub fn fill_word(&self) -> Word;
#[inline]
pub fn spi(&self) -> &SpiI;
#[inline]
pub fn cfg_hw_cs(&mut self, hw_cs: HwChipSelectId);
#[inline]
pub fn cfg_hw_cs_with_pin<HwCs: OptionalHwCs<SpiI>>(&mut self, _hwcs: &HwCs);
#[inline]
pub fn cfg_hw_cs_disable(&mut self);
pub fn cfg_transfer<HwCs: OptionalHwCs<SpiI>>(
&mut self, transfer_cfg: &TransferConfigWithHwcs<HwCs>
);
@ -698,6 +718,11 @@ impl<SpiInstance: Instance, Word: WordProvider> SpiBase<SpiInstance, Word>
where
<Word as TryFrom<u32>>::Error: core::fmt::Debug,
{
#[inline]
pub fn spi(&self) -> &SpiInstance {
&self.spi
}
#[inline]
pub fn cfg_clock(&mut self, cfg: SpiClkConfig) {
self.spi
@ -717,12 +742,7 @@ where
#[inline]
pub fn cfg_mode(&mut self, mode: Mode) {
let (cpo_bit, cph_bit) = match mode {
MODE_0 => (false, false),
MODE_1 => (false, true),
MODE_2 => (true, false),
MODE_3 => (true, true),
};
let (cpo_bit, cph_bit) = mode_to_cpo_cph_bit(mode);
self.spi.ctrl0().modify(|_, w| {
w.spo().bit(cpo_bit);
w.sph().bit(cph_bit)