M26/app/user/buzzer.c

45 lines
601 B
C

#include "buzzer.h"
#include "hwCtrl.h"
static uint8_t buzzer_state;
static uint16_t buzzer_count;
void buzzer_init(void)
{
buzzer_state = 0;
buzzer_count = 0;
buzzer_stop();
}
void buzzer_start(void)
{
buzzer_state = 1;
buzzer_count = 0;
//R_TAU0_Channel4_Start();
Buzzer_ctrl(1);
}
void buzzer_stop(void)
{
buzzer_state = 0;
//R_TAU0_Channel4_Stop();
Buzzer_ctrl(0);
}
void buzzer_task(void)//10ms
{
if (buzzer_state == 1)
{
buzzer_count++;
if (buzzer_count >= 20)
{
buzzer_stop();
}
}
}