AudioRecord

Dependencies:   STM32L4xx_HAL_Driver CMSIS_DSP_401

Committer:
EricLew
Date:
Wed Nov 25 17:31:28 2015 +0000
Revision:
1:1ae4b642c533
Parent:
0:d4e5ad7ad71c
Child:
3:ec7e3c37fe80
Added DSP, updated Main.c and audio_record.c to updated versions from offline IDE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EricLew 0:d4e5ad7ad71c 1 /* Includes ------------------------------------------------------------------*/
EricLew 0:d4e5ad7ad71c 2 #include "main.h"
EricLew 0:d4e5ad7ad71c 3
EricLew 0:d4e5ad7ad71c 4 /* Variable indicating which audio demo is currently running (playback v.s. record) */
EricLew 0:d4e5ad7ad71c 5 Audio_DemoTypeDef AudioDemo = AUDIO_DEMO_NONE;
EricLew 0:d4e5ad7ad71c 6
EricLew 0:d4e5ad7ad71c 7 /* Private typedef -----------------------------------------------------------*/
EricLew 0:d4e5ad7ad71c 8 typedef enum
EricLew 0:d4e5ad7ad71c 9 {
EricLew 0:d4e5ad7ad71c 10 BUFFER_OFFSET_NONE = 0,
EricLew 0:d4e5ad7ad71c 11 BUFFER_OFFSET_HALF,
EricLew 0:d4e5ad7ad71c 12 BUFFER_OFFSET_FULL,
EricLew 0:d4e5ad7ad71c 13 } RecordBufferOffset_Typedef;
EricLew 0:d4e5ad7ad71c 14
EricLew 0:d4e5ad7ad71c 15
EricLew 0:d4e5ad7ad71c 16 /* Private define ------------------------------------------------------------*/
EricLew 0:d4e5ad7ad71c 17 /* Size (in bytes) of the buffer containing the recorded PCM samples */
EricLew 1:1ae4b642c533 18 #define RECORD_BUFFER_SIZE (uint32_t)1024 //BUFFER SIZE IS THE SAME FOR BOTH RECORDINGS
EricLew 0:d4e5ad7ad71c 19
EricLew 0:d4e5ad7ad71c 20 /* Buffer containing the PCM samples coming from the microphone */
EricLew 1:1ae4b642c533 21 static uint32_t RecordBuffer[RECORD_BUFFER_SIZE]; //RECORDING BUFFER FOR SAMPLE #0
EricLew 1:1ae4b642c533 22 static uint32_t RecordBuffer1[RECORD_BUFFER_SIZE];//RECORDING BUFFER FOR SAMPLE #1
EricLew 0:d4e5ad7ad71c 23
EricLew 0:d4e5ad7ad71c 24 /* Buffer used to stream the recorded PCM samples towards the audio codec. */
EricLew 1:1ae4b642c533 25 static uint16_t PlaybackBuffer[RECORD_BUFFER_SIZE*2]; //PLAYBACK BUFFER FOR SAMPLE#0
EricLew 1:1ae4b642c533 26 static uint16_t PlaybackBuffer1[RECORD_BUFFER_SIZE*2];//PLAYBACK BUFFER FOR SAMPLE#1
EricLew 0:d4e5ad7ad71c 27
EricLew 0:d4e5ad7ad71c 28
EricLew 0:d4e5ad7ad71c 29 #define NB_SAMPLES_RATE 7
EricLew 1:1ae4b642c533 30 static uint32_t SamplesRates[NB_SAMPLES_RATE] = {BSP_AUDIO_FREQUENCY_48K}; //SAMPLE RATE IS THE SAME
EricLew 0:d4e5ad7ad71c 31
EricLew 0:d4e5ad7ad71c 32 /* Information indicating which part of the recorded buffer is ready for audio loopback */
EricLew 0:d4e5ad7ad71c 33 static RecordBufferOffset_Typedef RecordBufferOffset = BUFFER_OFFSET_NONE;
EricLew 0:d4e5ad7ad71c 34
EricLew 0:d4e5ad7ad71c 35 /* Private function prototypes -----------------------------------------------*/
EricLew 0:d4e5ad7ad71c 36 /* Display actuyel record sample rate */
EricLew 0:d4e5ad7ad71c 37 static void SampleRateDisplay(uint8_t SampleRate);
EricLew 0:d4e5ad7ad71c 38
EricLew 0:d4e5ad7ad71c 39 /* Record sample rate selection */
EricLew 0:d4e5ad7ad71c 40 static void SampleRateSelection(void);
EricLew 0:d4e5ad7ad71c 41
EricLew 0:d4e5ad7ad71c 42 /* Audio recorder callback functions */
EricLew 0:d4e5ad7ad71c 43 static void AudioRecord_TransferComplete_CallBack(void);
EricLew 0:d4e5ad7ad71c 44 static void AudioRecord_HalfTransfer_CallBack(void);
EricLew 0:d4e5ad7ad71c 45 static void AudioRecord_Error_CallBack(void);
EricLew 0:d4e5ad7ad71c 46
EricLew 0:d4e5ad7ad71c 47 /* Private functions ---------------------------------------------------------*/
EricLew 0:d4e5ad7ad71c 48
EricLew 0:d4e5ad7ad71c 49 /**
EricLew 0:d4e5ad7ad71c 50 * @brief Setup and start audio recording in loopback mode
EricLew 0:d4e5ad7ad71c 51 * @param None
EricLew 0:d4e5ad7ad71c 52 * @retval None
EricLew 0:d4e5ad7ad71c 53 */
EricLew 0:d4e5ad7ad71c 54 void AudioRecord_demo(void)
EricLew 0:d4e5ad7ad71c 55 {
EricLew 0:d4e5ad7ad71c 56 /* Indicates which part of the payback buffer must be updated */
EricLew 0:d4e5ad7ad71c 57 uint8_t transfer_range = 0;
EricLew 0:d4e5ad7ad71c 58
EricLew 1:1ae4b642c533 59 /* Flag indicating whether the audio codec has already been initialized */
EricLew 0:d4e5ad7ad71c 60 uint32_t audio_loop_back_init = RESET ;
EricLew 1:1ae4b642c533 61
EricLew 0:d4e5ad7ad71c 62 /* Audio record demo is running */
EricLew 0:d4e5ad7ad71c 63 AudioDemo = AUDIO_DEMO_RECORD;
EricLew 0:d4e5ad7ad71c 64
EricLew 0:d4e5ad7ad71c 65 /* Turn off green LED5 */
EricLew 0:d4e5ad7ad71c 66 BSP_LED_Off(LED5);
EricLew 0:d4e5ad7ad71c 67
EricLew 0:d4e5ad7ad71c 68 /* Initialize record buffer offset */
EricLew 0:d4e5ad7ad71c 69 RecordBufferOffset = BUFFER_OFFSET_NONE;
EricLew 0:d4e5ad7ad71c 70
EricLew 0:d4e5ad7ad71c 71 /* Select the audio record sample rate */
EricLew 0:d4e5ad7ad71c 72 SampleRateSelection();
EricLew 1:1ae4b642c533 73 //INITIALIZE RECORDING #0
EricLew 0:d4e5ad7ad71c 74 /* Initialize audio input */
EricLew 0:d4e5ad7ad71c 75 if (BSP_AUDIO_IN_Init(SamplesRates[SampleRateIndex],
EricLew 0:d4e5ad7ad71c 76 DEFAULT_AUDIO_IN_BIT_RESOLUTION,
EricLew 0:d4e5ad7ad71c 77 DEFAULT_AUDIO_IN_CHANNEL_NBR) != AUDIO_OK)
EricLew 0:d4e5ad7ad71c 78 {
EricLew 0:d4e5ad7ad71c 79 /* Record Error */
EricLew 0:d4e5ad7ad71c 80 Error_Handler();
EricLew 0:d4e5ad7ad71c 81 }
EricLew 0:d4e5ad7ad71c 82
EricLew 0:d4e5ad7ad71c 83 /* Set Callback function pointers */
EricLew 0:d4e5ad7ad71c 84 BSP_AUDIO_IN_RegisterCallbacks(AudioRecord_Error_CallBack,
EricLew 0:d4e5ad7ad71c 85 AudioRecord_HalfTransfer_CallBack,
EricLew 0:d4e5ad7ad71c 86 AudioRecord_TransferComplete_CallBack);
EricLew 0:d4e5ad7ad71c 87
EricLew 0:d4e5ad7ad71c 88 /* Start the audio record */
EricLew 0:d4e5ad7ad71c 89 if (BSP_AUDIO_IN_Record((uint16_t*)&RecordBuffer[0],
EricLew 0:d4e5ad7ad71c 90 RECORD_BUFFER_SIZE) != AUDIO_OK)
EricLew 0:d4e5ad7ad71c 91 {
EricLew 0:d4e5ad7ad71c 92 Error_Handler();
EricLew 0:d4e5ad7ad71c 93 }
EricLew 1:1ae4b642c533 94 uint32_t counter=0; //COUNTER IS REGISTER R4
EricLew 0:d4e5ad7ad71c 95 /* PCM samples recording loop */
EricLew 0:d4e5ad7ad71c 96 while (AudioRecordExit != SET)
EricLew 0:d4e5ad7ad71c 97 {
EricLew 1:1ae4b642c533 98
EricLew 1:1ae4b642c533 99 if (counter==10000000) //Approximately 3 seconds of record time
EricLew 1:1ae4b642c533 100 {
EricLew 1:1ae4b642c533 101 AudioRecordExit=1;
EricLew 1:1ae4b642c533 102 }
EricLew 1:1ae4b642c533 103 else
EricLew 1:1ae4b642c533 104 {
EricLew 1:1ae4b642c533 105 counter=counter++;
EricLew 1:1ae4b642c533 106 }
EricLew 0:d4e5ad7ad71c 107 /* 1st or 2nd half of the record buffer ready for being copied
EricLew 0:d4e5ad7ad71c 108 to the playback buffer */
EricLew 0:d4e5ad7ad71c 109 if(RecordBufferOffset != BUFFER_OFFSET_NONE)
EricLew 0:d4e5ad7ad71c 110 {
EricLew 0:d4e5ad7ad71c 111 /* Copy half of the record buffer to the playback buffer */
EricLew 0:d4e5ad7ad71c 112 if(RecordBufferOffset == BUFFER_OFFSET_HALF)
EricLew 0:d4e5ad7ad71c 113 {
EricLew 0:d4e5ad7ad71c 114 memcpy(&PlaybackBuffer[(RECORD_BUFFER_SIZE/2) * transfer_range],
EricLew 0:d4e5ad7ad71c 115 RecordBuffer,
EricLew 0:d4e5ad7ad71c 116 RECORD_BUFFER_SIZE);
EricLew 0:d4e5ad7ad71c 117
EricLew 0:d4e5ad7ad71c 118
EricLew 0:d4e5ad7ad71c 119 }
EricLew 0:d4e5ad7ad71c 120 else /* if(RecordBufferOffset == BUFFER_OFFSET_FULL)*/
EricLew 0:d4e5ad7ad71c 121 {
EricLew 0:d4e5ad7ad71c 122 memcpy(&PlaybackBuffer[(RECORD_BUFFER_SIZE/2) * transfer_range],
EricLew 0:d4e5ad7ad71c 123 &RecordBuffer[RECORD_BUFFER_SIZE/2],
EricLew 0:d4e5ad7ad71c 124 RECORD_BUFFER_SIZE);
EricLew 0:d4e5ad7ad71c 125 }
EricLew 0:d4e5ad7ad71c 126
EricLew 0:d4e5ad7ad71c 127 /* Wait for next data */
EricLew 0:d4e5ad7ad71c 128 RecordBufferOffset = BUFFER_OFFSET_NONE;
EricLew 0:d4e5ad7ad71c 129 transfer_range = (transfer_range+1) % 4;
EricLew 0:d4e5ad7ad71c 130 }
EricLew 0:d4e5ad7ad71c 131 }
EricLew 0:d4e5ad7ad71c 132
EricLew 0:d4e5ad7ad71c 133
EricLew 1:1ae4b642c533 134 /* Stop audio input */
EricLew 1:1ae4b642c533 135 if (BSP_AUDIO_IN_Stop() != AUDIO_OK)
EricLew 1:1ae4b642c533 136 {
EricLew 1:1ae4b642c533 137 Error_Handler();
EricLew 1:1ae4b642c533 138 }
EricLew 1:1ae4b642c533 139 /* De-initialize audio input */
EricLew 1:1ae4b642c533 140 if (BSP_AUDIO_IN_DeInit() != AUDIO_OK)
EricLew 1:1ae4b642c533 141 {
EricLew 1:1ae4b642c533 142 Error_Handler();
EricLew 1:1ae4b642c533 143 }
EricLew 1:1ae4b642c533 144 //END OF RECORDING #0
EricLew 1:1ae4b642c533 145 //INITIALIZE RECORDING #1
EricLew 1:1ae4b642c533 146 transfer_range = 0;
EricLew 1:1ae4b642c533 147
EricLew 1:1ae4b642c533 148 /* Flag indicating whether the audio codec has already been initialized */
EricLew 1:1ae4b642c533 149 audio_loop_back_init = RESET ;
EricLew 1:1ae4b642c533 150
EricLew 1:1ae4b642c533 151 /* Turn off green LED5 */
EricLew 1:1ae4b642c533 152 BSP_LED_Off(LED5);
EricLew 0:d4e5ad7ad71c 153
EricLew 1:1ae4b642c533 154 /* Initialize record buffer offset */
EricLew 1:1ae4b642c533 155 RecordBufferOffset = BUFFER_OFFSET_NONE;
EricLew 1:1ae4b642c533 156 /* Initialize audio input */
EricLew 1:1ae4b642c533 157 if (BSP_AUDIO_IN_Init(SamplesRates[SampleRateIndex],
EricLew 1:1ae4b642c533 158 DEFAULT_AUDIO_IN_BIT_RESOLUTION,
EricLew 1:1ae4b642c533 159 DEFAULT_AUDIO_IN_CHANNEL_NBR) != AUDIO_OK)
EricLew 1:1ae4b642c533 160 {
EricLew 1:1ae4b642c533 161 /* Record Error */
EricLew 1:1ae4b642c533 162 Error_Handler();
EricLew 1:1ae4b642c533 163 }
EricLew 1:1ae4b642c533 164
EricLew 1:1ae4b642c533 165 /* Set Callback function pointers */
EricLew 1:1ae4b642c533 166 BSP_AUDIO_IN_RegisterCallbacks(AudioRecord_Error_CallBack,
EricLew 1:1ae4b642c533 167 AudioRecord_HalfTransfer_CallBack,
EricLew 1:1ae4b642c533 168 AudioRecord_TransferComplete_CallBack);
EricLew 1:1ae4b642c533 169
EricLew 1:1ae4b642c533 170 /* Start the audio record */
EricLew 1:1ae4b642c533 171 if (BSP_AUDIO_IN_Record((uint16_t*)&RecordBuffer1[0],
EricLew 1:1ae4b642c533 172 RECORD_BUFFER_SIZE) != AUDIO_OK)
EricLew 1:1ae4b642c533 173 {
EricLew 1:1ae4b642c533 174 Error_Handler();
EricLew 1:1ae4b642c533 175 }
EricLew 1:1ae4b642c533 176
EricLew 1:1ae4b642c533 177 AudioRecordExit = 0; //RESET AUDIO RECORD FLAG
EricLew 1:1ae4b642c533 178 counter=0; //RESET COUNTER
EricLew 1:1ae4b642c533 179 /* PCM samples recording loop */ //COPIED FROM ABOVE USE '1' WHEN REFERENCING VARIABLES
EricLew 1:1ae4b642c533 180 while (AudioRecordExit != SET)
EricLew 1:1ae4b642c533 181 {
EricLew 1:1ae4b642c533 182
EricLew 1:1ae4b642c533 183 if (counter==10000000) //Approximately 3 seconds of record time
EricLew 1:1ae4b642c533 184 {
EricLew 1:1ae4b642c533 185 AudioRecordExit=1; //FLAG IS REGISTER R5
EricLew 1:1ae4b642c533 186 }
EricLew 1:1ae4b642c533 187 else
EricLew 1:1ae4b642c533 188 {
EricLew 1:1ae4b642c533 189 counter=counter++;
EricLew 1:1ae4b642c533 190 }
EricLew 1:1ae4b642c533 191 /* 1st or 2nd half of the record buffer ready for being copied
EricLew 1:1ae4b642c533 192 to the playback buffer */
EricLew 1:1ae4b642c533 193 if(RecordBufferOffset != BUFFER_OFFSET_NONE)
EricLew 1:1ae4b642c533 194 {
EricLew 1:1ae4b642c533 195 /* Copy half of the record buffer to the playback buffer */
EricLew 1:1ae4b642c533 196 if(RecordBufferOffset == BUFFER_OFFSET_HALF)
EricLew 1:1ae4b642c533 197 {
EricLew 1:1ae4b642c533 198 memcpy(&PlaybackBuffer1[(RECORD_BUFFER_SIZE/2) * transfer_range],
EricLew 1:1ae4b642c533 199 RecordBuffer1,
EricLew 1:1ae4b642c533 200 RECORD_BUFFER_SIZE);
EricLew 1:1ae4b642c533 201
EricLew 1:1ae4b642c533 202
EricLew 1:1ae4b642c533 203 }
EricLew 1:1ae4b642c533 204 else /* if(RecordBufferOffset == BUFFER_OFFSET_FULL)*/
EricLew 1:1ae4b642c533 205 {
EricLew 1:1ae4b642c533 206 memcpy(&PlaybackBuffer1[(RECORD_BUFFER_SIZE/2) * transfer_range],
EricLew 1:1ae4b642c533 207 &RecordBuffer1[RECORD_BUFFER_SIZE/2],
EricLew 1:1ae4b642c533 208 RECORD_BUFFER_SIZE);
EricLew 1:1ae4b642c533 209 }
EricLew 1:1ae4b642c533 210
EricLew 1:1ae4b642c533 211 /* Wait for next data */
EricLew 1:1ae4b642c533 212 RecordBufferOffset = BUFFER_OFFSET_NONE;
EricLew 1:1ae4b642c533 213 transfer_range = (transfer_range+1) % 4;
EricLew 1:1ae4b642c533 214 }
EricLew 1:1ae4b642c533 215 }
EricLew 1:1ae4b642c533 216
EricLew 0:d4e5ad7ad71c 217
EricLew 0:d4e5ad7ad71c 218 /* Stop audio input */
EricLew 0:d4e5ad7ad71c 219 if (BSP_AUDIO_IN_Stop() != AUDIO_OK)
EricLew 0:d4e5ad7ad71c 220 {
EricLew 0:d4e5ad7ad71c 221 Error_Handler();
EricLew 0:d4e5ad7ad71c 222 }
EricLew 1:1ae4b642c533 223
EricLew 0:d4e5ad7ad71c 224 /* De-initialize audio input */
EricLew 0:d4e5ad7ad71c 225 if (BSP_AUDIO_IN_DeInit() != AUDIO_OK)
EricLew 0:d4e5ad7ad71c 226 {
EricLew 0:d4e5ad7ad71c 227 Error_Handler();
EricLew 0:d4e5ad7ad71c 228 }
EricLew 1:1ae4b642c533 229 //END OF RECORDING #1
EricLew 0:d4e5ad7ad71c 230 /* Turn OFF LED5: stop record */
EricLew 0:d4e5ad7ad71c 231 BSP_LED_Off(LED5);
EricLew 0:d4e5ad7ad71c 232
EricLew 0:d4e5ad7ad71c 233 /* Reset AudioRecordExit flag */
EricLew 0:d4e5ad7ad71c 234 AudioRecordExit = 0;
EricLew 1:1ae4b642c533 235
EricLew 1:1ae4b642c533 236 //COMPARISON ALGORITHM START
EricLew 1:1ae4b642c533 237
EricLew 1:1ae4b642c533 238 /*arm_cfft_f32 ( const arm_cfft_instance_f32 * S,
EricLew 1:1ae4b642c533 239 float32_t * p1,
EricLew 1:1ae4b642c533 240 uint8_t ifftFlag,
EricLew 1:1ae4b642c533 241 uint8_t bitReverseFlag
EricLew 1:1ae4b642c533 242 )
EricLew 1:1ae4b642c533 243
EricLew 1:1ae4b642c533 244 */
EricLew 1:1ae4b642c533 245
EricLew 0:d4e5ad7ad71c 246 /* Turn off green led */
EricLew 0:d4e5ad7ad71c 247 AudioDemo = AUDIO_DEMO_NONE;
EricLew 0:d4e5ad7ad71c 248 }
EricLew 0:d4e5ad7ad71c 249
EricLew 0:d4e5ad7ad71c 250 /**
EricLew 0:d4e5ad7ad71c 251 * @brief Display actual audio record sample rate on LCD
EricLew 0:d4e5ad7ad71c 252 * @param None
EricLew 0:d4e5ad7ad71c 253 * @retval None
EricLew 0:d4e5ad7ad71c 254 */
EricLew 0:d4e5ad7ad71c 255 static void SampleRateDisplay(uint8_t SampleRate)
EricLew 0:d4e5ad7ad71c 256 {
EricLew 0:d4e5ad7ad71c 257 /* Clear the LCD glass */
EricLew 0:d4e5ad7ad71c 258 BSP_LCD_GLASS_Clear();
EricLew 0:d4e5ad7ad71c 259
EricLew 0:d4e5ad7ad71c 260 /* Display actual audio record sample rate */
EricLew 0:d4e5ad7ad71c 261 switch (SamplesRates[SampleRate])
EricLew 0:d4e5ad7ad71c 262 {
EricLew 0:d4e5ad7ad71c 263 case BSP_AUDIO_FREQUENCY_48K:
EricLew 0:d4e5ad7ad71c 264 BSP_LCD_GLASS_DisplayString((uint8_t *)"48000");
EricLew 0:d4e5ad7ad71c 265 break;
EricLew 1:1ae4b642c533 266 }
EricLew 1:1ae4b642c533 267 }
EricLew 0:d4e5ad7ad71c 268 /**
EricLew 0:d4e5ad7ad71c 269 * @brief Audio record sample rate selection
EricLew 0:d4e5ad7ad71c 270 * @param None
EricLew 0:d4e5ad7ad71c 271 * @retval None
EricLew 0:d4e5ad7ad71c 272 */
EricLew 0:d4e5ad7ad71c 273 void SampleRateSelection(void)
EricLew 0:d4e5ad7ad71c 274 {
EricLew 0:d4e5ad7ad71c 275 /* Display actual audio record sample rate */
EricLew 0:d4e5ad7ad71c 276 SampleRateDisplay(SampleRateIndex);
EricLew 0:d4e5ad7ad71c 277
EricLew 0:d4e5ad7ad71c 278 /* Select audio record sample rate */
EricLew 0:d4e5ad7ad71c 279 while (!AudioRecordSampleRateSelected)
EricLew 0:d4e5ad7ad71c 280 {
EricLew 0:d4e5ad7ad71c 281 if (AudioRecordSampleRateChange != 0)
EricLew 0:d4e5ad7ad71c 282 {
EricLew 0:d4e5ad7ad71c 283 SampleRateDisplay(SampleRateIndex);
EricLew 0:d4e5ad7ad71c 284 HAL_Delay(5);
EricLew 0:d4e5ad7ad71c 285 AudioRecordSampleRateChange = 0;
EricLew 0:d4e5ad7ad71c 286 }
EricLew 0:d4e5ad7ad71c 287 }
EricLew 0:d4e5ad7ad71c 288
EricLew 0:d4e5ad7ad71c 289 AudioRecordSampleRateSelected = 0;
EricLew 0:d4e5ad7ad71c 290 }
EricLew 0:d4e5ad7ad71c 291
EricLew 0:d4e5ad7ad71c 292 /**
EricLew 0:d4e5ad7ad71c 293 * @brief Callback function invoked when half of the PCM samples have been
EricLew 0:d4e5ad7ad71c 294 * DM Atransfered from the DFSDM channel.
EricLew 0:d4e5ad7ad71c 295 * @param None
EricLew 0:d4e5ad7ad71c 296 * @retval None
EricLew 0:d4e5ad7ad71c 297 */
EricLew 0:d4e5ad7ad71c 298 void AudioRecord_TransferComplete_CallBack(void)
EricLew 0:d4e5ad7ad71c 299 {
EricLew 0:d4e5ad7ad71c 300 /* Toggle green LED */
EricLew 0:d4e5ad7ad71c 301 BSP_LED_Toggle(LED5);
EricLew 0:d4e5ad7ad71c 302
EricLew 0:d4e5ad7ad71c 303 RecordBufferOffset = BUFFER_OFFSET_FULL;
EricLew 0:d4e5ad7ad71c 304 }
EricLew 0:d4e5ad7ad71c 305
EricLew 0:d4e5ad7ad71c 306 /**
EricLew 0:d4e5ad7ad71c 307 * @brief Callback function invoked when all the PCM samples have been
EricLew 0:d4e5ad7ad71c 308 * DMA transfered from the DFSDM channel.
EricLew 0:d4e5ad7ad71c 309 * @param None
EricLew 0:d4e5ad7ad71c 310 * @retval None
EricLew 0:d4e5ad7ad71c 311 */
EricLew 0:d4e5ad7ad71c 312 void AudioRecord_HalfTransfer_CallBack(void)
EricLew 0:d4e5ad7ad71c 313 {
EricLew 0:d4e5ad7ad71c 314 RecordBufferOffset = BUFFER_OFFSET_HALF;
EricLew 0:d4e5ad7ad71c 315 }
EricLew 0:d4e5ad7ad71c 316
EricLew 0:d4e5ad7ad71c 317 /**
EricLew 0:d4e5ad7ad71c 318 * @brief Callback function invoked when an error occured durint he DMA
EricLew 0:d4e5ad7ad71c 319 * transfer of the PCM samples from the DFSDM channel.
EricLew 0:d4e5ad7ad71c 320 * @param None
EricLew 0:d4e5ad7ad71c 321 * @retval None
EricLew 0:d4e5ad7ad71c 322 */
EricLew 0:d4e5ad7ad71c 323 void AudioRecord_Error_CallBack(void)
EricLew 0:d4e5ad7ad71c 324 {
EricLew 0:d4e5ad7ad71c 325 /* Stop the program with an infinite loop */
EricLew 0:d4e5ad7ad71c 326 Error_Handler();
EricLew 0:d4e5ad7ad71c 327 }
EricLew 0:d4e5ad7ad71c 328 /**
EricLew 0:d4e5ad7ad71c 329 * @}
EricLew 0:d4e5ad7ad71c 330 */
EricLew 0:d4e5ad7ad71c 331
EricLew 0:d4e5ad7ad71c 332
EricLew 0:d4e5ad7ad71c 333 /**
EricLew 0:d4e5ad7ad71c 334 * @}
EricLew 0:d4e5ad7ad71c 335 */
EricLew 0:d4e5ad7ad71c 336 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
EricLew 0:d4e5ad7ad71c 337