japaric / stm32f103xx-hal

HAL for the STM32F103xx family of microcontrollers
Apache License 2.0
116 stars 40 forks source link

Fixed a bug in the timer code that would miscalculate TIM1 ARR and PRESC #111

Closed gbip closed 5 years ago

gbip commented 5 years ago

Fixed a bug in the timer code that would miscalculate TIM1 ARR and PRESC. TIM1 is not on the same bus as TIM2-8 so we have to adjust how we compute its period.

If you know a way to avoid redefining an enum (for example using the APB identifier) please tell me !

TeXitoi commented 5 years ago

I would define 2 functions taking clock and returning bus clock and multiplier, and give the name of the good function to the macro.

TeXitoi commented 5 years ago

@therealprof sadly this repo doesn't use fmt, maybe we can do a PR to use it ?

TeXitoi commented 5 years ago

Moreover, inside macro, fmt will not work.

therealprof commented 5 years ago

@TeXitoi I think formatting is mostly up-to-date but rustfmt rules changed a bit over time. I'd prefer formatting code as we go rather than doing it all in one PR but you're right it doesn't work in macros.

burrbull commented 5 years ago

Please, correct typo in TIM4: tim3rst -> tim4rst

therealprof commented 5 years ago

@burrbull Nice spotting!

gbip commented 5 years ago

Is it better now ? For the formatting I tried to format the code by hand, tell me if it's not correct.