Car/Peripheral/Src/buzzer.c

27 lines
518 B
C
Raw Normal View History

2024-07-18 11:29:28 +08:00
#include "buzzer.h"
#include "timer.h"
static uint8_t state;
inline void BUZZER_Start()
{
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_RESET);
}
inline void BUZZER_Stop()
{
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_SET);
2024-07-19 12:33:18 +08:00
if (state == 1)
{
state = 0;
TIMER_DelLoopEvent(EVENT_BUZZER);
}
2024-07-18 11:29:28 +08:00
}
void BUZZER_StartTimed(uint8_t time)
{
2024-07-19 12:33:18 +08:00
state = 1;
2024-07-18 11:29:28 +08:00
BUZZER_Start();
TIMER_AddLoopEvent(EVENT_BUZZER, BUZZER_Stop, time * 100);
}