AUDIO DISCO_F769NI audioloop basic example
Dependencies: BSP_DISCO_F769NI
Revision 2:db1aee306f50, committed 2019-11-22
- Comitter:
- Jerome Coutant
- Date:
- Fri Nov 22 16:02:58 2019 +0100
- Parent:
- 1:f849e36f029e
- Commit message:
- Update with STM32Cube_FW_F7_V1.15.0
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Fri Nov 22 16:02:58 2019 +0100 @@ -0,0 +1,2 @@ +BUILD +mbed-os/
--- a/BSP_DISCO_F769NI.lib Tue Apr 04 09:42:54 2017 +0000 +++ b/BSP_DISCO_F769NI.lib Fri Nov 22 16:02:58 2019 +0100 @@ -1,1 +1,1 @@ -https://mbed.org/teams/ST/code/BSP_DISCO_F769NI/#39d2c2c79afa +https://mbed.org/teams/ST/code/BSP_DISCO_F769NI/#d13d7c447539
--- a/main.cpp Tue Apr 04 09:42:54 2017 +0000 +++ b/main.cpp Fri Nov 22 16:02:58 2019 +0100 @@ -1,51 +1,51 @@ #include "mbed.h" #include "stm32f769i_discovery.h" #include "stm32f769i_discovery_audio.h" - + static void CopyBuffer(int16_t *pbuffer1, int16_t *pbuffer2, uint16_t BufferSize); - + #define SCRATCH_BUFF_SIZE 1024 #define RECORD_BUFFER_SIZE 4096 - + typedef enum { BUFFER_OFFSET_NONE = 0, BUFFER_OFFSET_HALF = 1, BUFFER_OFFSET_FULL = 2, } BUFFER_StateTypeDef; - + volatile uint32_t audio_rec_buffer_state = BUFFER_OFFSET_NONE; int32_t Scratch[SCRATCH_BUFF_SIZE]; - + /* Buffer containing the PCM samples coming from the microphone */ int16_t RecordBuffer[RECORD_BUFFER_SIZE]; - + /* Buffer used to stream the recorded PCM samples towards the audio codec. */ int16_t PlaybackBuffer[RECORD_BUFFER_SIZE]; - + int main() { uint32_t audio_loop_back_init = RESET ; - + printf("\n\nAUDIO LOOPBACK EXAMPLE FOR DISCO-F769NI START:\n"); - + /* Initialize Audio Recorder with 4 channels to be used */ if (BSP_AUDIO_IN_Init(BSP_AUDIO_FREQUENCY_44K, DEFAULT_AUDIO_IN_BIT_RESOLUTION, 2*DEFAULT_AUDIO_IN_CHANNEL_NBR) == AUDIO_ERROR) { printf("BSP_AUDIO_IN_Init error\n"); } - + /* Allocate scratch buffers */ if (BSP_AUDIO_IN_AllocScratch (Scratch, SCRATCH_BUFF_SIZE) == AUDIO_ERROR) { printf("BSP_AUDIO_IN_AllocScratch error\n"); } - + /* Start Recording */ if (BSP_AUDIO_IN_Record((uint16_t*)&RecordBuffer[0], RECORD_BUFFER_SIZE) == AUDIO_ERROR) { printf("BSP_AUDIO_IN_Record error\n"); } uint8_t ChannelNumber = BSP_AUDIO_IN_GetChannelNumber(); - + audio_rec_buffer_state = BUFFER_OFFSET_NONE; - + while (1) { /* 1st or 2nd half of the record buffer ready for being copied to the playbakc buffer */ if(audio_rec_buffer_state != BUFFER_OFFSET_NONE) { @@ -62,7 +62,7 @@ } else { BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02); } - + /* Play the recorded buffer */ if (BSP_AUDIO_OUT_Play((uint16_t *) &PlaybackBuffer[0], 2*RECORD_BUFFER_SIZE) == AUDIO_ERROR) { printf("BSP_AUDIO_OUT_Play error\n"); @@ -70,18 +70,18 @@ /* Audio device is initialized only once */ audio_loop_back_init = SET; } - - + + } else { /* if(audio_rec_buffer_state == BUFFER_OFFSET_FULL)*/ CopyBuffer(&PlaybackBuffer[RECORD_BUFFER_SIZE/2], &RecordBuffer[RECORD_BUFFER_SIZE/2], RECORD_BUFFER_SIZE/2); } - + /* Wait for next data */ audio_rec_buffer_state = BUFFER_OFFSET_NONE; } } } - + /*------------------------------------------------------------------------------------- Callbacks implementation: the callbacks API are defined __weak in the stm32f769i_discovery_audio.c file @@ -97,7 +97,7 @@ { audio_rec_buffer_state = BUFFER_OFFSET_FULL; } - + /** * @brief Manages the DMA Half Transfer complete interrupt. * @param None @@ -107,7 +107,7 @@ { audio_rec_buffer_state = BUFFER_OFFSET_HALF; } - + /** * @brief Audio IN Error callback function. * @param None @@ -117,11 +117,13 @@ { printf("BSP_AUDIO_IN_Error_CallBack\n"); } - - + + /** * @brief Copy content of pbuffer2 to pbuffer1 - * @param None + * @param1 BufferOut + * @param2 BufferIn + * @param3 Size * @retval None */ static void CopyBuffer(int16_t *pbuffer1, int16_t *pbuffer2, uint16_t BufferSize)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Fri Nov 22 16:02:58 2019 +0100 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#eb60e67d92fa6d01b8e6a822434010a53d4eb006
--- a/mbed.bld Tue Apr 04 09:42:54 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/856d2700e60b \ No newline at end of file