1、安装WavPlay插件:WavPlay插件安装包下载路径:https://download.csdn.net/download/weixin_48408892/86740526
2、SigmaStudio添加插件,选择Tools-Add ins Browser菜单,打开添加插件窗口如下图
3、CCES中为Wavplay访问或控制的内存分配
/Buffer to be passed to DMA/
int32_t SPI_FLASH_BUFFER[MAX_WAV_PLAYER_BLOCK_SIZE];
/memory required to hold SPI information/
uint32_t SPI_INSTANCE_MEMORY[sizeof(SPI_HANDLE)];
/memory to hold wavplayer information/
uint32_t MODULE_STATE_MEMORY[sizeof(WAV_PLAYER_STATE)];
4、在main()中创建SPI_HANDLE和WAV_PLAYER_STATE实例,并将SPI_HANDLE实例中的状态指针指向WAV_PLAYER_STATE实例的位置
SPI_HANDLE hSPI = (SPI_HANDLE)&SPI_INSTANCE_MEMORY[0];
WAV_PLAYER_STATE pState = (WAV_PLAYER_STATE)&MODULE_STATE_MEMORY[0]; hSPI->pModuleState = (WAV_PLAYER_STATE*)pState;
5、在for循环前,调用初始化例程adi_initSpiFlash(SPI_HANDLE *hSPI)
6、在每次调用adi_ssn_process()之后调用adi_readFlash(SPI_HANDLE *hSPI, WAV_PLAYER_STATE *pState)
7、从链接后生成的映射文件中记录WAV_PLAYER_STATE的地址,它必须作为参数传递给模块。
8、配置Flash文件读取初始地址、长度,并使能bReadEnable。
9、Flash音频访问举例:
ERROR_CODE spi_read_flash_wavplay(SPI_HANDLE hSPI, WAV_PLAYER_STATE pModuleState)
{
(void)memcpy(&pState->aTxBuffer[0u],pAudioBuffer,pState->nBlockSize);
pState->bTransferDone = 1u;
/initiate DMA transfer for next block of data/
if(1==is_last_from_wavplay)
{
is_last_from_wavplay=0;
lastsize=((int)pState->nFileLength - (int)pState->nCurrSampleCnt)/2;
err = spi_read_flash_data(hSPI, pState->nCurrFlashAddress, lastsize, 2u, pAudioBuffer );
for (int i=lastsize; inBlockSize ; i++)
{
pAudioBuffer[i] = pAudioBufferBack[i-lastsize];
}
pState->nCurrSampleCnt = (pState->nBlockSize - lastsize)2u;
pState->nCurrFlashAddress = pState->nFileStartAddress + pState->nCurrSampleCnt;
}
else
{
err = spi_read_flash_data(hSPI, pState->nCurrFlashAddress, pState->nBlockSize, 2u, pAudioBuffer );
/increment number of samples read/
pState->nCurrSampleCnt += pState->nBlockSize2u;
if(((int)pState->nFileLength - (int)pState->nCurrSampleCnt) < (int)pState->nBlockSize2)
{
/loop back to start of the file if count exceeds file length/
is_last_from_wavplay=1;
}
/increment address to be read/
pState->nCurrFlashAddress += pState->nBlockSize2u;
}
}
Wav Play参考AE_50_IESS_WaveplayerIntegrationGuide.pdf