输入方式改成中断,开启了两个定时器

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2022-05-01 11:46:10 +08:00
parent de69c38b1f
commit 6e8fd579b8
67 changed files with 2869 additions and 3022 deletions
-85
View File
@@ -10,88 +10,3 @@ TIM2->ARR = (uint32_t)((72000000/freq)-1);TIM2->CCR3 = (uint32_t)(((72000000/fr
void add_a_note(uint16_t freq,uint8_t duty,uint16_t deley)
{
struct notes* buff;
buff = (struct notes*)malloc(sizeof(struct notes));
if (buff != NULL)
{
buff->freq = freq;
buff->duty = duty;
buff->deley = deley;
buff->next_note = NULL;
if (notes == NULL)
{
notes = buff;
}
else
{
struct notes *t = notes;
while (t->next_note != NULL)
{
t = t->next_note;
}
t->next_note = buff;
}
}
}
void delhead()
{
if (notes == NULL)
{
return;
}
if (notes->next_note == NULL)
{
free(notes);
notes = NULL;
}
else
{
struct notes *t = notes;
notes = notes->next_note;
free(t);
}
}
char buzzer_play_server()
{
static char busy_flag=0;
static uint32_t play_delay;
if(notes == NULL)
{
play_ones(0,0);
}else
{
if(busy_flag==0)
{
busy_flag=1;
play_delay=HAL_GetTick()+notes->deley;
play_ones(notes->freq,notes->duty);
}
if(busy_flag==1)
{
if(HAL_GetTick()>play_delay)
{
busy_flag=0;
delhead();
}
}
}
return busy_flag;
}