Skip to content

Commit a2ef40c

Browse files
committed
Add support for TIM23 and TIM24 found on RM0468 parts
1 parent 2bcf2af commit a2ef40c

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed

src/pwm.rs

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,56 @@ pins! {
915915
]
916916
}
917917

918+
// Quad channel timers (RM0468)
919+
#[cfg(feature = "rm0468")]
920+
pins! {
921+
pac::TIM23:
922+
CH1(ComplementaryImpossible): [
923+
gpio::PG12<Alternate<13>>,
924+
gpio::PF0<Alternate<13>>,
925+
gpio::PF6<Alternate<13>>
926+
]
927+
CH2(ComplementaryImpossible): [
928+
gpio::PG13<Alternate<13>>,
929+
gpio::PF1<Alternate<13>>,
930+
gpio::PF7<Alternate<13>>
931+
]
932+
CH3(ComplementaryImpossible): [
933+
gpio::PG14<Alternate<13>>,
934+
gpio::PF2<Alternate<13>>,
935+
gpio::PF8<Alternate<13>>
936+
]
937+
CH4(ComplementaryImpossible): [
938+
gpio::PF3<Alternate<13>>,
939+
gpio::PF9<Alternate<13>>
940+
]
941+
CH1N: []
942+
CH2N: []
943+
CH3N: []
944+
CH4N: []
945+
BRK: []
946+
BRK2: []
947+
pac::TIM24:
948+
CH1(ComplementaryImpossible): [
949+
gpio::PF11<Alternate<14>>
950+
]
951+
CH2(ComplementaryImpossible): [
952+
gpio::PF12<Alternate<14>>
953+
]
954+
CH3(ComplementaryImpossible): [
955+
gpio::PF13<Alternate<14>>
956+
]
957+
CH4(ComplementaryImpossible): [
958+
gpio::PF14<Alternate<14>>
959+
]
960+
CH1N: []
961+
CH2N: []
962+
CH3N: []
963+
CH4N: []
964+
BRK: []
965+
BRK2: []
966+
}
967+
918968
// Period and prescaler calculator for 32-bit timers
919969
// Returns (arr, psc)
920970
fn calculate_frequency_32bit(
@@ -1369,6 +1419,11 @@ tim_hal! {
13691419
pac::TIM5: (tim5, Tim5, u32, 32, DIR: cms),
13701420
pac::TIM8: (tim8, Tim8, u16, 16, DIR: cms, BDTR: bdtr, enabled, af1, clear_bit, clear_bit),
13711421
}
1422+
#[cfg(feature = "rm0468")]
1423+
tim_hal! {
1424+
pac::TIM23: (tim23, Tim23, u32, 32, DIR: cms),
1425+
pac::TIM24: (tim24, Tim24, u32, 32, DIR: cms),
1426+
}
13721427
tim_hal! {
13731428
pac::TIM12: (tim12, Tim12, u16, 16),
13741429
pac::TIM13: (tim13, Tim13, u16, 16),
@@ -1621,14 +1676,29 @@ tim_pin_hal! {
16211676
(C3, ccmr2_output, oc3pe, oc3m),
16221677
(C4, ccmr2_output, oc4pe, oc4m),
16231678
}
1624-
// Quad channel timers
16251679
tim_pin_hal! {
16261680
pac::TIM8, u16:
16271681
(C1, ccmr1_output, oc1pe, oc1m),
16281682
(C2, ccmr1_output, oc2pe, oc2m),
16291683
(C3, ccmr2_output, oc3pe, oc3m),
16301684
(C4, ccmr2_output, oc4pe, oc4m),
16311685
}
1686+
#[cfg(feature = "rm0468")]
1687+
tim_pin_hal! {
1688+
pac::TIM23, u32:
1689+
(C1, ccmr1_output, oc1pe, oc1m),
1690+
(C2, ccmr1_output, oc2pe, oc2m),
1691+
(C3, ccmr2_output, oc3pe, oc3m),
1692+
(C4, ccmr2_output, oc4pe, oc4m),
1693+
}
1694+
#[cfg(feature = "rm0468")]
1695+
tim_pin_hal! {
1696+
pac::TIM24, u32:
1697+
(C1, ccmr1_output, oc1pe, oc1m),
1698+
(C2, ccmr1_output, oc2pe, oc2m),
1699+
(C3, ccmr2_output, oc3pe, oc3m),
1700+
(C4, ccmr2_output, oc4pe, oc4m),
1701+
}
16321702

16331703
// Low-power timers
16341704
macro_rules! lptim_hal {

src/rcc/rec.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ peripheral_reset_and_enable_control! {
639639
];
640640
#[cfg(feature = "rm0468")]
641641
APB1H, "" => [
642-
Swpmi [kernel clk: Swpmi d2ccip1 "SWPMI"]
642+
Swpmi [kernel clk: Swpmi d2ccip1 "SWPMI"],
643+
644+
Tim23, Tim24
643645
];
644646

645647

src/timer.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use crate::stm32::{
2222
TIM1, TIM12, TIM13, TIM14, TIM15, TIM16, TIM17, TIM2, TIM3, TIM4, TIM5,
2323
TIM6, TIM7, TIM8,
2424
};
25+
#[cfg(feature = "rm0468")]
26+
use crate::stm32::{TIM23, TIM24};
2527

2628
use cast::{u16, u32};
2729
use void::Void;
@@ -58,6 +60,10 @@ impl_tim_ker_ck! {
5860
timx_ker_ck: TIM2, TIM3, TIM4, TIM5, TIM6, TIM7, TIM12, TIM13, TIM14
5961
timy_ker_ck: TIM1, TIM8, TIM15, TIM16, TIM17
6062
}
63+
#[cfg(feature = "rm0468")]
64+
impl_tim_ker_ck! {
65+
timx_ker_ck: TIM23, TIM24
66+
}
6167

6268
/// LPTIM1 Kernel Clock
6369
impl GetClk for LPTIM1 {
@@ -591,6 +597,12 @@ hal! {
591597
TIM16: (tim16, Tim16, u16),
592598
TIM17: (tim17, Tim17, u16),
593599
}
600+
#[cfg(feature = "rm0468")]
601+
hal! {
602+
// General-purpose
603+
TIM23: (tim23, Tim23, u32),
604+
TIM24: (tim24, Tim24, u32),
605+
}
594606

595607
macro_rules! lptim_hal {
596608
($($TIMX:ident: ($timx:ident, $Rec:ident, $timXpac:ident),)+) => {

0 commit comments

Comments
 (0)