Implement fan PWM

This commit is contained in:
jazzpi
2022-06-14 00:44:46 +02:00
parent bf08863de8
commit 705b9da821
9 changed files with 183 additions and 17 deletions

15
Core/Inc/FanControl.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef INC_FAN_CONTROL_H
#define INC_FAN_CONTROL_H
#include "stm32f4xx_hal.h"
#include "stm32f4xx_hal_def.h"
#include "stm32f4xx_hal_tim.h"
HAL_StatusTypeDef fan_ctrl_init(TIM_HandleTypeDef* handle, uint32_t channel);
/**
* @brief Set the power of the fan (0 -> off, 100 -> full power).
*/
void fan_ctrl_set_power(uint32_t percent);
#endif // INC_FAN_CONTROL_H

View File

@ -48,6 +48,8 @@ extern "C" {
#define MAIN_LOOP_PERIOD 100 /* ms */
/* USER CODE END EM */
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim);
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

View File

@ -63,7 +63,7 @@
/* #define HAL_SD_MODULE_ENABLED */
/* #define HAL_MMC_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */
/* #define HAL_TIM_MODULE_ENABLED */
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */