Added AUDIO_PlayVoice.

This commit is contained in:
Dual Tachyon 2023-08-12 21:33:27 +01:00
parent 757968759e
commit 92506bcfff
3 changed files with 37 additions and 0 deletions

View File

@ -33,6 +33,7 @@ OBJS += driver/systick.o
OBJS += driver/uart.o
# Main
OBJS += audio.o
OBJS += battery.o
OBJS += board.o
OBJS += dcs.o

27
audio.c Normal file
View File

@ -0,0 +1,27 @@
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/gpio.h"
#include "driver/system.h"
#include "driver/systick.h"
void AUDIO_PlayVoice(uint8_t VoiceID)
{
uint8_t i;
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
SYSTEM_DelayMs(7);
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
for (i = 0; i < 8; i++) {
if ((VoiceID & 0x80U) == 0) {
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
} else {
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
}
SYSTICK_DelayUs(1200);
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
SYSTICK_DelayUs(1200);
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
VoiceID <<= 1;
}
}

9
audio.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef AUDIO_H
#define AUDIO_H
#include <stdint.h>
void AUDIO_PlayVoice(uint8_t VoiceID);
#endif