Skip to content

Commit

Permalink
Test CAN1 set_fifo_interrupt(false) behaviors
Browse files Browse the repository at this point in the history
This commit corresponds to a FlexCAN PR review question in imxrt-hal.
I'm sharing it to make reproduction easier.

imxrt-rs/imxrt-hal#122 (comment)
  • Loading branch information
mciantyre authored and Sebastian Kuzminsky committed Aug 2, 2024
1 parent fa307d6 commit 41764c2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
17 changes: 15 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,24 @@ version = "0.4"
version = "0.5"
features = ["imxrt1062"]


#[dependencies.imxrt-hal]
#git = "https://github.com/dstric-aqueduct/imxrt-hal"
#branch = "dev/can"
#path = "../imxrt-hal"
#features = ["imxrt1060"]

[dependencies.imxrt-hal]
version = "0.4.2"
features = ["imxrt1062"]

[patch.crates-io.imxrt-hal]
git = "https://github.com/dstric-aqueduct/imxrt-hal"
branch = "dev/can"
#path = "../imxrt-hal"
#features = ["imxrt1060"]

[patch.crates-io.imxrt-iomuxc]
git = "https://github.com/dstric-aqueduct/imxrt-iomuxc.git"
tag = "v0.1.5-can"

[dependencies.imxrt-rt]
version = "0.1.4"
Expand Down
15 changes: 11 additions & 4 deletions examples/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//!
//! Pinout:
//!
//! - Teensy 4 Pin 22 (CAN1 TX) to TX pin of CAN Transceiver
//! - Teensy 4 Pin 23 (CAN2 RX) to RX pin of CAN Transceiver
//! - Teensy 4 Pin 22 (CAN1 TX) to TX pin of CAN Transceiver
//! - Teensy 4 Pin 23 (CAN2 RX) to RX pin of CAN Transceiver
//!
//! A Can transceiver (such as the Texas Instruments SN65HVD230) is required for this demo.
//!
Expand Down Expand Up @@ -46,22 +46,29 @@ fn main() -> ! {
);

let mut can1 = can1_builder.build(pins.p22, pins.p23);

can1.set_baud_rate(1_000_000);
can1.set_max_mailbox(16);
can1.enable_fifo();
can1.set_fifo_interrupt(true);
can1.set_fifo_interrupt(false);
can1.set_fifo_accept_all();
can1.print_registers();

let id = bsp::hal::can::Id::from(bsp::hal::can::StandardId::new(0x00).unwrap());
let data: [u8; 8] = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07];
let frame = bsp::hal::can::Frame::new_data(id, data);

unsafe { cortex_m::peripheral::NVIC::unmask(bsp::interrupt::CAN1) };
loop {
systick.delay_ms(1000);
led.toggle();
can1.read_mailboxes();
can1.transmit(&frame).ok();
}
}

use bsp::interrupt;
#[cortex_m_rt::interrupt]
fn CAN1() {
log::warn!("CAN1 interrupt fired");
}

0 comments on commit 41764c2

Please sign in to comment.