Skip to content

Commit 45073dc

Browse files
techmccatusbalbin
authored andcommitted
spi: use hal1 in example, make spi-hal-one a test
1 parent 829ffd6 commit 45073dc

File tree

3 files changed

+183
-209
lines changed

3 files changed

+183
-209
lines changed

examples/spi-example.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use hal::{
99
delay::DelayFromCountDownTimer,
1010
gpio::{AF5, PA5, PA6, PA7},
11-
hal_02::spi::FullDuplex,
1211
prelude::*,
1312
pwr::PwrExt,
1413
rcc::Config,
@@ -49,17 +48,20 @@ fn main() -> ! {
4948

5049
// "Hello world!"
5150
let message = b"Hello world!";
52-
let mut received_byte: u8;
51+
let mut received_msg = [0u8; 12];
5352

5453
loop {
55-
for &byte in message {
56-
cs.set_low();
57-
spi.send(byte).unwrap();
58-
received_byte = nb::block!(FullDuplex::read(&mut spi)).unwrap();
59-
cs.set_high();
54+
cs.set_low();
55+
// write only, nothing is received
56+
spi.write(message).unwrap();
57+
cs.set_high();
58+
59+
cs.set_low();
60+
// transmit and receive at the same time
61+
spi.transfer(&mut received_msg, message).unwrap();
62+
info!("{received_msg:?}");
63+
cs.set_high();
6064

61-
info!("{}", received_byte as char);
62-
}
6365
delay_tim2.delay_ms(1000);
6466
}
6567
}

examples/spi-hal-one.rs

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)