aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32h7
diff options
context:
space:
mode:
authorCorey Schuhen <[email protected]>2024-03-24 15:13:55 +1000
committerCorey Schuhen <[email protected]>2024-03-28 09:32:13 +1000
commit2217b802781b5f2188b4da659aca47f9d89ee032 (patch)
tree3054378ec4087372858312e74091f9a16ce26efd /examples/stm32h7
parentf5daa50a7baceb44f2aad44bf6ce055bccb08433 (diff)
CAN: Unify API's between BXCAN and FDCAN. Use Envelope for all read methods instead of a tuple sometimes.
Diffstat (limited to 'examples/stm32h7')
-rw-r--r--examples/stm32h7/src/bin/can.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/stm32h7/src/bin/can.rs b/examples/stm32h7/src/bin/can.rs
index 13a6a5051..22cb27481 100644
--- a/examples/stm32h7/src/bin/can.rs
+++ b/examples/stm32h7/src/bin/can.rs
@@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) {
24 24
25 let peripherals = embassy_stm32::init(config); 25 let peripherals = embassy_stm32::init(config);
26 26
27 let mut can = can::FdcanConfigurator::new(peripherals.FDCAN1, peripherals.PA11, peripherals.PA12, Irqs); 27 let mut can = can::CanConfigurator::new(peripherals.FDCAN1, peripherals.PA11, peripherals.PA12, Irqs);
28 28
29 // 250k bps 29 // 250k bps
30 can.set_bitrate(250_000); 30 can.set_bitrate(250_000);
@@ -38,12 +38,13 @@ async fn main(_spawner: Spawner) {
38 let mut last_read_ts = embassy_time::Instant::now(); 38 let mut last_read_ts = embassy_time::Instant::now();
39 39
40 loop { 40 loop {
41 let frame = can::frame::ClassicFrame::new_extended(0x123456F, &[i; 8]).unwrap(); 41 let frame = can::frame::Frame::new_extended(0x123456F, &[i; 8]).unwrap();
42 info!("Writing frame"); 42 info!("Writing frame");
43 _ = can.write(&frame).await; 43 _ = can.write(&frame).await;
44 44
45 match can.read().await { 45 match can.read().await {
46 Ok((rx_frame, ts)) => { 46 Ok(envelope) => {
47 let (rx_frame, ts) = envelope.parts();
47 let delta = (ts - last_read_ts).as_millis(); 48 let delta = (ts - last_read_ts).as_millis();
48 last_read_ts = ts; 49 last_read_ts = ts;
49 info!( 50 info!(
@@ -69,12 +70,13 @@ async fn main(_spawner: Spawner) {
69 let (mut tx, mut rx) = can.split(); 70 let (mut tx, mut rx) = can.split();
70 // With split 71 // With split
71 loop { 72 loop {
72 let frame = can::frame::ClassicFrame::new_extended(0x123456F, &[i; 8]).unwrap(); 73 let frame = can::frame::Frame::new_extended(0x123456F, &[i; 8]).unwrap();
73 info!("Writing frame"); 74 info!("Writing frame");
74 _ = tx.write(&frame).await; 75 _ = tx.write(&frame).await;
75 76
76 match rx.read().await { 77 match rx.read().await {
77 Ok((rx_frame, ts)) => { 78 Ok(envelope) => {
79 let (rx_frame, ts) = envelope.parts();
78 let delta = (ts - last_read_ts).as_millis(); 80 let delta = (ts - last_read_ts).as_millis();
79 last_read_ts = ts; 81 last_read_ts = ts;
80 info!( 82 info!(