use embassy_hal_internal::Peripheral;
use crate::interrupt;
use crate::rcc::SealedRccEnableReset;
#[derive(Clone, Copy)]
pub enum Channel {
Ch1,
Ch2,
Ch3,
Ch4,
Ch5,
Ch6,
}
impl Channel {
pub fn index(&self) -> usize {
match self {
Channel::Ch1 => 0,
Channel::Ch2 => 1,
Channel::Ch3 => 2,
Channel::Ch4 => 3,
Channel::Ch5 => 4,
Channel::Ch6 => 5,
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TimerBits {
Bits16,
Bits32,
}
trait SealedInstance: SealedRccEnableReset + Peripheral<P = Self> {
}
#[allow(private_bounds)]
pub trait Instance: SealedInstance + 'static {
type Interrupt: interrupt::typelevel::Interrupt;
const BITS: TimerBits;
fn regs() -> *mut ();
}
pub trait AtimInstance: Instance + 'static {}
pub trait GptimInstance: Instance + 'static {}
pub trait BimInstance: Instance + 'static {}
use crate::peripherals;
impl SealedInstance for peripherals::ATIM1 {}
impl Instance for peripherals::ATIM1 {
type Interrupt = interrupt::typelevel::ATIM1;
const BITS: TimerBits = TimerBits::Bits32;
fn regs() -> *mut () {
crate::pac::ATIM1.as_ptr()
}
}
impl AtimInstance for peripherals::ATIM1 {}
impl SealedInstance for peripherals::GPTIM1 {}
impl Instance for peripherals::GPTIM1 {
type Interrupt = interrupt::typelevel::GPTIM1;
const BITS: TimerBits = TimerBits::Bits32;
fn regs() -> *mut () {
crate::pac::GPTIM1.as_ptr()
}
}
impl GptimInstance for peripherals::GPTIM1 {}
impl SealedInstance for peripherals::GPTIM2 {}
impl Instance for peripherals::GPTIM2 {
type Interrupt = interrupt::typelevel::GPTIM2;
const BITS: TimerBits = TimerBits::Bits32;
fn regs() -> *mut () {
crate::pac::GPTIM2.as_ptr()
}
}
impl GptimInstance for peripherals::GPTIM2 {}
impl SealedInstance for peripherals::BTIM1 {}
impl Instance for peripherals::BTIM1 {
type Interrupt = interrupt::typelevel::BTIM1;
const BITS: TimerBits = TimerBits::Bits32;
fn regs() -> *mut () {
crate::pac::BTIM1.as_ptr()
}
}
impl BimInstance for peripherals::BTIM1 {}
impl SealedInstance for peripherals::BTIM2 {}
impl Instance for peripherals::BTIM2 {
type Interrupt = interrupt::typelevel::BTIM2;
const BITS: TimerBits = TimerBits::Bits32;
fn regs() -> *mut () {
crate::pac::BTIM2.as_ptr()
}
}
impl BimInstance for peripherals::BTIM2 {}