Merge pull request #3733 from tdittr/stm32-can-rx-filters

feat: STM32 Allow to modify the receiver filters from `BufferedCan`, `CanRx`, and `BufferedCanRx`
This commit is contained in:
Dario Nieuwenhuis 2025-01-07 11:29:55 +00:00 committed by GitHub
commit 4790f8ff35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<const BUF_SIZE: usize> = Channel<CriticalSectionRawMutex, Result<
pub struct BufferedCanRx<'d, const RX_BUF_SIZE: usize> {
info: &'static Info,
state: &'static State,
_rx: CanRx<'d>,
rx: CanRx<'d>,
rx_buf: &'static RxBuf<RX_BUF_SIZE>,
}
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<RX_BUF_SIZE>) -> Self {
fn new(info: &'static Info, state: &'static State, rx: CanRx<'d>, rx_buf: &'static RxBuf<RX_BUF_SIZE>) -> 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> {