fix SPI examples
Some checks failed
Rust/va416xx-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
2024-09-20 11:39:59 +02:00
parent 3f98fe7d93
commit ca580c88be
2 changed files with 33 additions and 15 deletions

View File

@ -255,6 +255,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,
}
@ -263,6 +266,7 @@ impl TransferConfigWithHwcs<NoneT> {
clk_cfg: Option<SpiClkConfig>,
mode: Option<Mode>,
blockmode: bool,
bmstall: bool,
sod: bool,
) -> Self {
TransferConfigWithHwcs {
@ -272,6 +276,7 @@ impl TransferConfigWithHwcs<NoneT> {
mode,
sod,
blockmode,
bmstall,
hw_cs: HwChipSelectId::Invalid,
},
}
@ -284,6 +289,7 @@ impl<HwCs: HwCsProvider> TransferConfigWithHwcs<HwCs> {
mode: Option<Mode>,
hw_cs: Option<HwCs>,
blockmode: bool,
bmstall: bool,
sod: bool,
) -> Self {
TransferConfigWithHwcs {
@ -293,6 +299,7 @@ impl<HwCs: HwCsProvider> TransferConfigWithHwcs<HwCs> {
mode,
sod,
blockmode,
bmstall,
hw_cs: HwCs::CS_ID,
},
}
@ -370,6 +377,21 @@ impl SpiConfig {
self
}
pub fn blockmode(mut self, enable: bool) -> Self {
self.blockmode = enable;
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
}
pub fn clk_cfg(mut self, clk_cfg: SpiClkConfig) -> Self {
self.clk = clk_cfg;
self
@ -719,12 +741,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)
});
}