aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-06-03 13:23:21 -0400
committerBob McWhirter <[email protected]>2021-06-03 13:23:21 -0400
commit75dc0fd542b3d9744cc2a0a4b661cb2951a9c2bd (patch)
tree607c9db490acb559b24a25c8ae2378ba79b1fd6e
parentc00a85f9a9e1506c23650b27d8db5a1c5b046aa5 (diff)
Migrate TIM[2-5] to macro tables.
-rw-r--r--embassy-stm32/gen.py6
-rw-r--r--embassy-stm32/src/clock.rs14
2 files changed, 14 insertions, 6 deletions
diff --git a/embassy-stm32/gen.py b/embassy-stm32/gen.py
index 55612cb3f..3cf93a2ca 100644
--- a/embassy-stm32/gen.py
+++ b/embassy-stm32/gen.py
@@ -136,9 +136,9 @@ with open(output_file, 'w') as f:
136 if (func := funcs.get(f'{name}_D7')) != None: 136 if (func := funcs.get(f'{name}_D7')) != None:
137 f.write(f'impl_sdmmc_pin!({name}, D7Pin, {pin}, {func});') 137 f.write(f'impl_sdmmc_pin!({name}, D7Pin, {pin}, {func});')
138 138
139 if block_name == 'TimGp16': 139 # if block_name == 'TimGp16':
140 if re.match('TIM[2345]$', name): 140 # if re.match('TIM[2345]$', name):
141 f.write(f'impl_timer!({name});') 141 # f.write(f'impl_timer!({name});')
142 142
143 if block_mod == 'exti': 143 if block_mod == 'exti':
144 for irq in chip['interrupts']: 144 for irq in chip['interrupts']:
diff --git a/embassy-stm32/src/clock.rs b/embassy-stm32/src/clock.rs
index aa83c5b45..694ca666d 100644
--- a/embassy-stm32/src/clock.rs
+++ b/embassy-stm32/src/clock.rs
@@ -10,6 +10,7 @@ use embassy::time::{Clock as EmbassyClock, TICKS_PER_SECOND};
10 10
11use crate::interrupt::{CriticalSection, Interrupt, Mutex}; 11use crate::interrupt::{CriticalSection, Interrupt, Mutex};
12use crate::pac::timer::TimGp16; 12use crate::pac::timer::TimGp16;
13use crate::peripherals;
13use crate::time::Hertz; 14use crate::time::Hertz;
14 15
15// Clock timekeeping works with something we call "periods", which are time intervals 16// Clock timekeeping works with something we call "periods", which are time intervals
@@ -362,15 +363,22 @@ pub trait Instance: sealed::Instance + Sized + 'static {}
362 363
363macro_rules! impl_timer { 364macro_rules! impl_timer {
364 ($inst:ident) => { 365 ($inst:ident) => {
365 impl crate::clock::sealed::Instance for peripherals::$inst { 366 impl sealed::Instance for peripherals::$inst {
366 type Interrupt = crate::interrupt::$inst; 367 type Interrupt = crate::interrupt::$inst;
367 368
368 fn inner() -> crate::clock::TimerInner { 369 fn inner() -> crate::clock::TimerInner {
369 const INNER: crate::clock::TimerInner = crate::clock::TimerInner(crate::pac::$inst); 370 const INNER: TimerInner = TimerInner(crate::pac::$inst);
370 INNER 371 INNER
371 } 372 }
372 } 373 }
373 374
374 impl crate::clock::Instance for peripherals::$inst {} 375 impl Instance for peripherals::$inst {}
375 }; 376 };
376} 377}
378
379crate::pac::peripherals!(
380 (timer, TIM2) => { impl_timer!(TIM2); };
381 (timer, TIM3) => { impl_timer!(TIM3); };
382 (timer, TIM4) => { impl_timer!(TIM4); };
383 (timer, TIM5) => { impl_timer!(TIM5); };
384);