From 92506bcfff1f0ce8d9ac7c79bd861d3a98fc697f Mon Sep 17 00:00:00 2001 From: Dual Tachyon Date: Sat, 12 Aug 2023 21:33:27 +0100 Subject: [PATCH] Added AUDIO_PlayVoice. --- Makefile | 1 + audio.c | 27 +++++++++++++++++++++++++++ audio.h | 9 +++++++++ 3 files changed, 37 insertions(+) create mode 100644 audio.c create mode 100644 audio.h diff --git a/Makefile b/Makefile index cfc3de1..2df7df3 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/audio.c b/audio.c new file mode 100644 index 0000000..2a4e4d4 --- /dev/null +++ b/audio.c @@ -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; + } +} + diff --git a/audio.h b/audio.h new file mode 100644 index 0000000..cf3893d --- /dev/null +++ b/audio.h @@ -0,0 +1,9 @@ +#ifndef AUDIO_H +#define AUDIO_H + +#include + +void AUDIO_PlayVoice(uint8_t VoiceID); + +#endif +