[fix] update examples cdk project

This commit is contained in:
jzlv 2021-06-04 17:51:00 +08:00
parent c2f3072455
commit 5cca7f0193
57 changed files with 473 additions and 547 deletions

View file

@ -32,9 +32,6 @@ Board: bl70x_iot
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_adc.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_camera.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dac.c">
<FileOption/>
</File>
@ -71,6 +68,10 @@ Board: bl70x_iot
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_clock.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_cam.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mjpeg.c"/>
</VirtualDirectory>
<VirtualDirectory Name="std">
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_acomp.c">

View file

@ -20,19 +20,24 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Note:
*
* This Case is currently based on BL706_AVB development board with ili9341 controller screen.
* If you use other hardware platforms, please modify the pin Settings by yourself.
*
* This routine audio playback requires transcoding the audio into PCM encoding and exporting it as an audio array.
* See fhm_onechannel_16k_20.h for audio array examples , and i2s/script for transcoding scripts.
*
* Your should Short connect func1 and func2 jump cap on 706_AVB Board,and Plug the Audio Codec Board(ES8388) whit speaker into the HD11 interface.
* Audio default configuration is
*
* bitwith= 16
* datarate = 16khz ,
* channel number= 1 ,
*
* if you want to play different wav format source , pleases modify this case .
*
*/
/***************************************************************************
* bl706_avb 使
* pcm
* fhm_onechannel_16k_20.h i2s/script
*
* 使 bl706_avb
* 1. func1 func2
* 2. Decode HD11 Decode ES8388
* 3.
* 4. 16kHz sampl_freq_hz = 16*1000
*
* *************************************************************************/
#include "hal_i2s.h"
#include "hal_gpio.h"
#include "hal_dma.h"

View file

@ -1,7 +1,7 @@
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
set(TARGET_REQUIRED_LIBS fatfs)
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/spi_sd)
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c ./wav_play_form_sd_card.c)
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/es8388 ${BSP_COMMON_DIR}/spi_sd )
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/es8388/bsp_es8388.c ${BSP_COMMON_DIR}/fatfs/fatfs_spi_sd.c ${BSP_COMMON_DIR}/spi_sd/bsp_spi_sd.c ./wav_play_form_sd_card.c ./shell.c)
set(mains main.c)
generate_bin()

View file

@ -19,19 +19,20 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Note:
*
* This Case is currently based on BL706_AVB development board with ili9341 controller screen.
* If you use other hardware platforms, please modify the pin Settings by yourself.
*
* This routine audio playback requires transcoding the audio into PCM encoding and exporting it as an audio array.
* See fhm_onechannel_16k_20.h for audio array examples , and i2s/script for transcoding scripts.
*
* Your should Short connect func1 and func2 jump cap on 706_AVB Board,and Plug the Audio Codec Board(ES8388) whit speaker into the HD11 interface , and connect SD Card with SPI ports.
*
* You need to fill in the correct audio file path which in SD Card file systems in audio_init(), please refer to line 58 of this code, this version only support Engilsh path.
*
* This case use shell module to complete human-computer interaction.
*/
/***************************************************************************
* bl706_avb 使
* WAV
*
* 使 bl706_avb
* 1. func1 func2
* 2. SD 线 HD13 SPI bl706_avb pinout
* 2. Decode HD11 Decode ES8388
* 3.
* 4. audio_init() 54
*
* *************************************************************************/
#include "ff.h"
#include "wav_play_form_sd_card.h"
@ -49,10 +50,13 @@ int main(void)
fatfs_sd_driver_register();
sd_wav_play_register(&Audio_Dev);
res = f_mount(&Fs_1,"1:",1);
res = f_mount(&Fs_1,"sd:",1);
f_chdrive("sd:");
f_chdir("./wav_test");
if(res==FR_OK)
{
if(Audio_Dev.audio_init(&Audio_Dev,"1:wav_test/test9_44100_stereo_s32(24bit).wav") == 0)
if(Audio_Dev.audio_init(&Audio_Dev,"sd:/wav_test/test9_44100_stereo_s32(24bit).wav") == 0)
{
MSG("Audio Init success\r\n");
}else{
@ -66,13 +70,16 @@ int main(void)
/* start/stop test */
Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_START,NULL);
/*
bflb_platform_delay_ms(10000);
Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_STOP,NULL);
bflb_platform_delay_ms(5000);
Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_START,NULL);
bflb_platform_delay_ms(5000);
*/
/* volume test */
/*
for(uint32_t vol=0; vol<80; vol++)
{
Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_VOLUME,(void *)vol);
@ -83,6 +90,7 @@ int main(void)
Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_VOLUME,(void *)vol);
bflb_platform_delay_ms(100);
}
*/
Audio_Dev.audio_control(&Audio_Dev,AUDIO_CMD_VOLUME,(void *)30);

View file

@ -1,3 +1,26 @@
/**
* @file wav_play_form_sd_card.c
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#include "bsp_es8388.h"
#include "hal_i2s.h"
#include "hal_dma.h"
@ -108,6 +131,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path)
audio_dev->buff_using = 1;
audio_dev->device = (struct device*)NULL;
audio_dev->audio_state = 0;
f_close(&Wav_Fp);
res = f_open(&Wav_Fp, path, FA_READ);
@ -119,6 +143,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path)
MSG("wav file open error\r\n");
return 1;
}
/* Parse the WAV file */
res = wav_data_parser(buff, &Wav_Information);
if (res == 0)
{
@ -136,11 +161,27 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path)
return 1;
}
i2s_register(I2S0_INDEX,"I2S",DEVICE_OFLAG_RDWR);
audio_dev->device = device_find("I2S");
if(audio_dev->device)
{
device_close(audio_dev->device);
}
else
{
i2s_register(I2S0_INDEX,"I2S",DEVICE_OFLAG_RDWR);
audio_dev->device = device_find("I2S");
}
dma_register(DMA0_CH2_INDEX, "i2s_ch2", DEVICE_OFLAG_RDWR);
struct device *dma_ch2 = device_find("i2s_ch2");
if(dma_ch2)
{
device_close(dma_ch2);
}
else
{
dma_register(DMA0_CH2_INDEX, "i2s_ch2", DEVICE_OFLAG_RDWR);
dma_ch2 = device_find("i2s_ch2");
}
if((audio_dev->device) && dma_ch2)
{
@ -223,6 +264,7 @@ static int sd_wav_play_init(audio_dev_t *audio_dev, const TCHAR* path)
f_read(&Wav_Fp,audio_dev->buff[1], audio_dev->buff_size_max, &num);
audio_dev->buff_data_size[1] = num;
}
audio_dev->audio_state = 1;
}
else{
return 1;
@ -236,15 +278,26 @@ static int sd_wav_play_control(struct audio_dev *audio_dev, AUDIO_CMD_t cmd, voi
switch (cmd)
{
case AUDIO_CMD_START:
res = device_write(audio_dev->device,0,audio_dev->buff[!audio_dev->buff_using],audio_dev->buff_data_size[!audio_dev->buff_using]);
audio_dev->audio_state = 1;
if(audio_dev->audio_state)
{
res = device_write(audio_dev->device,0,audio_dev->buff[!audio_dev->buff_using],audio_dev->buff_data_size[!audio_dev->buff_using]);
audio_dev->audio_state = 2;
res = 0;
}
break;
case AUDIO_CMD_STOP:
audio_dev->audio_state = 0;
res=0;
if(audio_dev->audio_state)
{
audio_dev->audio_state = 1;
res=0;
}
break;
case AUDIO_CMD_VOLUME:
res = ES8388_Set_Voice_Volume((uint32_t)args);
case AUDIO_CMD_VOLUME:
if(audio_dev->audio_state)
{
res = ES8388_Set_Voice_Volume((uint32_t)args);
res=0;
}
break;
default:
break;
@ -258,12 +311,13 @@ static int sd_wav_play_callback(audio_dev_t *audio_dev)
uint8_t buff_using = audio_dev->buff_using;
if(audio_dev->buff_data_size[!buff_using] )
{
if(audio_dev->audio_state)
/* start i2s-dma */
if(audio_dev->audio_state == 2 && audio_dev->buff[!buff_using])
{
device_write(audio_dev->device, 0, audio_dev->buff[!buff_using], audio_dev->buff_data_size[!buff_using]);
audio_dev->buff_using = !buff_using;
}
/* fill data */
if (audio_dev->wav_information->chunk_format.bits_per_sample / 8 == 3)
{
f_read(&Wav_Fp, audio_dev->buff[buff_using], audio_dev->buff_size_max / 4 * 3, &num);
@ -275,9 +329,25 @@ static int sd_wav_play_callback(audio_dev_t *audio_dev)
}
audio_dev->buff_data_size[buff_using] = num;
}
if(num==0 && audio_dev->buff_data_size[0]==0 && audio_dev->buff_data_size[1]==0)
/* play end, refill the buff for next time*/
if(num==0 && audio_dev->buff_data_size[!buff_using]==0 )
{
f_lseek(&Wav_Fp, audio_dev->wav_information->chunk_data_offset+sizeof(chunk_data_t));
if(audio_dev->wav_information->chunk_format.bits_per_sample/8 == 3)
{
f_read(&Wav_Fp,audio_dev->buff[0], audio_dev->buff_size_max/4*3, &num);
audio_dev->buff_data_size[0] = pcm_24bit_to_32bit(audio_dev->buff[0],num);
f_read(&Wav_Fp,audio_dev->buff[1], audio_dev->buff_size_max/4*3, &num);
audio_dev->buff_data_size[1] = pcm_24bit_to_32bit(audio_dev->buff[1],num);
}
else
{
f_read(&Wav_Fp,audio_dev->buff[0], audio_dev->buff_size_max, &num);
audio_dev->buff_data_size[0] = num;
f_read(&Wav_Fp,audio_dev->buff[1], audio_dev->buff_size_max, &num);
audio_dev->buff_data_size[1] = num;
}
audio_dev->audio_state = 1;
MSG("End of the play\r\n");
}
return 0;
@ -294,6 +364,7 @@ int sd_wav_play_register(audio_dev_t *audio_dev)
audio_dev->buff[1] = Data_Buff1;
audio_dev->buff_data_size[0] = 0;
audio_dev->buff_data_size[1] = 0;
audio_dev->audio_state = 0;
audio_dev->buff_size_max = sizeof(Data_Buff1);
return 0;
}

View file

@ -1,3 +1,26 @@
/**
* @file wav_play_form_sd_card.h
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#ifndef __MAV_PLAY_H__
#define __MAV_PLAY_H__