diff options
| author | xoviat <[email protected]> | 2021-03-15 18:19:28 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2021-03-15 18:19:28 -0500 |
| commit | cb8d53e498aa060f2ec37afb2ca88d1409e8cefd (patch) | |
| tree | 91a4d6cea93dcef652d6e7a62d57e1eb4e9aeec4 | |
| parent | 0fbb3174d212a3a5a59effb5984fdccbd36de93a (diff) | |
fixup
| -rw-r--r-- | embassy-stm32f4-examples/.cargo/config | 2 | ||||
| -rw-r--r-- | embassy-stm32f4-examples/src/bin/can.rs | 17 |
2 files changed, 7 insertions, 12 deletions
diff --git a/embassy-stm32f4-examples/.cargo/config b/embassy-stm32f4-examples/.cargo/config index 3ccca879d..7c1d4dfb6 100644 --- a/embassy-stm32f4-examples/.cargo/config +++ b/embassy-stm32f4-examples/.cargo/config | |||
| @@ -25,4 +25,4 @@ rustflags = [ | |||
| 25 | ] | 25 | ] |
| 26 | 26 | ||
| 27 | [build] | 27 | [build] |
| 28 | target = "thumbv7em-none-eabi" | 28 | target = "thumbv7em-none-eabihf" |
diff --git a/embassy-stm32f4-examples/src/bin/can.rs b/embassy-stm32f4-examples/src/bin/can.rs index c91447623..34ad12b59 100644 --- a/embassy-stm32f4-examples/src/bin/can.rs +++ b/embassy-stm32f4-examples/src/bin/can.rs | |||
| @@ -7,21 +7,22 @@ | |||
| 7 | mod example_common; | 7 | mod example_common; |
| 8 | use example_common::{panic, *}; | 8 | use example_common::{panic, *}; |
| 9 | 9 | ||
| 10 | use bxcan::filter::Mask32; | ||
| 10 | use cortex_m_rt::entry; | 11 | use cortex_m_rt::entry; |
| 11 | use embassy::executor::{task, Executor}; | 12 | use embassy::executor::{task, Executor}; |
| 12 | use embassy::traits::gpio::*; | 13 | use embassy::traits::gpio::*; |
| 13 | use embassy::util::Forever; | 14 | use embassy::util::Forever; |
| 14 | use embassy_stm32f4::can; | 15 | use embassy_stm32f4::{can, exti, interrupt}; |
| 15 | use embassy_stm32f4::exti; | ||
| 16 | use embassy_stm32f4::interrupt; | ||
| 17 | use futures::pin_mut; | 16 | use futures::pin_mut; |
| 18 | use stm32f4xx_hal::prelude::*; | 17 | use stm32f4xx_hal::prelude::*; |
| 19 | use stm32f4xx_hal::stm32; | 18 | use stm32f4xx_hal::{can::Can, stm32}; |
| 20 | 19 | ||
| 21 | static EXTI: Forever<exti::ExtiManager> = Forever::new(); | 20 | static EXTI: Forever<exti::ExtiManager> = Forever::new(); |
| 22 | 21 | ||
| 23 | #[task] | 22 | #[task] |
| 24 | async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { | 23 | async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { |
| 24 | let gpioa = dp.GPIOA.split(); | ||
| 25 | |||
| 25 | let rx = gpioa.pa11.into_alternate_af9(); | 26 | let rx = gpioa.pa11.into_alternate_af9(); |
| 26 | let tx = gpioa.pa12.into_alternate_af9(); | 27 | let tx = gpioa.pa12.into_alternate_af9(); |
| 27 | let mut can = bxcan::Can::new(Can::new(dp.CAN1, (tx, rx))); | 28 | let mut can = bxcan::Can::new(Can::new(dp.CAN1, (tx, rx))); |
| @@ -32,13 +33,7 @@ async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { | |||
| 32 | // Configure filters so that can frames can be received. | 33 | // Configure filters so that can frames can be received. |
| 33 | can.modify_filters().enable_bank(0, Mask32::accept_all()); | 34 | can.modify_filters().enable_bank(0, Mask32::accept_all()); |
| 34 | 35 | ||
| 35 | block!(can.enable()).unwrap(); | 36 | let mut can = can::Can::new(can, interrupt::take!(CAN1_TX), interrupt::take!(CAN1_RX0)); |
| 36 | |||
| 37 | let can = can::Can::new( | ||
| 38 | can, | ||
| 39 | interrupt::take!(CAN1_TX), | ||
| 40 | interrupt::take!(CAN1_RX0), | ||
| 41 | )); | ||
| 42 | 37 | ||
| 43 | let frame = can.receive().await; | 38 | let frame = can.receive().await; |
| 44 | } | 39 | } |
