summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-12-22 14:02:09 +1100
committerDamien George <damien.p.george@gmail.com>2016-12-22 14:55:26 +1100
commitb14abab9cd9e61307cd1101279f23fc77de09185 (patch)
tree0752bb4a8ffc80d077f78fa27675163e4c6feeb7
parentffe807f349294b67de15f63e113972251cd3901c (diff)
downloadmicropython-b14abab9cd9e61307cd1101279f23fc77de09185.tar.gz
micropython-b14abab9cd9e61307cd1101279f23fc77de09185.zip
stmhal/led: Properly initialise timer handle to zero before using it.
Without this the timer will have random values for its State and Lock entries. The object can then be in a locked state leading to some HAL functions returning immediately with an error code (which is unchecked). This patch fixes such a bug which did manifest itself as PWM not working correctly for LEDs.
-rw-r--r--stmhal/led.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/stmhal/led.c b/stmhal/led.c
index 310efdcda9..11784af533 100644
--- a/stmhal/led.c
+++ b/stmhal/led.c
@@ -148,7 +148,7 @@ STATIC void led_pwm_init(int led) {
case 3: __TIM3_CLK_ENABLE(); break;
default: assert(0);
}
- TIM_HandleTypeDef tim;
+ TIM_HandleTypeDef tim = {0};
tim.Instance = pwm_cfg->tim;
tim.Init.Period = LED_PWM_TIM_PERIOD - 1;
tim.Init.Prescaler = timer_get_source_freq(pwm_cfg->tim_id) / 1000000 - 1; // TIM runs at 1MHz