From 6111ab0e632b4e9f9a018ea11b9f3dfcc5e44459 Mon Sep 17 00:00:00 2001 From: Richard Meadows <962920+richardeoin@users.noreply.github.com> Date: Thu, 19 Jan 2023 22:44:48 +0100 Subject: [PATCH 1/2] Improve documentation links from FdCan to FdCanConfig --- src/lib.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2690229..b187d30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -684,8 +684,7 @@ where self.into_can_mode() } - /// Applies the settings of a new FdCanConfig - /// See [`FdCanConfig`] for more information + /// Applies the settings of a new FdCanConfig See [`FdCanConfig`] #[inline] pub fn apply_config(&mut self, config: FdCanConfig) { self.set_data_bit_timing(config.dbtr); @@ -761,8 +760,8 @@ where self.control.config.automatic_retransmit = enabled; } - /// Configures the transmit pause feature - /// See [`FdCanConfig`] for more information + /// Configures the transmit pause feature. See + /// [`FdCanConfig::set_transmit_pause`] #[inline] pub fn set_transmit_pause(&mut self, enabled: bool) { let can = self.registers(); @@ -770,8 +769,7 @@ where self.control.config.transmit_pause = enabled; } - /// Configures non-iso mode - /// See [`FdCanConfig`] for more information + /// Configures non-iso mode. See [`FdCanConfig::set_non_iso_mode`] #[inline] pub fn set_non_iso_mode(&mut self, enabled: bool) { let can = self.registers(); @@ -779,8 +777,7 @@ where self.control.config.non_iso_mode = enabled; } - /// Configures edge filtering - /// See [`FdCanConfig`] for more information + /// Configures edge filtering. See [`FdCanConfig::set_edge_filtering`] #[inline] pub fn set_edge_filtering(&mut self, enabled: bool) { let can = self.registers(); @@ -788,8 +785,8 @@ where self.control.config.edge_filtering = enabled; } - /// Configures frame transmission mode - /// See [`FdCanConfig`] for more information + /// Configures frame transmission mode. See + /// [`FdCanConfig::set_frame_transmit`] #[inline] pub fn set_frame_transmit(&mut self, fts: FrameTransmissionConfig) { let (fdoe, brse) = match fts { @@ -804,8 +801,8 @@ where self.control.config.frame_transmit = fts; } - /// Configures the interrupt lines - /// See [`FdCanConfig`] for more information + /// Configures the interrupt lines. See + /// [`FdCanConfig::set_interrupt_line_config`] #[inline] pub fn set_interrupt_line_config(&mut self, l0int: Interrupts) { let can = self.registers(); @@ -1225,7 +1222,7 @@ where /// /// If all transmit mailboxes are full, a higher priority frame can replace a lower-priority /// frame, which is returned via the closure 'pending'. If 'pending' is called; it's return value - /// is returned via Option

, if it is not, None is returned. + /// is returned via `Option

`, if it is not, None is returned. /// If there are only higher priority frames in the queue, this returns Err::WouldBlock pub fn transmit( &mut self, From 14f400a36c2d2267edf4a8309b8d7ac099171f9b Mon Sep 17 00:00:00 2001 From: Richard Meadows <962920+richardeoin@users.noreply.github.com> Date: Thu, 19 Jan 2023 22:49:14 +0100 Subject: [PATCH 2/2] Rename method `set_interrupt_line_config` to `select_interrupt_line_1` Closes #26 --- CHANGELOG.md | 3 +++ src/config.rs | 12 ++++++++++++ src/lib.rs | 15 +++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 102bc71..b51fd88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* Rename method `set_interrupt_line_config` to `select_interrupt_line_1` [#27] + ## [v0.1.2] 2022-09-13 * Fix DLC field (frame length) for FDCAN frames [#21] @@ -22,3 +24,4 @@ Callbacks replaced with parameter buffer #10 [#18]: https://github.com/stm32-rs/stm32h7xx-hal/pull/18 [#21]: https://github.com/stm32-rs/stm32h7xx-hal/pull/21 +[#27]: https://github.com/stm32-rs/stm32h7xx-hal/pull/27 diff --git a/src/config.rs b/src/config.rs index ac19d2a..2a5136b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -407,11 +407,23 @@ impl FdCanConfig { /// Configures which interrupt go to which interrupt lines #[inline] + #[deprecated( + since = "0.1.3", + note = "Deprecated in favour of .select_interrupt_line_1(..)" + )] pub const fn set_interrupt_line_config(mut self, l0int: Interrupts) -> Self { self.interrupt_line_config = l0int; self } + /// Selects Interrupt Line 1 for the given interrupts. Interrupt Line 0 is + /// selected for all other interrupts + #[inline] + pub const fn select_interrupt_line_1(mut self, l1int: Interrupts) -> Self { + self.interrupt_line_config = l1int; + self + } + /// Sets the general clock divider for this FdCAN instance #[inline] pub const fn set_clock_divider(mut self, div: ClockDivider) -> Self { diff --git a/src/lib.rs b/src/lib.rs index b187d30..3875d66 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -804,6 +804,10 @@ where /// Configures the interrupt lines. See /// [`FdCanConfig::set_interrupt_line_config`] #[inline] + #[deprecated( + since = "0.1.3", + note = "Deprecated in favour of .select_interrupt_line_1(..)" + )] pub fn set_interrupt_line_config(&mut self, l0int: Interrupts) { let can = self.registers(); @@ -812,6 +816,17 @@ where self.control.config.interrupt_line_config = l0int; } + /// Selects Interrupt Line 1 for the given interrupts. Interrupt Line 0 is + /// selected for all other interrupts. See + /// [`FdCanConfig::select_interrupt_line_1`] + pub fn select_interrupt_line_1(&mut self, l1int: Interrupts) { + let can = self.registers(); + + can.ils.modify(|_, w| unsafe { w.bits(l1int.bits()) }); + + self.control.config.interrupt_line_config = l1int; + } + /// Sets the protocol exception handling on/off #[inline] pub fn set_protocol_exception_handling(&mut self, enabled: bool) {