aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/timer
diff options
context:
space:
mode:
authorxoviat <[email protected]>2023-09-28 20:37:48 +0000
committerGitHub <[email protected]>2023-09-28 20:37:48 +0000
commitee5591017b032ab0848a24423d303be201b7fc54 (patch)
treecef830acf9b49053226cb2f6e9df9a0e6986bfb6 /embassy-stm32/src/timer
parentb1b32f079bd98f15fd0151d52cddc0380594f125 (diff)
parent23f3889167903c6e800f056517c2c831e73ed081 (diff)
Merge pull request #1964 from dberlin/main
Add support for STM32 input capture filter
Diffstat (limited to 'embassy-stm32/src/timer')
-rw-r--r--embassy-stm32/src/timer/mod.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs
index ea72b36ae..1d642ed37 100644
--- a/embassy-stm32/src/timer/mod.rs
+++ b/embassy-stm32/src/timer/mod.rs
@@ -56,6 +56,8 @@ pub(crate) mod sealed {
56 } 56 }
57 57
58 pub trait CaptureCompare16bitInstance: GeneralPurpose16bitInstance { 58 pub trait CaptureCompare16bitInstance: GeneralPurpose16bitInstance {
59 fn set_input_capture_filter(&mut self, channel: Channel, icf: vals::Icf);
60
59 fn clear_input_interrupt(&mut self, channel: Channel); 61 fn clear_input_interrupt(&mut self, channel: Channel);
60 62
61 fn enable_input_interrupt(&mut self, channel: Channel, enable: bool); 63 fn enable_input_interrupt(&mut self, channel: Channel, enable: bool);
@@ -93,6 +95,8 @@ pub(crate) mod sealed {
93 } 95 }
94 96
95 pub trait CaptureCompare32bitInstance: GeneralPurpose32bitInstance { 97 pub trait CaptureCompare32bitInstance: GeneralPurpose32bitInstance {
98 fn set_input_capture_filter(&mut self, channel: Channel, icf: vals::Icf);
99
96 fn clear_input_interrupt(&mut self, channel: Channel); 100 fn clear_input_interrupt(&mut self, channel: Channel);
97 101
98 fn enable_input_interrupt(&mut self, channel: Channel, enable: bool); 102 fn enable_input_interrupt(&mut self, channel: Channel, enable: bool);
@@ -338,6 +342,14 @@ macro_rules! impl_32bit_timer {
338macro_rules! impl_compare_capable_16bit { 342macro_rules! impl_compare_capable_16bit {
339 ($inst:ident) => { 343 ($inst:ident) => {
340 impl sealed::CaptureCompare16bitInstance for crate::peripherals::$inst { 344 impl sealed::CaptureCompare16bitInstance for crate::peripherals::$inst {
345 fn set_input_capture_filter(&mut self, channel: Channel, icf: vals::Icf) {
346 use sealed::GeneralPurpose16bitInstance;
347 let raw_channel = channel.raw();
348 Self::regs_gp16()
349 .ccmr_input(raw_channel / 2)
350 .modify(|r| r.set_icf(raw_channel % 2, icf));
351 }
352
341 fn clear_input_interrupt(&mut self, channel: Channel) { 353 fn clear_input_interrupt(&mut self, channel: Channel) {
342 use sealed::GeneralPurpose16bitInstance; 354 use sealed::GeneralPurpose16bitInstance;
343 Self::regs_gp16() 355 Self::regs_gp16()
@@ -463,6 +475,14 @@ foreach_interrupt! {
463 impl GeneralPurpose32bitInstance for crate::peripherals::$inst {} 475 impl GeneralPurpose32bitInstance for crate::peripherals::$inst {}
464 476
465 impl sealed::CaptureCompare32bitInstance for crate::peripherals::$inst { 477 impl sealed::CaptureCompare32bitInstance for crate::peripherals::$inst {
478 fn set_input_capture_filter(&mut self, channel: Channel, icf: vals::Icf) {
479 use sealed::GeneralPurpose32bitInstance;
480 let raw_channel = channel.raw();
481 Self::regs_gp32()
482 .ccmr_input(raw_channel / 2)
483 .modify(|r| r.set_icf(raw_channel % 2, icf));
484 }
485
466 fn clear_input_interrupt(&mut self, channel: Channel) { 486 fn clear_input_interrupt(&mut self, channel: Channel) {
467 use sealed::GeneralPurpose32bitInstance; 487 use sealed::GeneralPurpose32bitInstance;
468 Self::regs_gp32() 488 Self::regs_gp32()
@@ -591,6 +611,14 @@ foreach_interrupt! {
591 } 611 }
592 612
593 impl sealed::CaptureCompare16bitInstance for crate::peripherals::$inst { 613 impl sealed::CaptureCompare16bitInstance for crate::peripherals::$inst {
614 fn set_input_capture_filter(&mut self, channel: Channel, icf: vals::Icf) {
615 use crate::timer::sealed::AdvancedControlInstance;
616 let raw_channel = channel.raw();
617 Self::regs_advanced()
618 .ccmr_input(raw_channel / 2)
619 .modify(|r| r.set_icf(raw_channel % 2, icf));
620 }
621
594 fn clear_input_interrupt(&mut self, channel: Channel) { 622 fn clear_input_interrupt(&mut self, channel: Channel) {
595 use crate::timer::sealed::AdvancedControlInstance; 623 use crate::timer::sealed::AdvancedControlInstance;
596 Self::regs_advanced() 624 Self::regs_advanced()