mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
32 lines
590 B
C
32 lines
590 B
C
#include "buzzer.h"
|
|
#include "main.h"
|
|
|
|
extern TIM_HandleTypeDef htim4;
|
|
static uint8_t tmp_warning_level = 0;
|
|
|
|
void BuzzerInit()
|
|
{
|
|
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3);
|
|
__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_3, 0);
|
|
}
|
|
|
|
void BuzzerOn( )
|
|
{
|
|
static int16_t temp = 4000 ;
|
|
if(temp < 1000)
|
|
{
|
|
BuzzerOff();
|
|
return;
|
|
}
|
|
__HAL_TIM_PRESCALER(&htim4,(int)(temp/1000));
|
|
__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_3, 10000);
|
|
temp -= 5 ;
|
|
|
|
}
|
|
|
|
void BuzzerOff(void)
|
|
{
|
|
__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_3, 0);
|
|
tmp_warning_level = 0;
|
|
}
|