diff --git a/embassy-stm32/src/can/bxcan/mod.rs b/embassy-stm32/src/can/bxcan/mod.rs index 19f1cea29f..8165364f59 100644 --- a/embassy-stm32/src/can/bxcan/mod.rs +++ b/embassy-stm32/src/can/bxcan/mod.rs @@ -502,6 +502,14 @@ impl<'d, const TX_BUF_SIZE: usize, const RX_BUF_SIZE: usize> BufferedCan<'d, TX_ pub fn reader(&self) -> BufferedCanReceiver { self.rx.reader() } + + /// Accesses the filter banks owned by this CAN peripheral. + /// + /// To modify filters of a slave peripheral, `modify_filters` has to be called on the master + /// peripheral instead. + pub fn modify_filters(&mut self) -> MasterFilters<'_> { + self.rx.modify_filters() + } } /// CAN driver, transmit half. @@ -733,6 +741,14 @@ impl<'d> CanRx<'d> { ) -> BufferedCanRx<'d, RX_BUF_SIZE> { BufferedCanRx::new(self.info, self.state, self, rxb) } + + /// Accesses the filter banks owned by this CAN peripheral. + /// + /// To modify filters of a slave peripheral, `modify_filters` has to be called on the master + /// peripheral instead. + pub fn modify_filters(&mut self) -> MasterFilters<'_> { + unsafe { MasterFilters::new(self.info) } + } } /// User supplied buffer for RX Buffering @@ -742,16 +758,16 @@ pub type RxBuf = Channel { info: &'static Info, state: &'static State, - _rx: CanRx<'d>, + rx: CanRx<'d>, rx_buf: &'static RxBuf, } impl<'d, const RX_BUF_SIZE: usize> BufferedCanRx<'d, RX_BUF_SIZE> { - fn new(info: &'static Info, state: &'static State, _rx: CanRx<'d>, rx_buf: &'static RxBuf) -> Self { + fn new(info: &'static Info, state: &'static State, rx: CanRx<'d>, rx_buf: &'static RxBuf) -> Self { BufferedCanRx { info, state, - _rx, + rx, rx_buf, } .setup() @@ -811,6 +827,14 @@ impl<'d, const RX_BUF_SIZE: usize> BufferedCanRx<'d, RX_BUF_SIZE> { pub fn reader(&self) -> BufferedCanReceiver { self.rx_buf.receiver().into() } + + /// Accesses the filter banks owned by this CAN peripheral. + /// + /// To modify filters of a slave peripheral, `modify_filters` has to be called on the master + /// peripheral instead. + pub fn modify_filters(&mut self) -> MasterFilters<'_> { + self.rx.modify_filters() + } } impl<'d, const RX_BUF_SIZE: usize> Drop for BufferedCanRx<'d, RX_BUF_SIZE> {