diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-04-02 01:29:52 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-04-02 11:08:03 +0200 |
| commit | c8936edb6c13eb099dfb31a4a51be2dd3bb4661e (patch) | |
| tree | 0dd904e9264bc0e15ab54490cf2caa91717d9d1f /examples/stm32f1 | |
| parent | e0f0430e2cb04f373f3e93e7abd27eba39d3eb7f (diff) | |
stm32/can: simplify bxcan api, merging bx::* into the main structs.
The bx::* separate structs (Can, Rx, Tx) and separate `Instance` trait
are a relic from the `bxcan` crate. Remove them, move the functionality
into the main structs.
Diffstat (limited to 'examples/stm32f1')
| -rw-r--r-- | examples/stm32f1/src/bin/can.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/examples/stm32f1/src/bin/can.rs b/examples/stm32f1/src/bin/can.rs index 90cb9e46b..1c13d623d 100644 --- a/examples/stm32f1/src/bin/can.rs +++ b/examples/stm32f1/src/bin/can.rs | |||
| @@ -3,8 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::can::frame::Envelope; | ||
| 6 | use embassy_stm32::can::{ | 7 | use embassy_stm32::can::{ |
| 7 | filter, Can, Envelope, Fifo, Frame, Id, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, StandardId, | 8 | filter, Can, Fifo, Frame, Id, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, StandardId, |
| 8 | TxInterruptHandler, | 9 | TxInterruptHandler, |
| 9 | }; | 10 | }; |
| 10 | use embassy_stm32::peripherals::CAN; | 11 | use embassy_stm32::peripherals::CAN; |
| @@ -55,17 +56,13 @@ async fn main(_spawner: Spawner) { | |||
| 55 | 56 | ||
| 56 | let mut can = Can::new(p.CAN, p.PB8, p.PB9, Irqs); | 57 | let mut can = Can::new(p.CAN, p.PB8, p.PB9, Irqs); |
| 57 | 58 | ||
| 58 | can.as_mut() | 59 | can.modify_filters() |
| 59 | .modify_filters() | ||
| 60 | .enable_bank(0, Fifo::Fifo0, filter::Mask32::accept_all()); | 60 | .enable_bank(0, Fifo::Fifo0, filter::Mask32::accept_all()); |
| 61 | 61 | ||
| 62 | can.as_mut() | 62 | can.modify_config() |
| 63 | .modify_config() | ||
| 64 | .set_loopback(false) | 63 | .set_loopback(false) |
| 65 | .set_silent(false) | 64 | .set_silent(false) |
| 66 | .leave_disabled(); | 65 | .set_bitrate(250_000); |
| 67 | |||
| 68 | can.set_bitrate(250_000); | ||
| 69 | 66 | ||
| 70 | can.enable().await; | 67 | can.enable().await; |
| 71 | let mut i: u8 = 0; | 68 | let mut i: u8 = 0; |
