Commit b14abab9 authored by Damien George's avatar Damien George
Browse files

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.
parent ffe807f3
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment