1 Star 1 Fork 0

网易独家音乐人Mike Zhou/ADuCM4050的函数打包

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BEEP 7.44 KB
一键复制 编辑 原始数据 按行查看 历史
网易独家音乐人Mike Zhou 提交于 2024-10-12 06:37 . add BEEP.
#include "ADuCM4050.h"
#include "drivers/beep/adi_beep.h"
#include "drivers/pwr/adi_pwr.h"
#include <stdio.h>
#include "GPIO.h"
#include "DELAY.h"
#include "PITCH.h"
#include "MUSIC_NOTE.h"
unsigned char BEEP0_MemorySize[ADI_BEEP_MEMORY_SIZE]; //20b+ADI_SEM_SIZE
ADI_BEEP_HANDLE handle_BEEP0;
void callback_BEEP0(void *pCBParam,uint32_t Event,void *pArg);
uint8_t i=0;
ADI_BEEP_NOTE GYZ[254]=
{
{.frequency=ADI_BEEP_FREQ_A4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_A4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_B4,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_12_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_12_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_A5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_12_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_12_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_A5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_REST,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_A4,.duration=ADI_BEEP_DUR_32_32},
{.frequency=ADI_BEEP_FREQ_REST,.duration=ADI_BEEP_DUR_32_32},
{.frequency=ADI_BEEP_FREQ_REST,.duration=ADI_BEEP_DUR_32_32},
{.frequency=ADI_BEEP_FREQ_REST,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_G5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_E5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_REST,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_D5,.duration=ADI_BEEP_DUR_16_32},
{.frequency=ADI_BEEP_FREQ_C5,.duration=ADI_BEEP_DUR_8_32},
{.frequency=ADI_BEEP_FREQ_A4,.duration=ADI_BEEP_DUR_32_32},
};
void init_PWR_CLK(void)
{
adi_pwr_Init();
adi_pwr_EnableClockSource(ADI_CLOCK_SOURCE_HFXTAL,true);
adi_pwr_EnableClockSource(ADI_CLOCK_SOURCE_LFXTAL,true);
adi_pwr_SetClockDivider(ADI_CLOCK_HCLK,1);
adi_pwr_SetClockDivider(ADI_CLOCK_PCLK,1);
}
void init_BEEP0(void)
{
mux_PINS(0,8,1);
mux_PINS(0,9,1);
adi_beep_Open(ADI_BEEP_DEVID_0,&BEEP0_MemorySize,ADI_BEEP_MEMORY_SIZE,&handle_BEEP0);
adi_beep_RegisterCallback(handle_BEEP0,callback_BEEP0,NULL);
adi_beep_Enable(handle_BEEP0,true);
}
void play_NOTE(ADI_BEEP_NOTE_FREQUENCY f,ADI_BEEP_NOTE_DURATION d)
{
ADI_BEEP_NOTE Notes;
Notes.frequency=f;
Notes.duration=d;
adi_beep_PlayNote(handle_BEEP0,Notes);
adi_beep_Wait(handle_BEEP0);
}
void play_NOTE_Buf(ADI_BEEP_NOTE* Note_Buf,uint8_t size)
{
adi_beep_PlaySequence(handle_BEEP0,Note_Buf,size);
adi_beep_Wait(handle_BEEP0);
}
int main(void)
{
init_BEEP0();
play_NOTE_Buf(GYZ,96);
play_NOTE(ADI_BEEP_FREQ_A5,ADI_BEEP_DUR_16_32);
return 0;
}
void callback_BEEP0(void *pCBParam,uint32_t Event,void *pArg)
{
i++;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Mike_Zhou_Admin/ADuCM4050_Func.git
git@gitee.com:Mike_Zhou_Admin/ADuCM4050_Func.git
Mike_Zhou_Admin
ADuCM4050_Func
ADuCM4050的函数打包
master

搜索帮助