Implement simple fan control

This commit is contained in:
jazzpi
2022-06-24 04:38:23 +02:00
parent 405b255936
commit 2c4a428534
4 changed files with 41 additions and 0 deletions

View File

@ -5,8 +5,14 @@
#include "stm32f4xx_hal_def.h"
#include "stm32f4xx_hal_tim.h"
typedef enum { FANS_OFF, FANS_ON } FanState;
extern FanState fan_state;
HAL_StatusTypeDef fan_ctrl_init(TIM_HandleTypeDef* handle, uint32_t channel);
void fan_ctrl_update();
/**
* @brief Set the power of the fan (0 -> off, 100 -> full power).
*/

View File

@ -59,6 +59,10 @@ extern uint8_t slave_id;
#define THRESH_OV 55050 /* 4.2V */
#define THRESH_UT 0 /* 0C */
#define THRESH_OT 880 /* 55C */
#define THRESH_FANS_ON_HALF 640 /* 40C */
#define THRESH_FANS_ON_FULL 800 /* 50C */
#define THRESH_FANS_OFF 560 /* 35C */
/* USER CODE END EM */
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim);