Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dstric-aqueduct committed Dec 7, 2022
1 parent bc428c0 commit fef5223
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
14 changes: 12 additions & 2 deletions imxrt1060-hal/src/can/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@
use super::{ExtendedId, Id, StandardId};

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub enum FlexCanIde {
#[default]
None = 0,
Ext = 1,
Rtr = 2,
Std = 3,
Inactive
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub enum FlexCanFlten {
AcceptAll = 0,
#[default]
RejectAll = 1,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub struct FlexCanFilter {
pub filter_id: u8,
pub id: u32,
pub ide: FlexCanIde,
pub remote: FlexCanIde
}

const F32_RTR: u32 = 0b010; // set the RTR bit to match remote frames
const F32_IDE: u32 = 0b100; // set the IDE bit to match extended identifiers
const F16_RTR: u16 = 0b10000;
Expand Down
7 changes: 7 additions & 0 deletions imxrt1060-hal/src/can/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ impl IdReg {

const RTR_MASK: u32 = 0x0000_0002;

/// Creates a new standard identifier (11bit, Range: 0..0x7FF)
///
/// Panics for IDs outside the allowed range.
pub fn new(reg: u32) -> Self {
Self(reg)
}

/// Creates a new standard identifier (11bit, Range: 0..0x7FF)
///
/// Panics for IDs outside the allowed range.
Expand Down
16 changes: 16 additions & 0 deletions imxrt1060-hal/src/can/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ impl From<&Frame> for MailboxData {
}
}

impl From<&MailboxData> for Frame {
fn from(d: &MailboxData) -> Self {
Self {
id: IdReg::new(d.id),
data: d.data.into(),
}
}
}

const FLEXCAN_MB_CS_CODE_MASK: u32 = 0x0F000000;

#[repr(u8)]
Expand Down Expand Up @@ -836,6 +845,13 @@ where
})
}

pub fn set_fifo_filter_2(
&mut self,
filter: filter::FlexCanFilter
) {
self.set_fifo_filter(filter.filter_id, filter.id, filter.ide, filter.remote)
}

pub fn enable_fifo_interrupt(&mut self, enabled: bool) {
/* FIFO must be enabled first */
if !self.fifo_enabled() {
Expand Down

0 comments on commit fef5223

Please sign in to comment.