Skip to content

Commit e971e8d

Browse files
committed
bmstall is configurable now as well
1 parent 501d1c9 commit e971e8d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

examples/simple/examples/spi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ fn main() -> ! {
125125
Some(spi_clk_cfg),
126126
Some(SPI_MODE),
127127
BLOCKMODE,
128+
true,
128129
false,
129130
);
130131
spi.cfg_transfer(&transfer_cfg);
@@ -138,6 +139,7 @@ fn main() -> ! {
138139
Some(SPI_MODE),
139140
Some(hw_cs_pin),
140141
BLOCKMODE,
142+
true,
141143
false,
142144
);
143145
spi.cfg_transfer(&transfer_cfg);

va108xx-hal/src/spi.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ pub struct TransferConfig {
301301
/// the BMSTOP bit is set on a dataword. A frame is defined as CSn being active for the
302302
/// duration of multiple data words
303303
pub blockmode: bool,
304+
/// Only used when blockmode is used. The SCK will be stalled until an explicit stop bit
305+
/// is set on a written word.
306+
pub bmstall: bool,
304307
pub hw_cs: HwChipSelectId,
305308
}
306309

@@ -309,6 +312,7 @@ impl TransferConfigWithHwcs<NoneT> {
309312
clk_cfg: Option<SpiClkConfig>,
310313
mode: Option<Mode>,
311314
blockmode: bool,
315+
bmstall: bool,
312316
sod: bool,
313317
) -> Self {
314318
TransferConfigWithHwcs {
@@ -318,6 +322,7 @@ impl TransferConfigWithHwcs<NoneT> {
318322
mode,
319323
sod,
320324
blockmode,
325+
bmstall,
321326
hw_cs: HwChipSelectId::Invalid,
322327
},
323328
}
@@ -330,6 +335,7 @@ impl<HwCs: HwCsProvider> TransferConfigWithHwcs<HwCs> {
330335
mode: Option<Mode>,
331336
hw_cs: Option<HwCs>,
332337
blockmode: bool,
338+
bmstall: bool,
333339
sod: bool,
334340
) -> Self {
335341
TransferConfigWithHwcs {
@@ -339,6 +345,7 @@ impl<HwCs: HwCsProvider> TransferConfigWithHwcs<HwCs> {
339345
mode,
340346
sod,
341347
blockmode,
348+
bmstall,
342349
hw_cs: HwCs::CS_ID,
343350
},
344351
}
@@ -421,6 +428,11 @@ impl SpiConfig {
421428
self
422429
}
423430

431+
pub fn bmstall(mut self, enable: bool) -> Self {
432+
self.bmstall = enable;
433+
self
434+
}
435+
424436
pub fn mode(mut self, mode: Mode) -> Self {
425437
self.init_mode = mode;
426438
self
@@ -744,12 +756,8 @@ where
744756
} else {
745757
w.sod().clear_bit();
746758
}
747-
if transfer_cfg.cfg.blockmode {
748-
w.blockmode().set_bit();
749-
} else {
750-
w.blockmode().clear_bit();
751-
}
752-
w
759+
w.blockmode().bit(transfer_cfg.cfg.blockmode);
760+
w.bmstall().bit(transfer_cfg.cfg.bmstall)
753761
});
754762
}
755763

0 commit comments

Comments
 (0)