AudioRecord and FFT/MSE comparison. Call AudioRecord_demo for control record and AudioSample for subsequent recordings.
Dependencies: CMSIS_DSP_401 STM32L4xx_HAL_Driver
Fork of OneHopeOnePrayer by
stm32l4xx_nucleo_audio.h@5:f6afbd3fc47a, 2015-12-05 (annotated)
- Committer:
- EricLew
- Date:
- Sat Dec 05 16:17:25 2015 +0000
- Revision:
- 5:f6afbd3fc47a
Ported to Nucleo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EricLew | 5:f6afbd3fc47a | 1 | /** |
EricLew | 5:f6afbd3fc47a | 2 | ****************************************************************************** |
EricLew | 5:f6afbd3fc47a | 3 | * @file stm32l4xx_nucleo_audio.h |
EricLew | 5:f6afbd3fc47a | 4 | * @author MCD Application Team |
EricLew | 5:f6afbd3fc47a | 5 | * @version V1.0.1 |
EricLew | 5:f6afbd3fc47a | 6 | * @date 16-September-2015 |
EricLew | 5:f6afbd3fc47a | 7 | * @brief This file contains the common defines and functions prototypes for |
EricLew | 5:f6afbd3fc47a | 8 | * the stm32l4xx_nucleo_audio.c driver. |
EricLew | 5:f6afbd3fc47a | 9 | ****************************************************************************** |
EricLew | 5:f6afbd3fc47a | 10 | * @attention |
EricLew | 5:f6afbd3fc47a | 11 | * |
EricLew | 5:f6afbd3fc47a | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
EricLew | 5:f6afbd3fc47a | 13 | * |
EricLew | 5:f6afbd3fc47a | 14 | * Redistribution and use in source and binary forms, with or without modification, |
EricLew | 5:f6afbd3fc47a | 15 | * are permitted provided that the following conditions are met: |
EricLew | 5:f6afbd3fc47a | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
EricLew | 5:f6afbd3fc47a | 17 | * this list of conditions and the following disclaimer. |
EricLew | 5:f6afbd3fc47a | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
EricLew | 5:f6afbd3fc47a | 19 | * this list of conditions and the following disclaimer in the documentation |
EricLew | 5:f6afbd3fc47a | 20 | * and/or other materials provided with the distribution. |
EricLew | 5:f6afbd3fc47a | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
EricLew | 5:f6afbd3fc47a | 22 | * may be used to endorse or promote products derived from this software |
EricLew | 5:f6afbd3fc47a | 23 | * without specific prior written permission. |
EricLew | 5:f6afbd3fc47a | 24 | * |
EricLew | 5:f6afbd3fc47a | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
EricLew | 5:f6afbd3fc47a | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
EricLew | 5:f6afbd3fc47a | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
EricLew | 5:f6afbd3fc47a | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
EricLew | 5:f6afbd3fc47a | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
EricLew | 5:f6afbd3fc47a | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
EricLew | 5:f6afbd3fc47a | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
EricLew | 5:f6afbd3fc47a | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
EricLew | 5:f6afbd3fc47a | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
EricLew | 5:f6afbd3fc47a | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
EricLew | 5:f6afbd3fc47a | 35 | * |
EricLew | 5:f6afbd3fc47a | 36 | ****************************************************************************** |
EricLew | 5:f6afbd3fc47a | 37 | */ |
EricLew | 5:f6afbd3fc47a | 38 | |
EricLew | 5:f6afbd3fc47a | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
EricLew | 5:f6afbd3fc47a | 40 | #ifndef __STM32L476G_NUCLEO_AUDIO_H |
EricLew | 5:f6afbd3fc47a | 41 | #define __STM32L476G_NUCLEO_AUDIO_H |
EricLew | 5:f6afbd3fc47a | 42 | |
EricLew | 5:f6afbd3fc47a | 43 | #ifdef __cplusplus |
EricLew | 5:f6afbd3fc47a | 44 | extern "C" { |
EricLew | 5:f6afbd3fc47a | 45 | #endif |
EricLew | 5:f6afbd3fc47a | 46 | |
EricLew | 5:f6afbd3fc47a | 47 | /* Includes ------------------------------------------------------------------*/ |
EricLew | 5:f6afbd3fc47a | 48 | #if defined(BSP_AUDIO_USE_RTOS) |
EricLew | 5:f6afbd3fc47a | 49 | #include "k_mem.h" |
EricLew | 5:f6afbd3fc47a | 50 | #else |
EricLew | 5:f6afbd3fc47a | 51 | #include <stdlib.h> |
EricLew | 5:f6afbd3fc47a | 52 | #endif |
EricLew | 5:f6afbd3fc47a | 53 | /* Include audio component Driver */ |
EricLew | 5:f6afbd3fc47a | 54 | //#include "cs43l22.h" |
EricLew | 5:f6afbd3fc47a | 55 | #include "stm32l4xx_nucleo.h" |
EricLew | 5:f6afbd3fc47a | 56 | |
EricLew | 5:f6afbd3fc47a | 57 | /** @addtogroup BSP |
EricLew | 5:f6afbd3fc47a | 58 | * @{ |
EricLew | 5:f6afbd3fc47a | 59 | */ |
EricLew | 5:f6afbd3fc47a | 60 | |
EricLew | 5:f6afbd3fc47a | 61 | /** @addtogroup STM32L476G_NUCLEO |
EricLew | 5:f6afbd3fc47a | 62 | * @{ |
EricLew | 5:f6afbd3fc47a | 63 | */ |
EricLew | 5:f6afbd3fc47a | 64 | |
EricLew | 5:f6afbd3fc47a | 65 | /** @addtogroup STM32L476G_NUCLEO_AUDIO |
EricLew | 5:f6afbd3fc47a | 66 | * @{ |
EricLew | 5:f6afbd3fc47a | 67 | */ |
EricLew | 5:f6afbd3fc47a | 68 | |
EricLew | 5:f6afbd3fc47a | 69 | /** @defgroup STM32L476G_NUCLEO_AUDIO_Exported_Types Exported Types |
EricLew | 5:f6afbd3fc47a | 70 | * @{ |
EricLew | 5:f6afbd3fc47a | 71 | */ |
EricLew | 5:f6afbd3fc47a | 72 | typedef void (*Audio_CallbackTypeDef)(void); |
EricLew | 5:f6afbd3fc47a | 73 | |
EricLew | 5:f6afbd3fc47a | 74 | /** |
EricLew | 5:f6afbd3fc47a | 75 | * @} |
EricLew | 5:f6afbd3fc47a | 76 | */ |
EricLew | 5:f6afbd3fc47a | 77 | |
EricLew | 5:f6afbd3fc47a | 78 | /* AUDIO FREQUENCY */ |
EricLew | 5:f6afbd3fc47a | 79 | #define AUDIO_FREQUENCY_192K ((uint32_t)192000) |
EricLew | 5:f6afbd3fc47a | 80 | #define AUDIO_FREQUENCY_96K ((uint32_t)96000) |
EricLew | 5:f6afbd3fc47a | 81 | #define AUDIO_FREQUENCY_48K ((uint32_t)48000) |
EricLew | 5:f6afbd3fc47a | 82 | #define AUDIO_FREQUENCY_44K ((uint32_t)44100) |
EricLew | 5:f6afbd3fc47a | 83 | #define AUDIO_FREQUENCY_32K ((uint32_t)32000) |
EricLew | 5:f6afbd3fc47a | 84 | #define AUDIO_FREQUENCY_22K ((uint32_t)22050) |
EricLew | 5:f6afbd3fc47a | 85 | #define AUDIO_FREQUENCY_16K ((uint32_t)16000) |
EricLew | 5:f6afbd3fc47a | 86 | #define AUDIO_FREQUENCY_11K ((uint32_t)11025) |
EricLew | 5:f6afbd3fc47a | 87 | #define AUDIO_FREQUENCY_8K ((uint32_t)8000) |
EricLew | 5:f6afbd3fc47a | 88 | |
EricLew | 5:f6afbd3fc47a | 89 | /** @defgroup STM32L476G_NUCLEO_AUDIO_Exported_Constants Exported Constants |
EricLew | 5:f6afbd3fc47a | 90 | * @{ |
EricLew | 5:f6afbd3fc47a | 91 | */ |
EricLew | 5:f6afbd3fc47a | 92 | /** @defgroup BSP_Audio_Out_Option BSP Audio Out Option |
EricLew | 5:f6afbd3fc47a | 93 | * @{ |
EricLew | 5:f6afbd3fc47a | 94 | */ |
EricLew | 5:f6afbd3fc47a | 95 | #define BSP_AUDIO_OUT_CIRCULARMODE ((uint32_t)0x00000001) /* BUFFER CIRCULAR MODE */ |
EricLew | 5:f6afbd3fc47a | 96 | #define BSP_AUDIO_OUT_NORMALMODE ((uint32_t)0x00000002) /* BUFFER NORMAL MODE */ |
EricLew | 5:f6afbd3fc47a | 97 | #define BSP_AUDIO_OUT_STEREOMODE ((uint32_t)0x00000004) /* STEREO MODE */ |
EricLew | 5:f6afbd3fc47a | 98 | #define BSP_AUDIO_OUT_MONOMODE ((uint32_t)0x00000008) /* MONO MODE */ |
EricLew | 5:f6afbd3fc47a | 99 | /** |
EricLew | 5:f6afbd3fc47a | 100 | * @} |
EricLew | 5:f6afbd3fc47a | 101 | */ |
EricLew | 5:f6afbd3fc47a | 102 | |
EricLew | 5:f6afbd3fc47a | 103 | /** @defgroup BSP_Audio_Sample_Rate BSP Audio Sample Rate |
EricLew | 5:f6afbd3fc47a | 104 | * @{ |
EricLew | 5:f6afbd3fc47a | 105 | */ |
EricLew | 5:f6afbd3fc47a | 106 | #define BSP_AUDIO_FREQUENCY_96K SAI_AUDIO_FREQUENCY_96K |
EricLew | 5:f6afbd3fc47a | 107 | #define BSP_AUDIO_FREQUENCY_48K SAI_AUDIO_FREQUENCY_48K |
EricLew | 5:f6afbd3fc47a | 108 | #define BSP_AUDIO_FREQUENCY_44K SAI_AUDIO_FREQUENCY_44K |
EricLew | 5:f6afbd3fc47a | 109 | #define BSP_AUDIO_FREQUENCY_32K SAI_AUDIO_FREQUENCY_32K |
EricLew | 5:f6afbd3fc47a | 110 | #define BSP_AUDIO_FREQUENCY_22K SAI_AUDIO_FREQUENCY_22K |
EricLew | 5:f6afbd3fc47a | 111 | #define BSP_AUDIO_FREQUENCY_16K SAI_AUDIO_FREQUENCY_16K |
EricLew | 5:f6afbd3fc47a | 112 | #define BSP_AUDIO_FREQUENCY_11K SAI_AUDIO_FREQUENCY_11K |
EricLew | 5:f6afbd3fc47a | 113 | #define BSP_AUDIO_FREQUENCY_8K SAI_AUDIO_FREQUENCY_8K |
EricLew | 5:f6afbd3fc47a | 114 | /** |
EricLew | 5:f6afbd3fc47a | 115 | * @} |
EricLew | 5:f6afbd3fc47a | 116 | */ |
EricLew | 5:f6afbd3fc47a | 117 | /*------------------------------------------------------------------------------ |
EricLew | 5:f6afbd3fc47a | 118 | USER SAI defines parameters |
EricLew | 5:f6afbd3fc47a | 119 | -----------------------------------------------------------------------------*/ |
EricLew | 5:f6afbd3fc47a | 120 | /* SAI peripheral configuration defines */ |
EricLew | 5:f6afbd3fc47a | 121 | #define AUDIO_SAIx SAI1_Block_A |
EricLew | 5:f6afbd3fc47a | 122 | #define AUDIO_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE() |
EricLew | 5:f6afbd3fc47a | 123 | #define AUDIO_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE() |
EricLew | 5:f6afbd3fc47a | 124 | #define AUDIO_SAIx_MCK_SCK_SD_FS_AF GPIO_AF13_SAI1 |
EricLew | 5:f6afbd3fc47a | 125 | |
EricLew | 5:f6afbd3fc47a | 126 | #define AUDIO_SAIx_MCK_SCK_SD_FS_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() |
EricLew | 5:f6afbd3fc47a | 127 | #define AUDIO_SAIx_MCK_SCK_SD_FS_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() |
EricLew | 5:f6afbd3fc47a | 128 | #define AUDIO_SAIx_FS_PIN GPIO_PIN_4 |
EricLew | 5:f6afbd3fc47a | 129 | #define AUDIO_SAIx_SCK_PIN GPIO_PIN_5 |
EricLew | 5:f6afbd3fc47a | 130 | #define AUDIO_SAIx_SD_PIN GPIO_PIN_6 |
EricLew | 5:f6afbd3fc47a | 131 | #define AUDIO_SAIx_MCK_PIN GPIO_PIN_2 |
EricLew | 5:f6afbd3fc47a | 132 | #define AUDIO_SAIx_MCK_SCK_SD_FS_GPIO_PORT GPIOE |
EricLew | 5:f6afbd3fc47a | 133 | |
EricLew | 5:f6afbd3fc47a | 134 | /* SAI DMA Channel definitions */ |
EricLew | 5:f6afbd3fc47a | 135 | #define AUDIO_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE() |
EricLew | 5:f6afbd3fc47a | 136 | #define AUDIO_SAIx_DMAx_CLK_DISABLE() __HAL_RCC_DMA2_CLK_DISABLE() |
EricLew | 5:f6afbd3fc47a | 137 | #define AUDIO_SAIx_DMAx_CHANNEL DMA2_Channel1 |
EricLew | 5:f6afbd3fc47a | 138 | #define AUDIO_SAIx_DMAx_IRQ DMA2_Channel1_IRQn |
EricLew | 5:f6afbd3fc47a | 139 | #define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD |
EricLew | 5:f6afbd3fc47a | 140 | #define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD |
EricLew | 5:f6afbd3fc47a | 141 | #define DMA_MAX_SZE (uint32_t)0xFFFF |
EricLew | 5:f6afbd3fc47a | 142 | |
EricLew | 5:f6afbd3fc47a | 143 | #define AUDIO_SAIx_DMAx_IRQHandler DMA2_Channel1_IRQHandler |
EricLew | 5:f6afbd3fc47a | 144 | |
EricLew | 5:f6afbd3fc47a | 145 | /* Select the interrupt preemption priority for the DMA interrupt */ |
EricLew | 5:f6afbd3fc47a | 146 | #define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */ |
EricLew | 5:f6afbd3fc47a | 147 | |
EricLew | 5:f6afbd3fc47a | 148 | /* Disable SAIx PLL */ |
EricLew | 5:f6afbd3fc47a | 149 | #define AUDIO_SAIx_PLL_DISABLE() HAL_RCCEx_DisablePLLSAI1() |
EricLew | 5:f6afbd3fc47a | 150 | |
EricLew | 5:f6afbd3fc47a | 151 | /*------------------------------------------------------------------------------ |
EricLew | 5:f6afbd3fc47a | 152 | AUDIO IN CONFIGURATION |
EricLew | 5:f6afbd3fc47a | 153 | ------------------------------------------------------------------------------*/ |
EricLew | 5:f6afbd3fc47a | 154 | /* DFSDM Configuration defines */ |
EricLew | 5:f6afbd3fc47a | 155 | #define AUDIO_DFSDMx_LEFT_CHANNEL DFSDM_Channel2 |
EricLew | 5:f6afbd3fc47a | 156 | #define AUDIO_DFSDMx_LEFT_FILTER DFSDM_Filter0 |
EricLew | 5:f6afbd3fc47a | 157 | #define AUDIO_DFSDMx_CLK_ENABLE() __HAL_RCC_DFSDM_CLK_ENABLE() |
EricLew | 5:f6afbd3fc47a | 158 | #define AUDIO_DFSDMx_CLK_DISABLE() __HAL_RCC_DFSDM_CLK_DISABLE() |
EricLew | 5:f6afbd3fc47a | 159 | #define AUDIO_DFSDMx_CKOUT_PIN GPIO_PIN_9 |
EricLew | 5:f6afbd3fc47a | 160 | #define AUDIO_DFSDMx_DMIC_DATIN_PIN GPIO_PIN_7 |
EricLew | 5:f6afbd3fc47a | 161 | #define AUDIO_DFSDMx_CKOUT_DMIC_DATIN_GPIO_PORT GPIOE |
EricLew | 5:f6afbd3fc47a | 162 | #define AUDIO_DFSDMx_CKOUT_DMIC_DATIN_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() |
EricLew | 5:f6afbd3fc47a | 163 | #define AUDIO_DFSDMx_CKOUT_DMIC_DATIN_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() |
EricLew | 5:f6afbd3fc47a | 164 | #define AUDIO_DFSDMx_CKOUT_DMIC_DATIN_AF GPIO_AF6_DFSDM |
EricLew | 5:f6afbd3fc47a | 165 | |
EricLew | 5:f6afbd3fc47a | 166 | /* DFSDM DMA Right and Left channels definitions */ |
EricLew | 5:f6afbd3fc47a | 167 | #define AUDIO_DFSDMx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() |
EricLew | 5:f6afbd3fc47a | 168 | #define AUDIO_DFSDMx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE() |
EricLew | 5:f6afbd3fc47a | 169 | #define AUDIO_DFSDMx_DMAx_LEFT_CHANNEL DMA1_Channel4 |
EricLew | 5:f6afbd3fc47a | 170 | #define AUDIO_DFSDMx_DMAx_LEFT_IRQ DMA1_Channel4_IRQn |
EricLew | 5:f6afbd3fc47a | 171 | #define AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_WORD |
EricLew | 5:f6afbd3fc47a | 172 | #define AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_WORD |
EricLew | 5:f6afbd3fc47a | 173 | |
EricLew | 5:f6afbd3fc47a | 174 | #define AUDIO_DFSDM_DMAx_LEFT_IRQHandler DMA1_Channel4_IRQHandler |
EricLew | 5:f6afbd3fc47a | 175 | |
EricLew | 5:f6afbd3fc47a | 176 | /* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ |
EricLew | 5:f6afbd3fc47a | 177 | #define AUDIO_IN_IRQ_PREPRIO 6 /* Select the preemption priority level(0 is the highest) */ |
EricLew | 5:f6afbd3fc47a | 178 | |
EricLew | 5:f6afbd3fc47a | 179 | /*------------------------------------------------------------------------------ |
EricLew | 5:f6afbd3fc47a | 180 | CONFIGURATION: Audio Driver Configuration parameters |
EricLew | 5:f6afbd3fc47a | 181 | ------------------------------------------------------------------------------*/ |
EricLew | 5:f6afbd3fc47a | 182 | |
EricLew | 5:f6afbd3fc47a | 183 | #define AUDIODATA_SIZE 2 /* 16-bits audio data size */ |
EricLew | 5:f6afbd3fc47a | 184 | |
EricLew | 5:f6afbd3fc47a | 185 | /* Audio status definition */ |
EricLew | 5:f6afbd3fc47a | 186 | #define AUDIO_OK 0 |
EricLew | 5:f6afbd3fc47a | 187 | #define AUDIO_ERROR 1 |
EricLew | 5:f6afbd3fc47a | 188 | #define AUDIO_TIMEOUT 2 |
EricLew | 5:f6afbd3fc47a | 189 | |
EricLew | 5:f6afbd3fc47a | 190 | /* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ |
EricLew | 5:f6afbd3fc47a | 191 | #define DEFAULT_AUDIO_IN_FREQ BSP_AUDIO_FREQUENCY_16K |
EricLew | 5:f6afbd3fc47a | 192 | #define DEFAULT_AUDIO_IN_BIT_RESOLUTION 16 |
EricLew | 5:f6afbd3fc47a | 193 | #define DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */ |
EricLew | 5:f6afbd3fc47a | 194 | #define DEFAULT_AUDIO_IN_VOLUME 64 |
EricLew | 5:f6afbd3fc47a | 195 | |
EricLew | 5:f6afbd3fc47a | 196 | /*------------------------------------------------------------------------------ |
EricLew | 5:f6afbd3fc47a | 197 | OPTIONAL Configuration defines parameters |
EricLew | 5:f6afbd3fc47a | 198 | ------------------------------------------------------------------------------*/ |
EricLew | 5:f6afbd3fc47a | 199 | |
EricLew | 5:f6afbd3fc47a | 200 | /* Delay for the Codec to be correctly reset */ |
EricLew | 5:f6afbd3fc47a | 201 | #define CODEC_RESET_DELAY 5 |
EricLew | 5:f6afbd3fc47a | 202 | |
EricLew | 5:f6afbd3fc47a | 203 | /** |
EricLew | 5:f6afbd3fc47a | 204 | * @} |
EricLew | 5:f6afbd3fc47a | 205 | */ |
EricLew | 5:f6afbd3fc47a | 206 | |
EricLew | 5:f6afbd3fc47a | 207 | /** @defgroup STM32L476G_NUCLEO_AUDIO_Exported_Variables Exported Variables |
EricLew | 5:f6afbd3fc47a | 208 | * @{ |
EricLew | 5:f6afbd3fc47a | 209 | */ |
EricLew | 5:f6afbd3fc47a | 210 | extern SAI_HandleTypeDef BSP_AUDIO_hSai; |
EricLew | 5:f6afbd3fc47a | 211 | extern DFSDM_Filter_HandleTypeDef BSP_AUDIO_hDfsdmLeftFilter; |
EricLew | 5:f6afbd3fc47a | 212 | |
EricLew | 5:f6afbd3fc47a | 213 | /** |
EricLew | 5:f6afbd3fc47a | 214 | * @} |
EricLew | 5:f6afbd3fc47a | 215 | */ |
EricLew | 5:f6afbd3fc47a | 216 | |
EricLew | 5:f6afbd3fc47a | 217 | /** @defgroup STM32L476G_NUCLEO_AUDIO_Exported_Macros Exported Macros |
EricLew | 5:f6afbd3fc47a | 218 | * @{ |
EricLew | 5:f6afbd3fc47a | 219 | */ |
EricLew | 5:f6afbd3fc47a | 220 | #define DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE) |
EricLew | 5:f6afbd3fc47a | 221 | |
EricLew | 5:f6afbd3fc47a | 222 | /** |
EricLew | 5:f6afbd3fc47a | 223 | * @} |
EricLew | 5:f6afbd3fc47a | 224 | */ |
EricLew | 5:f6afbd3fc47a | 225 | |
EricLew | 5:f6afbd3fc47a | 226 | /* Exported functions --------------------------------------------------------*/ |
EricLew | 5:f6afbd3fc47a | 227 | /** @defgroup STM32L476G_NUCLEO_AUDIO_Exported_Functions Exported Functions |
EricLew | 5:f6afbd3fc47a | 228 | * @{ |
EricLew | 5:f6afbd3fc47a | 229 | */ |
EricLew | 5:f6afbd3fc47a | 230 | uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); |
EricLew | 5:f6afbd3fc47a | 231 | uint8_t BSP_AUDIO_OUT_DeInit(void); |
EricLew | 5:f6afbd3fc47a | 232 | uint8_t BSP_AUDIO_OUT_Play(uint16_t* pData, uint32_t Size); |
EricLew | 5:f6afbd3fc47a | 233 | uint8_t BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); |
EricLew | 5:f6afbd3fc47a | 234 | uint8_t BSP_AUDIO_OUT_Pause(void); |
EricLew | 5:f6afbd3fc47a | 235 | uint8_t BSP_AUDIO_OUT_Resume(void); |
EricLew | 5:f6afbd3fc47a | 236 | uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); |
EricLew | 5:f6afbd3fc47a | 237 | uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); |
EricLew | 5:f6afbd3fc47a | 238 | uint8_t BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); |
EricLew | 5:f6afbd3fc47a | 239 | void BSP_AUDIO_OUT_ChangeAudioConfig(uint32_t AudioOutOption); |
EricLew | 5:f6afbd3fc47a | 240 | uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); |
EricLew | 5:f6afbd3fc47a | 241 | uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); |
EricLew | 5:f6afbd3fc47a | 242 | void BSP_AUDIO_OUT_RegisterCallbacks(Audio_CallbackTypeDef ErrorCallback, |
EricLew | 5:f6afbd3fc47a | 243 | Audio_CallbackTypeDef HalfTransferCallback, |
EricLew | 5:f6afbd3fc47a | 244 | Audio_CallbackTypeDef TransferCompleteCallback); |
EricLew | 5:f6afbd3fc47a | 245 | |
EricLew | 5:f6afbd3fc47a | 246 | uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); |
EricLew | 5:f6afbd3fc47a | 247 | uint8_t BSP_AUDIO_IN_DeInit(void); |
EricLew | 5:f6afbd3fc47a | 248 | uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); |
EricLew | 5:f6afbd3fc47a | 249 | uint8_t BSP_AUDIO_IN_SetFrequency(uint32_t AudioFreq); |
EricLew | 5:f6afbd3fc47a | 250 | uint8_t BSP_AUDIO_IN_Stop(void); |
EricLew | 5:f6afbd3fc47a | 251 | uint8_t BSP_AUDIO_IN_Pause(void); |
EricLew | 5:f6afbd3fc47a | 252 | uint8_t BSP_AUDIO_IN_Resume(void); |
EricLew | 5:f6afbd3fc47a | 253 | void BSP_AUDIO_IN_RegisterCallbacks(Audio_CallbackTypeDef ErrorCallback, |
EricLew | 5:f6afbd3fc47a | 254 | Audio_CallbackTypeDef HalfTransferCallback, |
EricLew | 5:f6afbd3fc47a | 255 | Audio_CallbackTypeDef TransferCompleteCallback); |
EricLew | 5:f6afbd3fc47a | 256 | /** |
EricLew | 5:f6afbd3fc47a | 257 | * @} |
EricLew | 5:f6afbd3fc47a | 258 | */ |
EricLew | 5:f6afbd3fc47a | 259 | |
EricLew | 5:f6afbd3fc47a | 260 | /** |
EricLew | 5:f6afbd3fc47a | 261 | * @} |
EricLew | 5:f6afbd3fc47a | 262 | */ |
EricLew | 5:f6afbd3fc47a | 263 | |
EricLew | 5:f6afbd3fc47a | 264 | /** |
EricLew | 5:f6afbd3fc47a | 265 | * @} |
EricLew | 5:f6afbd3fc47a | 266 | */ |
EricLew | 5:f6afbd3fc47a | 267 | |
EricLew | 5:f6afbd3fc47a | 268 | /** |
EricLew | 5:f6afbd3fc47a | 269 | * @} |
EricLew | 5:f6afbd3fc47a | 270 | */ |
EricLew | 5:f6afbd3fc47a | 271 | |
EricLew | 5:f6afbd3fc47a | 272 | #ifdef __cplusplus |
EricLew | 5:f6afbd3fc47a | 273 | } |
EricLew | 5:f6afbd3fc47a | 274 | #endif |
EricLew | 5:f6afbd3fc47a | 275 | |
EricLew | 5:f6afbd3fc47a | 276 | #endif /* __STM32L476G_NUCLEO_AUDIO_H */ |
EricLew | 5:f6afbd3fc47a | 277 | |
EricLew | 5:f6afbd3fc47a | 278 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
EricLew | 5:f6afbd3fc47a | 279 |