From 407a9e0b9399c520a8a7c3ab914711041d33f6f6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 20 Sep 2024 11:41:03 +0200 Subject: [PATCH] bmstall is configurable now as well --- examples/simple/examples/spi.rs | 2 ++ va108xx-hal/src/spi.rs | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/simple/examples/spi.rs b/examples/simple/examples/spi.rs index ff0195f..13d6b6f 100644 --- a/examples/simple/examples/spi.rs +++ b/examples/simple/examples/spi.rs @@ -125,6 +125,7 @@ fn main() -> ! { Some(spi_clk_cfg), Some(SPI_MODE), BLOCKMODE, + true, false, ); spi.cfg_transfer(&transfer_cfg); @@ -138,6 +139,7 @@ fn main() -> ! { Some(SPI_MODE), Some(hw_cs_pin), BLOCKMODE, + true, false, ); spi.cfg_transfer(&transfer_cfg); diff --git a/va108xx-hal/src/spi.rs b/va108xx-hal/src/spi.rs index 219cb9f..c9e41fd 100644 --- a/va108xx-hal/src/spi.rs +++ b/va108xx-hal/src/spi.rs @@ -301,6 +301,9 @@ pub struct TransferConfig { /// the BMSTOP bit is set on a dataword. A frame is defined as CSn being active for the /// duration of multiple data words pub blockmode: bool, + /// Only used when blockmode is used. The SCK will be stalled until an explicit stop bit + /// is set on a written word. + pub bmstall: bool, pub hw_cs: HwChipSelectId, } @@ -309,6 +312,7 @@ impl TransferConfigWithHwcs { clk_cfg: Option, mode: Option, blockmode: bool, + bmstall: bool, sod: bool, ) -> Self { TransferConfigWithHwcs { @@ -318,6 +322,7 @@ impl TransferConfigWithHwcs { mode, sod, blockmode, + bmstall, hw_cs: HwChipSelectId::Invalid, }, } @@ -330,6 +335,7 @@ impl TransferConfigWithHwcs { mode: Option, hw_cs: Option, blockmode: bool, + bmstall: bool, sod: bool, ) -> Self { TransferConfigWithHwcs { @@ -339,6 +345,7 @@ impl TransferConfigWithHwcs { mode, sod, blockmode, + bmstall, hw_cs: HwCs::CS_ID, }, } @@ -421,6 +428,11 @@ impl SpiConfig { self } + pub fn bmstall(mut self, enable: bool) -> Self { + self.bmstall = enable; + self + } + pub fn mode(mut self, mode: Mode) -> Self { self.init_mode = mode; self @@ -744,12 +756,8 @@ where } else { w.sod().clear_bit(); } - if transfer_cfg.cfg.blockmode { - w.blockmode().set_bit(); - } else { - w.blockmode().clear_bit(); - } - w + w.blockmode().bit(transfer_cfg.cfg.blockmode); + w.bmstall().bit(transfer_cfg.cfg.bmstall) }); }