diff options
| author | Bob McWhirter <[email protected]> | 2021-06-03 13:23:21 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-06-03 13:23:21 -0400 |
| commit | 75dc0fd542b3d9744cc2a0a4b661cb2951a9c2bd (patch) | |
| tree | 607c9db490acb559b24a25c8ae2378ba79b1fd6e | |
| parent | c00a85f9a9e1506c23650b27d8db5a1c5b046aa5 (diff) | |
Migrate TIM[2-5] to macro tables.
| -rw-r--r-- | embassy-stm32/gen.py | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/clock.rs | 14 |
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 | ||
| 11 | use crate::interrupt::{CriticalSection, Interrupt, Mutex}; | 11 | use crate::interrupt::{CriticalSection, Interrupt, Mutex}; |
| 12 | use crate::pac::timer::TimGp16; | 12 | use crate::pac::timer::TimGp16; |
| 13 | use crate::peripherals; | ||
| 13 | use crate::time::Hertz; | 14 | use 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 | ||
| 363 | macro_rules! impl_timer { | 364 | macro_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 | |||
| 379 | crate::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 | ); | ||
