Skip to content

Commit

Permalink
Merge pull request #3317 from GrantM11235/simplepwmchannel
Browse files Browse the repository at this point in the history
embassy-stm32: Add SimplePwmChannel
  • Loading branch information
lulf authored Oct 23, 2024
2 parents 8eb80c6 + f2646b2 commit 8803128
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 90 deletions.
7 changes: 7 additions & 0 deletions embassy-stm32/src/timer/low_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//!
//! The available functionality depends on the timer type.

use core::mem::ManuallyDrop;

use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef};
// Re-export useful enums
pub use stm32_metapac::timer::vals::{FilterValue, Sms as SlaveMode, Ts as TriggerSource};
Expand Down Expand Up @@ -198,6 +200,11 @@ impl<'d, T: CoreInstance> Timer<'d, T> {
Self { tim }
}

pub(crate) unsafe fn clone_unchecked(&self) -> ManuallyDrop<Self> {
let tim = unsafe { self.tim.clone_unchecked() };
ManuallyDrop::new(Self { tim })
}

/// Get access to the virutal core 16bit timer registers.
///
/// Note: This works even if the timer is more capable, because registers
Expand Down
3 changes: 2 additions & 1 deletion embassy-stm32/src/timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use core::marker::PhantomData;

use embassy_hal_internal::Peripheral;
use embassy_sync::waitqueue::AtomicWaker;

#[cfg(not(stm32l0))]
Expand Down Expand Up @@ -66,7 +67,7 @@ impl State {
}
}

trait SealedInstance: RccPeripheral {
trait SealedInstance: RccPeripheral + Peripheral<P = Self> {
/// Async state for this timer
fn state() -> &'static State;
}
Expand Down
Loading

0 comments on commit 8803128

Please sign in to comment.