Scott Lahteine 3 роки тому
джерело
коміт
7ffada64ce
1 змінених файлів з 2 додано та 2 видалено
  1. 2
    2
      Marlin/src/HAL/STM32/fast_pwm.cpp

+ 2
- 2
Marlin/src/HAL/STM32/fast_pwm.cpp Переглянути файл

71
 void set_pwm_frequency(const pin_t pin, int f_desired) {
71
 void set_pwm_frequency(const pin_t pin, int f_desired) {
72
   if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
72
   if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
73
 
73
 
74
+  const PinName pin_name = digitalPinToPinName(pin);
75
+  TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance
74
   uint32_t index = get_timer_index(Instance);
76
   uint32_t index = get_timer_index(Instance);
75
 
77
 
76
   // Protect used timers
78
   // Protect used timers
80
     #endif
82
     #endif
81
   ) return;
83
   ) return;
82
 
84
 
83
-  const PinName pin_name = digitalPinToPinName(pin);
84
-  TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance
85
   if (HardwareTimer_Handle[index] == nullptr) // If frequency is set before duty we need to create a handle here.
85
   if (HardwareTimer_Handle[index] == nullptr) // If frequency is set before duty we need to create a handle here.
86
     HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM));
86
     HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM));
87
   HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);
87
   HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);

Завантаження…
Відмінити
Зберегти