Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dstric-aqueduct committed Nov 27, 2022
1 parent 78183fc commit 52934a6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
5 changes: 1 addition & 4 deletions imxrt1060-hal/src/can/embedded_hal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ where
type Error = OverrunError;

fn transmit(&mut self, frame: &Self::Frame) -> nb::Result<Option<Self::Frame>, Self::Error> {
let data: [u8; 8] = [255, 255, 255, 255, 255, 255, 255, 255];
let id = StandardId::new(0).unwrap();

match self.transmit(frame) {
Ok(status) => Ok(Some(Frame::new_data(id, Data::new(&data).unwrap()))),
Ok(_status) => Ok(Some(frame.clone())),
Err(nb::Error::WouldBlock) => Err(nb::Error::WouldBlock),
Err(nb::Error::Other(e)) => match e {},
}
Expand Down
40 changes: 40 additions & 0 deletions imxrt1060-hal/src/can/isotp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use super::CAN;

use crate::ccm;
use crate::iomuxc::consts::{Unsigned, U1, U2};
use crate::ral;

use core::cmp::Ord;
use core::convert::Infallible;
use core::marker::PhantomData;


/// A CAN ISO-TP builder that can build a CAN peripheral
pub struct IsoTPBuilder<M> {
can: CAN<M>,
}

impl<M> IsoTPBuilder<M>
where
M: Unsigned,
{
pub fn new(can: CAN<M>) -> Self {
IsoTPBuilder {
can,
}
}

pub fn build(self) -> IsoTP<M> {
IsoTP::new(self.can)
}
}

pub struct IsoTP<M> {
pub can: CAN<M>,
}

impl<M> IsoTP<M> {
pub fn new(can: CAN<M>) -> Self {
Self { can }
}
}
2 changes: 2 additions & 0 deletions imxrt1060-hal/src/can/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ pub mod filter;
mod frame;
mod id;
mod interrupt;
mod isotp;

pub use frame::{Data, Frame, FramePriority};
pub use id::{ExtendedId, Id, IdReg, StandardId};
pub use isotp::{IsoTPBuilder, IsoTP};
use ral::{modify_reg, read_reg, write_reg};

use crate::ccm;
Expand Down

0 comments on commit 52934a6

Please sign in to comment.