Skip to content

Commit a437421

Browse files
committed
Implement free() method for CAN
1 parent a91344a commit a437421

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/can.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ cfg_if! {
5757
///
5858
/// See [`bxcan::Instance`] for more information on how to use the CAN interface.
5959
pub struct Can<Tx, Rx> {
60-
_can: pac::CAN,
61-
_tx: TX,
62-
_rx: RX,
60+
can: pac::CAN,
61+
tx: Tx,
62+
rx: Rx,
6363
}
6464

6565
impl<Tx, Rx> Can<Tx, Rx>
@@ -79,11 +79,16 @@ where
7979
apb1.rstr().modify(|_, w| w.canrst().clear_bit());
8080

8181
bxcan::Can::new(Can {
82-
_can: can,
83-
_tx: tx,
84-
_rx: rx,
82+
can,
83+
tx,
84+
rx,
8585
})
8686
}
87+
88+
/// Releases the CAN peripheral and associated pins
89+
pub fn free(self) -> (pac::CAN, Tx, Rx) {
90+
(self.can, self.tx, self.rx)
91+
}
8792
}
8893

8994
unsafe impl<Tx, Rx> bxcan::Instance for Can<Tx, Rx> {

0 commit comments

Comments
 (0)