bmstall is configurable now as well #15

Merged
muellerr merged 1 commits from va108xx-update-package into main 2024-09-20 12:13:13 +02:00
2 changed files with 16 additions and 6 deletions
Showing only changes of commit e971e8dc0d - Show all commits

View File

@ -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);

View File

@ -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<NoneT> {
clk_cfg: Option<SpiClkConfig>,
mode: Option<Mode>,
blockmode: bool,
bmstall: bool,
sod: bool,
) -> Self {
TransferConfigWithHwcs {
@ -318,6 +322,7 @@ impl TransferConfigWithHwcs<NoneT> {
mode,
sod,
blockmode,
bmstall,
hw_cs: HwChipSelectId::Invalid,
},
}
@ -330,6 +335,7 @@ impl<HwCs: HwCsProvider> TransferConfigWithHwcs<HwCs> {
mode: Option<Mode>,
hw_cs: Option<HwCs>,
blockmode: bool,
bmstall: bool,
sod: bool,
) -> Self {
TransferConfigWithHwcs {
@ -339,6 +345,7 @@ impl<HwCs: HwCsProvider> TransferConfigWithHwcs<HwCs> {
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)
});
}