@@ -14,11 +14,11 @@ use stm32_metapac::timer::{TimGp16, regs};
1414
1515use crate :: interrupt:: typelevel:: Interrupt ;
1616use crate :: pac:: timer:: vals;
17+ use crate :: peripherals;
1718use crate :: rcc:: { self , SealedRccPeripheral } ;
1819#[ cfg( feature = "low-power" ) ]
1920use crate :: rtc:: Rtc ;
2021use crate :: timer:: { CoreInstance , GeneralInstance1Channel } ;
21- use crate :: { interrupt, peripherals} ;
2222
2323// NOTE regarding ALARM_COUNT:
2424//
@@ -56,121 +56,6 @@ type T = peripherals::TIM23;
5656#[ cfg( time_driver_tim24) ]
5757type T = peripherals:: TIM24 ;
5858
59- foreach_interrupt ! {
60- ( TIM1 , timer, $block: ident, CC , $irq: ident) => {
61- #[ cfg( time_driver_tim1) ]
62- #[ cfg( feature = "rt" ) ]
63- #[ interrupt]
64- fn $irq( ) {
65- DRIVER . on_interrupt( )
66- }
67- } ;
68- ( TIM2 , timer, $block: ident, CC , $irq: ident) => {
69- #[ cfg( time_driver_tim2) ]
70- #[ cfg( feature = "rt" ) ]
71- #[ interrupt]
72- fn $irq( ) {
73- DRIVER . on_interrupt( )
74- }
75- } ;
76- ( TIM3 , timer, $block: ident, CC , $irq: ident) => {
77- #[ cfg( time_driver_tim3) ]
78- #[ cfg( feature = "rt" ) ]
79- #[ interrupt]
80- fn $irq( ) {
81- DRIVER . on_interrupt( )
82- }
83- } ;
84- ( TIM4 , timer, $block: ident, CC , $irq: ident) => {
85- #[ cfg( time_driver_tim4) ]
86- #[ cfg( feature = "rt" ) ]
87- #[ interrupt]
88- fn $irq( ) {
89- DRIVER . on_interrupt( )
90- }
91- } ;
92- ( TIM5 , timer, $block: ident, CC , $irq: ident) => {
93- #[ cfg( time_driver_tim5) ]
94- #[ cfg( feature = "rt" ) ]
95- #[ interrupt]
96- fn $irq( ) {
97- DRIVER . on_interrupt( )
98- }
99- } ;
100- ( TIM8 , timer, $block: ident, CC , $irq: ident) => {
101- #[ cfg( time_driver_tim8) ]
102- #[ cfg( feature = "rt" ) ]
103- #[ interrupt]
104- fn $irq( ) {
105- DRIVER . on_interrupt( )
106- }
107- } ;
108- ( TIM9 , timer, $block: ident, CC , $irq: ident) => {
109- #[ cfg( time_driver_tim9) ]
110- #[ cfg( feature = "rt" ) ]
111- #[ interrupt]
112- fn $irq( ) {
113- DRIVER . on_interrupt( )
114- }
115- } ;
116- ( TIM12 , timer, $block: ident, CC , $irq: ident) => {
117- #[ cfg( time_driver_tim12) ]
118- #[ cfg( feature = "rt" ) ]
119- #[ interrupt]
120- fn $irq( ) {
121- DRIVER . on_interrupt( )
122- }
123- } ;
124- ( TIM15 , timer, $block: ident, CC , $irq: ident) => {
125- #[ cfg( time_driver_tim15) ]
126- #[ cfg( feature = "rt" ) ]
127- #[ interrupt]
128- fn $irq( ) {
129- DRIVER . on_interrupt( )
130- }
131- } ;
132- ( TIM20 , timer, $block: ident, CC , $irq: ident) => {
133- #[ cfg( time_driver_tim20) ]
134- #[ cfg( feature = "rt" ) ]
135- #[ interrupt]
136- fn $irq( ) {
137- DRIVER . on_interrupt( )
138- }
139- } ;
140- ( TIM21 , timer, $block: ident, CC , $irq: ident) => {
141- #[ cfg( time_driver_tim21) ]
142- #[ cfg( feature = "rt" ) ]
143- #[ interrupt]
144- fn $irq( ) {
145- DRIVER . on_interrupt( )
146- }
147- } ;
148- ( TIM22 , timer, $block: ident, CC , $irq: ident) => {
149- #[ cfg( time_driver_tim22) ]
150- #[ cfg( feature = "rt" ) ]
151- #[ interrupt]
152- fn $irq( ) {
153- DRIVER . on_interrupt( )
154- }
155- } ;
156- ( TIM23 , timer, $block: ident, CC , $irq: ident) => {
157- #[ cfg( time_driver_tim23) ]
158- #[ cfg( feature = "rt" ) ]
159- #[ interrupt]
160- fn $irq( ) {
161- DRIVER . on_interrupt( )
162- }
163- } ;
164- ( TIM24 , timer, $block: ident, CC , $irq: ident) => {
165- #[ cfg( time_driver_tim24) ]
166- #[ cfg( feature = "rt" ) ]
167- #[ interrupt]
168- fn $irq( ) {
169- DRIVER . on_interrupt( )
170- }
171- } ;
172- }
173-
17459fn regs_gp16 ( ) -> TimGp16 {
17560 unsafe { TimGp16 :: from_ptr ( T :: regs ( ) ) }
17661}
@@ -282,15 +167,19 @@ impl RtcDriver {
282167 r. cnt ( ) . write ( |w| w. set_cnt ( self . saved_count . load ( Ordering :: SeqCst ) ) ) ;
283168
284169 <T as GeneralInstance1Channel >:: CaptureCompareInterrupt :: unpend ( ) ;
285- unsafe { <T as GeneralInstance1Channel >:: CaptureCompareInterrupt :: enable ( ) } ;
170+ <T as CoreInstance >:: UpdateInterrupt :: unpend ( ) ;
171+ unsafe {
172+ <T as GeneralInstance1Channel >:: CaptureCompareInterrupt :: enable ( ) ;
173+ <T as CoreInstance >:: UpdateInterrupt :: enable ( ) ;
174+ }
286175 }
287176
288177 fn init ( & ' static self , cs : CriticalSection ) {
289178 self . init_timer ( cs) ;
290179 regs_gp16 ( ) . cr1 ( ) . modify ( |w| w. set_cen ( true ) ) ;
291180 }
292181
293- fn on_interrupt ( & self ) {
182+ pub ( crate ) fn on_interrupt ( & self ) {
294183 let r = regs_gp16 ( ) ;
295184
296185 critical_section:: with ( |cs| {
@@ -508,7 +397,6 @@ impl Driver for RtcDriver {
508397 }
509398}
510399
511- #[ cfg( feature = "low-power" ) ]
512400pub ( crate ) const fn get_driver ( ) -> & ' static RtcDriver {
513401 & DRIVER
514402}
0 commit comments