Selaa lähdekoodia

Merge pull request #2953 from wuhanstudio/pwm-clock-enable

[stm32][driver] pwm enable clock
Bernard Xiong 5 vuotta sitten
vanhempi
commit
ccf80cc2f3
1 muutettua tiedostoa jossa 8 lisäystä ja 7 poistoa
  1. 8 7
      bsp/stm32/libraries/HAL_Drivers/drv_pwm.c

+ 8 - 7
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c

@@ -322,24 +322,25 @@ static rt_err_t stm32_hw_pwm_init(struct stm32_pwm *device)
 #if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
 #if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
 #endif
 #endif
-    if (HAL_TIM_Base_Init(tim) != HAL_OK)
+
+    if (HAL_TIM_PWM_Init(tim) != HAL_OK)
     {
     {
-        LOG_E("%s time base init failed", device->name);
+        LOG_E("%s pwm init failed", device->name);
         result = -RT_ERROR;
         result = -RT_ERROR;
         goto __exit;
         goto __exit;
     }
     }
 
 
-    clock_config.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
-    if (HAL_TIM_ConfigClockSource(tim, &clock_config) != HAL_OK)
+    if (HAL_TIM_Base_Init(tim) != HAL_OK)
     {
     {
-        LOG_E("%s clock init failed", device->name);
+        LOG_E("%s time base init failed", device->name);
         result = -RT_ERROR;
         result = -RT_ERROR;
         goto __exit;
         goto __exit;
     }
     }
 
 
-    if (HAL_TIM_PWM_Init(tim) != HAL_OK)
+    clock_config.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
+    if (HAL_TIM_ConfigClockSource(tim, &clock_config) != HAL_OK)
     {
     {
-        LOG_E("%s pwm init failed", device->name);
+        LOG_E("%s clock init failed", device->name);
         result = -RT_ERROR;
         result = -RT_ERROR;
         goto __exit;
         goto __exit;
     }
     }