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 /tests | |
| 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 'tests')
| -rw-r--r-- | tests/stm32/src/bin/can.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs index 74d84c42f..551764458 100644 --- a/tests/stm32/src/bin/can.rs +++ b/tests/stm32/src/bin/can.rs | |||
| @@ -8,9 +8,10 @@ mod common; | |||
| 8 | use common::*; | 8 | use common::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::bind_interrupts; | 10 | use embassy_stm32::bind_interrupts; |
| 11 | use embassy_stm32::can::bx::filter::Mask32; | 11 | use embassy_stm32::can::filter::Mask32; |
| 12 | use embassy_stm32::can::bx::Fifo; | 12 | use embassy_stm32::can::{ |
| 13 | use embassy_stm32::can::{Can, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler}; | 13 | Can, Fifo, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler, |
| 14 | }; | ||
| 14 | use embassy_stm32::gpio::{Input, Pull}; | 15 | use embassy_stm32::gpio::{Input, Pull}; |
| 15 | use embassy_stm32::peripherals::CAN1; | 16 | use embassy_stm32::peripherals::CAN1; |
| 16 | use embassy_time::Duration; | 17 | use embassy_time::Duration; |
| @@ -51,17 +52,15 @@ async fn main(_spawner: Spawner) { | |||
| 51 | 52 | ||
| 52 | info!("Configuring can..."); | 53 | info!("Configuring can..."); |
| 53 | 54 | ||
| 54 | can.as_mut() | 55 | can.modify_filters().enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); |
| 55 | .modify_filters() | ||
| 56 | .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); | ||
| 57 | 56 | ||
| 58 | can.set_bitrate(1_000_000); | 57 | can.modify_config() |
| 59 | can.as_mut() | ||
| 60 | .modify_config() | ||
| 61 | .set_loopback(true) // Receive own frames | 58 | .set_loopback(true) // Receive own frames |
| 62 | .set_silent(true) | 59 | .set_silent(true) |
| 63 | // .set_bit_timing(0x001c0003) | 60 | // .set_bit_timing(0x001c0003) |
| 64 | .enable(); | 61 | .set_bitrate(1_000_000); |
| 62 | |||
| 63 | can.enable().await; | ||
| 65 | 64 | ||
| 66 | info!("Can configured"); | 65 | info!("Can configured"); |
| 67 | 66 | ||
