diff --git a/firmware/mcal/stm32f767/periph/pwm.h b/firmware/mcal/stm32f767/periph/pwm.h index 3ffbcd54f..f9bd4d66d 100644 --- a/firmware/mcal/stm32f767/periph/pwm.h +++ b/firmware/mcal/stm32f767/periph/pwm.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include "shared/periph/pwm.h" @@ -47,14 +48,16 @@ class PWMOutput : public shared::periph::PWMOutput { } void SetFrequency(float frequency) override { - frequency_ = std::max(kMinimumFrequency, frequency); - uint32_t autoreload = GetTimerFrequency() / frequency_; + float frequency_ = std::max(kMinimumFrequency, frequency); + uint32_t autoreload = static_cast( + static_cast(GetTimerFrequency()) / frequency_); - __HAL_TIM_SetAutoreload(htim, autoreload); + __HAL_TIM_SetAutoreload(htim_, autoreload); } float GetFrequency() override { - float frequency = GetTimerFrequency() / __HAL_TIM_GetAutoreload(htim_); + float frequency = static_cast(GetTimerFrequency()) / + static_cast(__HAL_TIM_GetAutoreload(htim_)); return frequency; } @@ -62,12 +65,12 @@ class PWMOutput : public shared::periph::PWMOutput { private: TIM_HandleTypeDef* htim_; // stm32f767 has a 16-bit autoreload register -> min frequency = 1/65535 - static constexpr kMinimumFrequency = 0.000015259022f; + static constexpr float kMinimumFrequency = 0.000015259022f; uint32_t channel_; float duty_cycle_ = 0; uint32_t GetTimerFrequency() { - uint32_t tickFreq = __HAL_TIM_GetTickFreq(); + uint32_t tickFreq = HAL_GetTickFreq(); return tickFreq; }