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/stm32f7/src | |
| 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/stm32f7/src')
| -rw-r--r-- | examples/stm32f7/src/bin/can.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/examples/stm32f7/src/bin/can.rs b/examples/stm32f7/src/bin/can.rs index 221ac2a05..e32b4d3df 100644 --- a/examples/stm32f7/src/bin/can.rs +++ b/examples/stm32f7/src/bin/can.rs | |||
| @@ -47,20 +47,18 @@ async fn main(spawner: Spawner) { | |||
| 47 | 47 | ||
| 48 | static CAN: StaticCell<Can<'static, CAN3>> = StaticCell::new(); | 48 | static CAN: StaticCell<Can<'static, CAN3>> = StaticCell::new(); |
| 49 | let can = CAN.init(Can::new(p.CAN3, p.PA8, p.PA15, Irqs)); | 49 | let can = CAN.init(Can::new(p.CAN3, p.PA8, p.PA15, Irqs)); |
| 50 | can.as_mut() | 50 | can.modify_filters().enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); |
| 51 | .modify_filters() | ||
| 52 | .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); | ||
| 53 | 51 | ||
| 54 | can.as_mut() | 52 | can.modify_config() |
| 55 | .modify_config() | ||
| 56 | .set_bit_timing(can::util::NominalBitTiming { | 53 | .set_bit_timing(can::util::NominalBitTiming { |
| 57 | prescaler: NonZeroU16::new(2).unwrap(), | 54 | prescaler: NonZeroU16::new(2).unwrap(), |
| 58 | seg1: NonZeroU8::new(13).unwrap(), | 55 | seg1: NonZeroU8::new(13).unwrap(), |
| 59 | seg2: NonZeroU8::new(2).unwrap(), | 56 | seg2: NonZeroU8::new(2).unwrap(), |
| 60 | sync_jump_width: NonZeroU8::new(1).unwrap(), | 57 | sync_jump_width: NonZeroU8::new(1).unwrap(), |
| 61 | }) // http://www.bittiming.can-wiki.info/ | 58 | }) // http://www.bittiming.can-wiki.info/ |
| 62 | .set_loopback(true) | 59 | .set_loopback(true); |
| 63 | .enable(); | 60 | |
| 61 | can.enable().await; | ||
| 64 | 62 | ||
| 65 | let (tx, mut rx) = can.split(); | 63 | let (tx, mut rx) = can.split(); |
| 66 | 64 | ||
