File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111- Increased MSRV to 1.81 due to ` core::error::Error `
1212- Bumped ` defmt ` to v1
1313- ` defmt-03 ` feature is now named ` defmt `
14+ - Added CAN FD support
1415
1516### Added
1617
Original file line number Diff line number Diff line change @@ -15,3 +15,19 @@ pub trait Can {
1515 /// Blocks until a frame was received or an error occurred.
1616 fn receive ( & mut self ) -> Result < Self :: Frame , Self :: Error > ;
1717}
18+
19+ /// A blocking CAN FD interface that is able to transmit and receive fd frames.
20+ pub trait CanFD {
21+ /// Associated frame type.
22+ type FDFrame : crate :: FDFrame ;
23+
24+ /// Associated error type.
25+ type Error : crate :: Error ;
26+
27+ /// Puts a fd frame in the transmit buffer. Blocks until space is available in
28+ /// the transmit buffer.
29+ fn transmit_fd ( & mut self , frame : & Self :: FDFrame ) -> Result < ( ) , Self :: Error > ;
30+
31+ /// Blocks until a fd frame was received or an error occurred.
32+ fn receive_fd ( & mut self ) -> Result < Self :: FDFrame , Self :: Error > ;
33+ }
Original file line number Diff line number Diff line change @@ -26,3 +26,33 @@ pub trait Can {
2626 /// Returns a received frame if available.
2727 fn receive ( & mut self ) -> nb:: Result < Self :: Frame , Self :: Error > ;
2828}
29+
30+ /// A CAN FD interface that is able to transmit and receive frames.
31+ pub trait CanFD {
32+ /// Associated frame type.
33+ type FDFrame : crate :: FDFrame ;
34+
35+ /// Associated error type.
36+ type Error : crate :: Error ;
37+
38+ /// Puts a fd frame in the transmit buffer to be sent on the bus.
39+ ///
40+ /// If the transmit buffer is full, this function will try to replace a pending
41+ /// lower priority frame and return the frame that was replaced.
42+ /// Returns `Err(WouldBlock)` if the transmit buffer is full and no frame can be
43+ /// replaced.
44+ ///
45+ /// # Notes for implementers
46+ ///
47+ /// * Frames of equal identifier shall be transmitted in FIFO fashion when more
48+ /// than one transmit buffer is available.
49+ /// * When replacing pending frames make sure the frame is not in the process of
50+ /// being send to the bus.
51+ fn transmit_fd (
52+ & mut self ,
53+ frame : & Self :: FDFrame ,
54+ ) -> nb:: Result < Option < Self :: FDFrame > , Self :: Error > ;
55+
56+ /// Returns a received frame if available.
57+ fn receive_fd ( & mut self ) -> nb:: Result < Self :: FDFrame , Self :: Error > ;
58+ }
You can’t perform that action at this time.
0 commit comments