Skip to content

Commit

Permalink
Implement free() method for CAN
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh3Rm4n committed Jul 2, 2021
1 parent 8ad482d commit 3d3a38e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ cfg_if! {
///
/// See [`bxcan::Instance`] for more information on how to use the CAN interface.
pub struct Can<Tx, Rx> {
_can: pac::CAN,
_tx: TX,
_rx: RX,
can: pac::CAN,
tx: Tx,
rx: Rx,
}

impl<Tx, Rx> Can<Tx, Rx>
Expand All @@ -78,11 +78,12 @@ where
apb1.rstr().modify(|_, w| w.canrst().set_bit());
apb1.rstr().modify(|_, w| w.canrst().clear_bit());

bxcan::Can::new(Can {
_can: can,
_tx: tx,
_rx: rx,
})
bxcan::Can::new(Can { can, tx, rx })
}

/// Releases the CAN peripheral and associated pins
pub fn free(self) -> (pac::CAN, Tx, Rx) {
(self.can, self.tx, self.rx)
}
}

Expand Down

0 comments on commit 3d3a38e

Please sign in to comment.