58 lines
509 B
C
58 lines
509 B
C
#include "drv_fan.h"
|
|
#include "tim.h"
|
|
|
|
osMutexId mutex_fan;
|
|
//·çÉÈ¿ØÖÆ
|
|
void fan_init(void)
|
|
{
|
|
TIM20->CCR1 = 0;
|
|
HAL_TIM_PWM_Start(&htim20,TIM_CHANNEL_1);//FAN
|
|
|
|
osMutexDef(fan);
|
|
mutex_fan = osMutexCreate(osMutex(fan));
|
|
}
|
|
|
|
void fan_set(uint16_t pwm)
|
|
{
|
|
if(mutex_fan && !osMutexWait(mutex_fan, portMAX_DELAY))
|
|
{
|
|
if(pwm <= 1000)
|
|
{
|
|
TIM20->CCR1 = pwm;
|
|
}
|
|
else
|
|
{
|
|
TIM20->CCR1 = 0;
|
|
}
|
|
|
|
osMutexRelease(mutex_fan);
|
|
}
|
|
}
|
|
|
|
uint16_t fan_state(void)
|
|
{
|
|
return TIM20->CCR1;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|