make stm32f4 example work
This commit is contained in:
parent
e3e8d82933
commit
1869fe02ba
@ -2,8 +2,8 @@
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::bind_interrupts;
|
||||
use embassy_stm32::can::bxcan::filter::Mask32;
|
||||
use embassy_stm32::can::bxcan::{Fifo, Frame, StandardId};
|
||||
@ -19,8 +19,8 @@ bind_interrupts!(struct Irqs {
|
||||
CAN1_TX => TxInterruptHandler<CAN1>;
|
||||
});
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
info!("Hello World!");
|
||||
|
||||
let mut p = embassy_stm32::init(Default::default());
|
||||
@ -34,9 +34,12 @@ fn main() -> ! {
|
||||
|
||||
let mut can = Can::new(p.CAN1, p.PA11, p.PA12, Irqs);
|
||||
|
||||
can.modify_filters().enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
|
||||
can.as_mut()
|
||||
.modify_filters()
|
||||
.enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
|
||||
|
||||
can.modify_config()
|
||||
can.as_mut()
|
||||
.modify_config()
|
||||
.set_bit_timing(0x001c0003) // http://www.bittiming.can-wiki.info/
|
||||
.set_loopback(true) // Receive own frames
|
||||
.set_silent(true)
|
||||
@ -45,9 +48,8 @@ fn main() -> ! {
|
||||
let mut i: u8 = 0;
|
||||
loop {
|
||||
let tx_frame = Frame::new_data(unwrap!(StandardId::new(i as _)), [i]);
|
||||
unwrap!(nb::block!(can.transmit(&tx_frame)));
|
||||
while !can.is_transmitter_idle() {}
|
||||
let rx_frame = unwrap!(nb::block!(can.receive()));
|
||||
can.write(&tx_frame).await;
|
||||
let (_, rx_frame) = can.read().await.unwrap();
|
||||
info!("loopback frame {=u8}", unwrap!(rx_frame.data())[0]);
|
||||
i += 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user