lab 1 code

Dependencies:   CMSIS-DSP_for_STM32F746G BSP_DISCO_F746NG

Committer:
bmazzeo
Date:
Fri Jan 03 21:00:56 2020 +0000
Revision:
31:5a0235b66851
Parent:
30:debea332cdfe
Child:
33:a0dab92ea1b9
Updated the code so that way a user can download the code, compile it, and use it. It has the basic outline for the first laboratory activity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bmazzeo 9:f5b37c71856d 1 /**
bmazzeo 9:f5b37c71856d 2 ******************************************************************************
bmazzeo 9:f5b37c71856d 3 * @file main.c
bmazzeo 9:f5b37c71856d 4 * @author Brian Mazzeo
bmazzeo 23:d938f87dd1ee 5 * @date 2020
bmazzeo 9:f5b37c71856d 6 * @brief This file provides a set of code for signal processing in 487.
bmazzeo 9:f5b37c71856d 7 * Parts are taken from example code from STMIcroelectronics
bmazzeo 9:f5b37c71856d 8 ******************************************************************************
bmazzeo 9:f5b37c71856d 9 * @attention
bmazzeo 13:61131aac4031 10 * This code was specifically developed for BYU ECEn 487 course
bmazzeo 13:61131aac4031 11 * Introduction to Digital Signal Processing.
bmazzeo 9:f5b37c71856d 12 *
bmazzeo 9:f5b37c71856d 13 *
bmazzeo 9:f5b37c71856d 14 ******************************************************************************
bmazzeo 9:f5b37c71856d 15 */
bmazzeo 9:f5b37c71856d 16
bmazzeo 9:f5b37c71856d 17
adustm 0:da04816fb411 18 #include "mbed.h"
Jerome Coutant 5:66c230f74325 19 #include "stm32746g_discovery_audio.h"
Jerome Coutant 5:66c230f74325 20 #include "stm32746g_discovery_sdram.h"
bmazzeo 6:e689075b04ed 21 #include "stm32746g_discovery_lcd.h"
bmazzeo 23:d938f87dd1ee 22 #include "signal_processing.h"
adustm 0:da04816fb411 23
bmazzeo 30:debea332cdfe 24 /* The following type definitions are used to control the
bmazzeo 30:debea332cdfe 25 * buffering of the audio data using a double buffering technique.
bmazzeo 30:debea332cdfe 26 * Most of the transactions between the WM8994 and the microcontroller
bmazzeo 30:debea332cdfe 27 * are handled by other code - but this signals what the buffering state
bmazzeo 30:debea332cdfe 28 * is, so the data can be appropriately processed. */
Jerome Coutant 5:66c230f74325 29 typedef enum {
adustm 0:da04816fb411 30 BUFFER_OFFSET_NONE = 0,
adustm 0:da04816fb411 31 BUFFER_OFFSET_HALF = 1,
adustm 0:da04816fb411 32 BUFFER_OFFSET_FULL = 2,
Jerome Coutant 5:66c230f74325 33 } BUFFER_StateTypeDef;
Jerome Coutant 5:66c230f74325 34
bmazzeo 30:debea332cdfe 35 /* These audio block samples define the size of the buffering */
bmazzeo 19:479f611941a8 36 #define AUDIO_BLOCK_SAMPLES ((uint32_t)128) // Number of samples (L and R) in audio block (each samples is 16 bits)
bmazzeo 19:479f611941a8 37 #define AUDIO_BLOCK_SIZE ((uint32_t)512) // Number of bytes in audio block (4 * AUDIO_BLOCK_SAMPLES)
bmazzeo 6:e689075b04ed 38
bmazzeo 30:debea332cdfe 39 /* These RAM addresses are important to determine where the audio data is stored. */
bmazzeo 9:f5b37c71856d 40 #define SDRAM_DEVICE_ADDR_AUDIO_MEM ((uint32_t)0xC0400000)
bmazzeo 9:f5b37c71856d 41 #define AUDIO_BUFFER_IN SDRAM_DEVICE_ADDR_AUDIO_MEM
bmazzeo 9:f5b37c71856d 42 #define AUDIO_BUFFER_OUT (AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE * 2))
Jerome Coutant 5:66c230f74325 43
bmazzeo 30:debea332cdfe 44 /* These definitions define the size of the oscilloscope that is used to display data. */
bmazzeo 8:d1c41eca57f0 45 #define OSC_START_X_POS 20
bmazzeo 6:e689075b04ed 46 #define OSC_LINE_SIZE 256
bmazzeo 31:5a0235b66851 47 #define OSC_Y_POS 130
bmazzeo 31:5a0235b66851 48 #define AUDIO_DRAW_LIMIT 50
bmazzeo 6:e689075b04ed 49
bmazzeo 30:debea332cdfe 50 /* This define a timer that is then used to record the timing of the different processing stages. */
bmazzeo 9:f5b37c71856d 51 Timer timer;
bmazzeo 9:f5b37c71856d 52
bmazzeo 30:debea332cdfe 53 /* This variable is important because it define the audio buffer recording state. */
Jerome Coutant 5:66c230f74325 54 volatile uint32_t audio_rec_buffer_state = BUFFER_OFFSET_NONE;
bmazzeo 30:debea332cdfe 55
bmazzeo 30:debea332cdfe 56 /* Function declarations */
bmazzeo 17:eb85a2387dd4 57 static void Erase_Trace(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
bmazzeo 17:eb85a2387dd4 58 static void Draw_Trace(uint16_t Xpos, uint16_t Ypos, uint16_t* Mem_start, uint16_t Length);
bmazzeo 16:b7dca59ab076 59 static void Audio_to_Float(uint16_t* buffer_in, float* L_out, float* R_out, uint16_t Length);
bmazzeo 16:b7dca59ab076 60 static void Float_to_Audio(float* L_in, float* R_in, uint16_t* buffer_out, uint16_t Length);
Jerome Coutant 5:66c230f74325 61
bmazzeo 30:debea332cdfe 62 /* These memory blocks are important for converting to floating point representation. */
bmazzeo 19:479f611941a8 63 float L_channel_float[AUDIO_BLOCK_SAMPLES];
bmazzeo 19:479f611941a8 64 float R_channel_float[AUDIO_BLOCK_SAMPLES];
bmazzeo 20:2ecdf687a2d1 65 float *L_channel_float_p = &L_channel_float[0];
bmazzeo 20:2ecdf687a2d1 66 float *R_channel_float_p = &R_channel_float[0];
bmazzeo 14:18f159d48340 67
bmazzeo 30:debea332cdfe 68 /* These memory blocks are where the information is stored to send back out to the WM8994 chip. */
bmazzeo 22:f36d7a53bb7e 69 uint16_t Processed_audio[AUDIO_BLOCK_SAMPLES];
bmazzeo 20:2ecdf687a2d1 70 uint16_t *Processed_audio_p = &Processed_audio[0];
bmazzeo 14:18f159d48340 71
bmazzeo 14:18f159d48340 72 /* Useful variables during looping */
bmazzeo 30:debea332cdfe 73 uint32_t counter = 0; // Loop counter
bmazzeo 30:debea332cdfe 74 char buf[40]; // Character buffer for sprintf statements to the LCD
bmazzeo 30:debea332cdfe 75 int first_half_time = 0; // Time of first processing block
bmazzeo 30:debea332cdfe 76 int second_half_time = 0; // Time of second processing block
bmazzeo 30:debea332cdfe 77 int total_time = 0; // Time of total loop (first and second blocks)
bmazzeo 9:f5b37c71856d 78
bmazzeo 30:debea332cdfe 79 /* Main Function */
adustm 0:da04816fb411 80 int main()
adustm 0:da04816fb411 81 {
bmazzeo 13:61131aac4031 82 /* Initialize the LCD Screen and display information */
bmazzeo 6:e689075b04ed 83 BSP_LCD_Init();
bmazzeo 6:e689075b04ed 84 BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
bmazzeo 6:e689075b04ed 85 BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
bmazzeo 6:e689075b04ed 86
bmazzeo 30:debea332cdfe 87 /* Clear the LCD and set the font to be default */
bmazzeo 6:e689075b04ed 88 BSP_LCD_Clear(LCD_COLOR_BLACK);
bmazzeo 6:e689075b04ed 89 BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
bmazzeo 30:debea332cdfe 90
bmazzeo 30:debea332cdfe 91 /* Set the backcolor to be black and the textcolor to be orange. */
bmazzeo 6:e689075b04ed 92 BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
bmazzeo 6:e689075b04ed 93 BSP_LCD_SetTextColor(LCD_COLOR_ORANGE);
bmazzeo 30:debea332cdfe 94
bmazzeo 30:debea332cdfe 95 /* The following are static display elements that will remain on the screen. */
bmazzeo 31:5a0235b66851 96 BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"487 Lab 1 (student)", LEFT_MODE);
bmazzeo 30:debea332cdfe 97
bmazzeo 30:debea332cdfe 98 /* Display the L and R colors for the channels */
bmazzeo 17:eb85a2387dd4 99 BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
bmazzeo 17:eb85a2387dd4 100 BSP_LCD_DisplayStringAt(0, OSC_Y_POS - 20, (uint8_t *)"L", LEFT_MODE);
bmazzeo 17:eb85a2387dd4 101 BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
bmazzeo 17:eb85a2387dd4 102 BSP_LCD_DisplayStringAt(0, OSC_Y_POS, (uint8_t *)"R", LEFT_MODE);
bmazzeo 6:e689075b04ed 103
bmazzeo 30:debea332cdfe 104 /* The following code should not be code that you need to worry about - it sets up the audio interfaces. */
bmazzeo 30:debea332cdfe 105 /* Initialize the Audio Interface */
bmazzeo 30:debea332cdfe 106 BSP_AUDIO_IN_OUT_Init(INPUT_DEVICE_DIGITAL_MICROPHONE_2, OUTPUT_DEVICE_HEADPHONE, DEFAULT_AUDIO_IN_FREQ, DEFAULT_AUDIO_IN_BIT_RESOLUTION, DEFAULT_AUDIO_IN_CHANNEL_NBR);
bmazzeo 30:debea332cdfe 107
bmazzeo 30:debea332cdfe 108 /* Initialize SDRAM buffers */
bmazzeo 30:debea332cdfe 109 BSP_SDRAM_Init();
bmazzeo 30:debea332cdfe 110 memset((uint16_t *)AUDIO_BUFFER_IN, 0, AUDIO_BLOCK_SIZE * 2);
bmazzeo 30:debea332cdfe 111 memset((uint16_t *)AUDIO_BUFFER_OUT, 0, AUDIO_BLOCK_SIZE * 2);
bmazzeo 30:debea332cdfe 112
bmazzeo 30:debea332cdfe 113 /* Start Recording */
bmazzeo 30:debea332cdfe 114 if (BSP_AUDIO_IN_Record((uint16_t *)AUDIO_BUFFER_IN, AUDIO_BLOCK_SIZE) != AUDIO_OK) { printf("BSP_AUDIO_IN_Record error\n"); }
bmazzeo 30:debea332cdfe 115
bmazzeo 30:debea332cdfe 116 /* Start Playback */
bmazzeo 30:debea332cdfe 117 BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02);
bmazzeo 30:debea332cdfe 118 if (BSP_AUDIO_OUT_Play((uint16_t *)AUDIO_BUFFER_OUT, AUDIO_BLOCK_SIZE * 2) != AUDIO_OK) { printf("BSP_AUDIO_OUT_Play error\n"); }
bmazzeo 30:debea332cdfe 119
bmazzeo 30:debea332cdfe 120 /* The audio interfaces are all now working.
bmazzeo 30:debea332cdfe 121 * Importantly - AUDIO_BUFFER_IN is the pointer to the incoming data from the WM8994
bmazzeo 30:debea332cdfe 122 * AUDIO_BUFFER_OUT is the pointer to the outgoing data to the WM8994 */
Jerome Coutant 5:66c230f74325 123
adustm 0:da04816fb411 124
bmazzeo 30:debea332cdfe 125 /* Initialize signal processing filters - usually there are variables that
bmazzeo 30:debea332cdfe 126 * need to be set up or that there are arrays you need to precompute - this
bmazzeo 30:debea332cdfe 127 * function call allows you to do that. */
bmazzeo 25:5412779376a7 128 initalize_signal_processing();
adustm 0:da04816fb411 129
bmazzeo 30:debea332cdfe 130 /* Hardware timer starts. Set to zero */
bmazzeo 9:f5b37c71856d 131 timer.start();
bmazzeo 30:debea332cdfe 132
bmazzeo 30:debea332cdfe 133 /* Main signal processing while loop */
adustm 0:da04816fb411 134 while (1) {
bmazzeo 30:debea332cdfe 135
bmazzeo 6:e689075b04ed 136 /* First Half */
bmazzeo 30:debea332cdfe 137 /* Wait until end of half block recording before going on in the first half cycle*/
bmazzeo 11:4256dbbb0c89 138 while (audio_rec_buffer_state != BUFFER_OFFSET_HALF) {}
bmazzeo 9:f5b37c71856d 139
bmazzeo 13:61131aac4031 140 /* This captures the time of an entire cycle */
bmazzeo 9:f5b37c71856d 141 total_time = timer.read_us();
bmazzeo 13:61131aac4031 142
bmazzeo 13:61131aac4031 143 /* Reset the timer counter to zero */
bmazzeo 9:f5b37c71856d 144 timer.reset();
Jerome Coutant 5:66c230f74325 145
bmazzeo 13:61131aac4031 146 /* Plot traces of first half block recording */
bmazzeo 19:479f611941a8 147 Erase_Trace(OSC_START_X_POS, OSC_Y_POS, AUDIO_BLOCK_SAMPLES);
bmazzeo 19:479f611941a8 148 Draw_Trace(OSC_START_X_POS, OSC_Y_POS, (uint16_t *) AUDIO_BUFFER_IN, AUDIO_BLOCK_SAMPLES);
bmazzeo 18:255d15af49f2 149
bmazzeo 14:18f159d48340 150 /* Convert data to floating point representation for processing */
bmazzeo 20:2ecdf687a2d1 151 Audio_to_Float((uint16_t *) AUDIO_BUFFER_IN, L_channel_float_p, R_channel_float_p, AUDIO_BLOCK_SAMPLES);
bmazzeo 22:f36d7a53bb7e 152
bmazzeo 30:debea332cdfe 153 /* ------------------------------------------------------------------------ */
bmazzeo 30:debea332cdfe 154 /* Here is where signal processing can be done on the floating point arrays */
bmazzeo 22:f36d7a53bb7e 155
bmazzeo 30:debea332cdfe 156 process_audio_channel_signals(L_channel_float_p, R_channel_float_p, AUDIO_BLOCK_SAMPLES);
bmazzeo 20:2ecdf687a2d1 157
bmazzeo 30:debea332cdfe 158 /* Here is where signal processing can end on the floating point arrays */
bmazzeo 30:debea332cdfe 159 /* -------------------------------------------------------------------- */
bmazzeo 20:2ecdf687a2d1 160
bmazzeo 22:f36d7a53bb7e 161 /* Covert floating point data back to fixed point audio format */
bmazzeo 21:4dbfda694c0d 162 Float_to_Audio(L_channel_float_p, R_channel_float_p, (uint16_t *) Processed_audio, AUDIO_BLOCK_SAMPLES);
bmazzeo 14:18f159d48340 163
bmazzeo 13:61131aac4031 164 /* Copy recorded 1st half block into the audio buffer that goes out */
bmazzeo 31:5a0235b66851 165 /* Replace the second memcpy with this first one once you have worked out the processed audio functions. */
bmazzeo 31:5a0235b66851 166 //memcpy((uint16_t *)(AUDIO_BUFFER_OUT), (uint16_t *)(Processed_audio), AUDIO_BLOCK_SIZE);
bmazzeo 31:5a0235b66851 167 memcpy((uint16_t *)(AUDIO_BUFFER_OUT), (uint16_t *)(AUDIO_BUFFER_IN), AUDIO_BLOCK_SIZE);
bmazzeo 13:61131aac4031 168
bmazzeo 26:023edf8cea6c 169 /* Display useful cycle information (split up information display so the processing is more balanced) */
bmazzeo 26:023edf8cea6c 170 sprintf(buf, "Cycles: %9d", counter);
bmazzeo 26:023edf8cea6c 171 BSP_LCD_SetTextColor(LCD_COLOR_RED);
bmazzeo 26:023edf8cea6c 172 BSP_LCD_DisplayStringAt(0, 46, (uint8_t *) buf, LEFT_MODE);
bmazzeo 26:023edf8cea6c 173
bmazzeo 26:023edf8cea6c 174
bmazzeo 13:61131aac4031 175 /* Capture the timing of the first half processing */
bmazzeo 9:f5b37c71856d 176 first_half_time = timer.read_us();
bmazzeo 13:61131aac4031 177 /* End First Half */
bmazzeo 8:d1c41eca57f0 178
bmazzeo 6:e689075b04ed 179 /* Second Half */
adustm 0:da04816fb411 180 /* Wait end of one block recording */
bmazzeo 11:4256dbbb0c89 181 while (audio_rec_buffer_state != BUFFER_OFFSET_FULL) {}
bmazzeo 9:f5b37c71856d 182
bmazzeo 13:61131aac4031 183 /* Plot traces of second half block recording */
bmazzeo 19:479f611941a8 184 Erase_Trace(OSC_START_X_POS+AUDIO_BLOCK_SAMPLES, OSC_Y_POS, AUDIO_BLOCK_SAMPLES);
bmazzeo 19:479f611941a8 185 Draw_Trace( OSC_START_X_POS+AUDIO_BLOCK_SAMPLES, OSC_Y_POS, (uint16_t *) (AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE)), AUDIO_BLOCK_SAMPLES);
bmazzeo 22:f36d7a53bb7e 186
bmazzeo 22:f36d7a53bb7e 187 /* Convert data to floating point representation for processing */
bmazzeo 22:f36d7a53bb7e 188 Audio_to_Float((uint16_t *) (AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE)), L_channel_float_p, R_channel_float_p, AUDIO_BLOCK_SAMPLES);
bmazzeo 22:f36d7a53bb7e 189
bmazzeo 30:debea332cdfe 190 /* ------------------------------------------------------------------------ */
bmazzeo 30:debea332cdfe 191 /* Here is where signal processing can be done on the floating point arrays */
bmazzeo 22:f36d7a53bb7e 192
bmazzeo 30:debea332cdfe 193 process_audio_channel_signals(L_channel_float_p, R_channel_float_p, AUDIO_BLOCK_SAMPLES);
bmazzeo 22:f36d7a53bb7e 194
bmazzeo 30:debea332cdfe 195 /* Here is where signal processing can end on the floating point arrays */
bmazzeo 30:debea332cdfe 196 /* -------------------------------------------------------------------- */
bmazzeo 30:debea332cdfe 197
bmazzeo 22:f36d7a53bb7e 198 /* Covert floating point data back to fixed point audio format */
bmazzeo 22:f36d7a53bb7e 199 Float_to_Audio(L_channel_float_p, R_channel_float_p, (uint16_t *) Processed_audio, AUDIO_BLOCK_SAMPLES);
bmazzeo 22:f36d7a53bb7e 200
bmazzeo 22:f36d7a53bb7e 201 /* Copy recorded 2nd half block into the audio buffer that goes out */
bmazzeo 31:5a0235b66851 202 //memcpy((uint16_t *)(AUDIO_BUFFER_OUT + (AUDIO_BLOCK_SIZE)), (uint16_t *) (Processed_audio), AUDIO_BLOCK_SIZE);
bmazzeo 31:5a0235b66851 203 memcpy((uint16_t *)(AUDIO_BUFFER_OUT + (AUDIO_BLOCK_SIZE)), (uint16_t *)(AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE)), AUDIO_BLOCK_SIZE);
bmazzeo 31:5a0235b66851 204
bmazzeo 13:61131aac4031 205
bmazzeo 13:61131aac4031 206 /* Compute important cycle information and display it*/
bmazzeo 26:023edf8cea6c 207 sprintf(buf, "1:%6d 2:%6d T:%6d", first_half_time, second_half_time, total_time);
bmazzeo 6:e689075b04ed 208 BSP_LCD_SetTextColor(LCD_COLOR_RED);
bmazzeo 10:a82b64ea1d11 209 BSP_LCD_DisplayStringAt(0, 20, (uint8_t *) buf, LEFT_MODE);
bmazzeo 13:61131aac4031 210
bmazzeo 13:61131aac4031 211 /* Copy recorded 2nd half block into audio output buffer */
bmazzeo 18:255d15af49f2 212
bmazzeo 13:61131aac4031 213 /* Change the recording buffer state to reflect the status of the buffer */
bmazzeo 13:61131aac4031 214 audio_rec_buffer_state = BUFFER_OFFSET_NONE;
bmazzeo 26:023edf8cea6c 215
bmazzeo 26:023edf8cea6c 216 /* Increase the counter */
bmazzeo 26:023edf8cea6c 217 counter++;
bmazzeo 9:f5b37c71856d 218
bmazzeo 13:61131aac4031 219 /* Measures the amount of time to process the second half */
bmazzeo 9:f5b37c71856d 220 second_half_time = timer.read_us();
bmazzeo 9:f5b37c71856d 221
bmazzeo 13:61131aac4031 222 /* End Second Half */
adustm 0:da04816fb411 223 }
adustm 0:da04816fb411 224 }
Jerome Coutant 5:66c230f74325 225
bmazzeo 7:e1dfd64eba81 226 /**
bmazzeo 7:e1dfd64eba81 227 * @brief Draws a trace of the data line.
bmazzeo 7:e1dfd64eba81 228 * @param Xpos: X position
bmazzeo 7:e1dfd64eba81 229 * @param L_Ypos: Left channel Y position
bmazzeo 7:e1dfd64eba81 230 * @param R_Ypos: Right channel Y position
bmazzeo 7:e1dfd64eba81 231 * @param Mem_start: Start of memory location
bmazzeo 7:e1dfd64eba81 232 * @param Length: length of trace
bmazzeo 7:e1dfd64eba81 233 * @retval None
bmazzeo 7:e1dfd64eba81 234 */
bmazzeo 17:eb85a2387dd4 235 void Erase_Trace(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
bmazzeo 7:e1dfd64eba81 236 {
bmazzeo 7:e1dfd64eba81 237 }
bmazzeo 7:e1dfd64eba81 238
Jerome Coutant 5:66c230f74325 239
bmazzeo 6:e689075b04ed 240 /**
bmazzeo 6:e689075b04ed 241 * @brief Draws a trace of the data line.
bmazzeo 6:e689075b04ed 242 * @param Xpos: X position
bmazzeo 7:e1dfd64eba81 243 * @param L_Ypos: Left channel Y position
bmazzeo 7:e1dfd64eba81 244 * @param R_Ypos: Right channel Y position
bmazzeo 6:e689075b04ed 245 * @param Mem_start: Start of memory location
bmazzeo 6:e689075b04ed 246 * @param Length: length of trace
bmazzeo 6:e689075b04ed 247 * @retval None
bmazzeo 6:e689075b04ed 248 */
bmazzeo 17:eb85a2387dd4 249 void Draw_Trace(uint16_t Xpos, uint16_t Ypos, uint16_t* Mem_start, uint16_t Length)
bmazzeo 6:e689075b04ed 250 {
bmazzeo 6:e689075b04ed 251 }
bmazzeo 14:18f159d48340 252
bmazzeo 14:18f159d48340 253 /**
bmazzeo 14:18f159d48340 254 * @brief Converts audio data in buffer to floating point representation.
bmazzeo 14:18f159d48340 255 * @param buffer_in: Pointer to Audio buffer start location
bmazzeo 14:18f159d48340 256 * @param L_out: Pointer to Left channel out data (float)
bmazzeo 14:18f159d48340 257 * @param R_out: Pointer to Right channel out data (float)
bmazzeo 14:18f159d48340 258 * @param Length: length of data to convert
bmazzeo 14:18f159d48340 259 * @retval None
bmazzeo 14:18f159d48340 260 */
bmazzeo 16:b7dca59ab076 261 void Audio_to_Float(uint16_t* buffer_in, float* L_out, float* R_out, uint16_t Length)
bmazzeo 14:18f159d48340 262 {
bmazzeo 14:18f159d48340 263 }
bmazzeo 14:18f159d48340 264
bmazzeo 14:18f159d48340 265 /**
bmazzeo 14:18f159d48340 266 * @brief Converts audio data in buffer to floating point representation.
bmazzeo 14:18f159d48340 267 * @param L_out: Pointer to Left channel in data (float)
bmazzeo 14:18f159d48340 268 * @param R_out: Pointer to Right channel in data (float)
bmazzeo 14:18f159d48340 269 * @param buffer_out: Pointer to combined 32 bit (two 16-bit int samples)
bmazzeo 14:18f159d48340 270 * @param Length: length of data to convert
bmazzeo 14:18f159d48340 271 * @retval None
bmazzeo 14:18f159d48340 272 */
bmazzeo 16:b7dca59ab076 273 void Float_to_Audio(float* L_in, float* R_in, uint16_t* buffer_out, uint16_t Length)
bmazzeo 14:18f159d48340 274 {
bmazzeo 14:18f159d48340 275 }
bmazzeo 14:18f159d48340 276
bmazzeo 14:18f159d48340 277
bmazzeo 14:18f159d48340 278
bmazzeo 6:e689075b04ed 279
bmazzeo 6:e689075b04ed 280
adustm 0:da04816fb411 281 /*-------------------------------------------------------------------------------------
adustm 0:da04816fb411 282 Callbacks implementation:
adustm 0:da04816fb411 283 the callbacks API are defined __weak in the stm32746g_discovery_audio.c file
adustm 0:da04816fb411 284 and their implementation should be done in the user code if they are needed.
adustm 0:da04816fb411 285 Below some examples of callback implementations.
adustm 0:da04816fb411 286 -------------------------------------------------------------------------------------*/
adustm 0:da04816fb411 287 /**
adustm 0:da04816fb411 288 * @brief Manages the DMA Transfer complete interrupt.
adustm 0:da04816fb411 289 * @param None
adustm 0:da04816fb411 290 * @retval None
adustm 0:da04816fb411 291 */
adustm 0:da04816fb411 292 void BSP_AUDIO_IN_TransferComplete_CallBack(void)
adustm 0:da04816fb411 293 {
Jerome Coutant 5:66c230f74325 294 audio_rec_buffer_state = BUFFER_OFFSET_FULL;
adustm 0:da04816fb411 295 }
adustm 0:da04816fb411 296
adustm 0:da04816fb411 297 /**
adustm 0:da04816fb411 298 * @brief Manages the DMA Half Transfer complete interrupt.
adustm 0:da04816fb411 299 * @param None
adustm 0:da04816fb411 300 * @retval None
adustm 0:da04816fb411 301 */
adustm 0:da04816fb411 302 void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
adustm 0:da04816fb411 303 {
Jerome Coutant 5:66c230f74325 304 audio_rec_buffer_state = BUFFER_OFFSET_HALF;
adustm 0:da04816fb411 305 }
adustm 0:da04816fb411 306
Jerome Coutant 5:66c230f74325 307 /**
Jerome Coutant 5:66c230f74325 308 * @brief Audio IN Error callback function.
Jerome Coutant 5:66c230f74325 309 * @param None
Jerome Coutant 5:66c230f74325 310 * @retval None
Jerome Coutant 5:66c230f74325 311 */
Jerome Coutant 5:66c230f74325 312 void BSP_AUDIO_IN_Error_CallBack(void)
adustm 0:da04816fb411 313 {
Jerome Coutant 5:66c230f74325 314 printf("BSP_AUDIO_IN_Error_CallBack\n");
adustm 0:da04816fb411 315 }