diff options
| author | Ulf Lilleengen <[email protected]> | 2025-08-12 19:27:28 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-12 19:27:28 +0200 |
| commit | e2921be35cb2d02b7cc25605c4a1cfed090a13cb (patch) | |
| tree | d907d4bcb6d2e8918179b6fabefc66d3405df33c /embassy-stm32/src/timer/low_level.rs | |
| parent | 1f57e2130a123a2e36cea25a3fc8c5b660313f47 (diff) | |
| parent | c228ffe666c4354c909ea454cebc14387930c9c0 (diff) | |
Merge pull request #4522 from WattStep/complementary_pwm_idle_state
Add methods for idle-state control in STM32 Complementary PWM
Diffstat (limited to 'embassy-stm32/src/timer/low_level.rs')
| -rw-r--r-- | embassy-stm32/src/timer/low_level.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/embassy-stm32/src/timer/low_level.rs b/embassy-stm32/src/timer/low_level.rs index dc8ceb725..ac039bb0d 100644 --- a/embassy-stm32/src/timer/low_level.rs +++ b/embassy-stm32/src/timer/low_level.rs | |||
| @@ -686,10 +686,35 @@ impl<'d, T: AdvancedInstance1Channel> Timer<'d, T> { | |||
| 686 | self.regs_1ch_cmp().bdtr().modify(|w| w.set_dtg(value)); | 686 | self.regs_1ch_cmp().bdtr().modify(|w| w.set_dtg(value)); |
| 687 | } | 687 | } |
| 688 | 688 | ||
| 689 | /// Set state of OSSI-bit in BDTR register | ||
| 690 | pub fn set_ossi(&self, val: vals::Ossi) { | ||
| 691 | self.regs_1ch_cmp().bdtr().modify(|w| w.set_ossi(val)); | ||
| 692 | } | ||
| 693 | |||
| 694 | /// Get state of OSSI-bit in BDTR register | ||
| 695 | pub fn get_ossi(&self) -> vals::Ossi { | ||
| 696 | self.regs_1ch_cmp().bdtr().read().ossi() | ||
| 697 | } | ||
| 698 | |||
| 699 | /// Set state of OSSR-bit in BDTR register | ||
| 700 | pub fn set_ossr(&self, val: vals::Ossr) { | ||
| 701 | self.regs_1ch_cmp().bdtr().modify(|w| w.set_ossr(val)); | ||
| 702 | } | ||
| 703 | |||
| 704 | /// Get state of OSSR-bit in BDTR register | ||
| 705 | pub fn get_ossr(&self) -> vals::Ossr { | ||
| 706 | self.regs_1ch_cmp().bdtr().read().ossr() | ||
| 707 | } | ||
| 708 | |||
| 689 | /// Set state of MOE-bit in BDTR register to en-/disable output | 709 | /// Set state of MOE-bit in BDTR register to en-/disable output |
| 690 | pub fn set_moe(&self, enable: bool) { | 710 | pub fn set_moe(&self, enable: bool) { |
| 691 | self.regs_1ch_cmp().bdtr().modify(|w| w.set_moe(enable)); | 711 | self.regs_1ch_cmp().bdtr().modify(|w| w.set_moe(enable)); |
| 692 | } | 712 | } |
| 713 | |||
| 714 | /// Get state of MOE-bit in BDTR register | ||
| 715 | pub fn get_moe(&self) -> bool { | ||
| 716 | self.regs_1ch_cmp().bdtr().read().moe() | ||
| 717 | } | ||
| 693 | } | 718 | } |
| 694 | 719 | ||
| 695 | #[cfg(not(stm32l0))] | 720 | #[cfg(not(stm32l0))] |
| @@ -725,4 +750,19 @@ impl<'d, T: AdvancedInstance4Channel> Timer<'d, T> { | |||
| 725 | .ccer() | 750 | .ccer() |
| 726 | .modify(|w| w.set_ccne(channel.index(), enable)); | 751 | .modify(|w| w.set_ccne(channel.index(), enable)); |
| 727 | } | 752 | } |
| 753 | |||
| 754 | /// Set Output Idle State | ||
| 755 | pub fn set_ois(&self, channel: Channel, val: bool) { | ||
| 756 | self.regs_advanced().cr2().modify(|w| w.set_ois(channel.index(), val)); | ||
| 757 | } | ||
| 758 | /// Set Output Idle State Complementary Channel | ||
| 759 | pub fn set_oisn(&self, channel: Channel, val: bool) { | ||
| 760 | self.regs_advanced().cr2().modify(|w| w.set_oisn(channel.index(), val)); | ||
| 761 | } | ||
| 762 | |||
| 763 | /// Trigger software break 1 or 2 | ||
| 764 | /// Setting this bit generates a break event. This bit is automatically cleared by the hardware. | ||
| 765 | pub fn trigger_software_break(&self, n: usize) { | ||
| 766 | self.regs_advanced().egr().write(|r| r.set_bg(n, true)); | ||
| 767 | } | ||
| 728 | } | 768 | } |
