Skip to content

Commit 3d3a38e

Browse files
committed
Implement free() method for CAN
1 parent 8ad482d commit 3d3a38e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/can.rs

+9-8
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>
@@ -78,11 +78,12 @@ where
7878
apb1.rstr().modify(|_, w| w.canrst().set_bit());
7979
apb1.rstr().modify(|_, w| w.canrst().clear_bit());
8080

81-
bxcan::Can::new(Can {
82-
_can: can,
83-
_tx: tx,
84-
_rx: rx,
85-
})
81+
bxcan::Can::new(Can { can, tx, rx })
82+
}
83+
84+
/// Releases the CAN peripheral and associated pins
85+
pub fn free(self) -> (pac::CAN, Tx, Rx) {
86+
(self.can, self.tx, self.rx)
8687
}
8788
}
8889

0 commit comments

Comments
 (0)