mcp25625
Full support for tranmission, recepetion and filtering with convenient API.
Define some types to keep everything clean:
pub type Mcp25625Sck = ;
pub type Mcp25625Miso = ;
pub type Mcp25625Mosi = ;
pub type Mcp25625IrqUninit = ;
pub type Mcp25625Cs = ;
pub type Mcp25625Spi = SPI1;
pub type Mcp25625Instance = MCP25625;
Also define filters to use:
const MOTOR_DRIVE_ID: FrameId = new_extended.unwrap;
const EMERGENCY_STOP_ID: FrameId = new_standard.unwrap;
Setup filters and configure:
Unused filter slots are filled with the latest one used. So in this example filter1
= filter0
and filter3-5
= filter2
.
Enable interrupts:
mcp25625.enable_interrupts;
Receive a frame:
let intf = mcp25625.interrupt_flags;
if intf.rx0if_is_set
// Check Buffer1 also depending on the configuration
Send a frame:
// Create RawFrameRef if you do not want to make unnecesarry copies
// or use Frame::as_raw_frame_ref() or RawFrame::as_raw_frame_ref()
let data = ;
let frame = RawFrameRef ;
match mcp25625.send
For more advanced example see this file with hot reinit, interrupts and proper queues for transmission and reception.