Patched for Audio example - Add status check when DFSDM's filter and channel de-init.
Dependents: DISCO_F413ZH-AUDIO-demo
The base repository is https://os.mbed.com/teams/ST/code/BSP_DISCO_F413ZH/. I've just added workaround patch for Audio-in demo on DISCO_F413ZH board(Microphone U16, U17)
Drivers/BSP/STM32F413H-Discovery/stm32f413h_discovery_audio.h@4:c051317d4051, 2020-01-31 (annotated)
- Committer:
- Daniel_Lee
- Date:
- Fri Jan 31 07:17:05 2020 +0000
- Revision:
- 4:c051317d4051
- Parent:
- 3:42b354f5069c
Patched for Audio example;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
arostm | 0:4af3ca173992 | 1 | /** |
arostm | 0:4af3ca173992 | 2 | ****************************************************************************** |
arostm | 0:4af3ca173992 | 3 | * @file stm32f413h_discovery_audio.h |
arostm | 0:4af3ca173992 | 4 | * @author MCD Application Team |
arostm | 0:4af3ca173992 | 5 | * @brief This file contains the common defines and functions prototypes for |
arostm | 0:4af3ca173992 | 6 | * the stm32f413h_discovery_audio.c driver. |
arostm | 0:4af3ca173992 | 7 | ****************************************************************************** |
arostm | 0:4af3ca173992 | 8 | * @attention |
arostm | 0:4af3ca173992 | 9 | * |
arostm | 0:4af3ca173992 | 10 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
arostm | 0:4af3ca173992 | 11 | * |
arostm | 0:4af3ca173992 | 12 | * Redistribution and use in source and binary forms, with or without modification, |
arostm | 0:4af3ca173992 | 13 | * are permitted provided that the following conditions are met: |
arostm | 0:4af3ca173992 | 14 | * 1. Redistributions of source code must retain the above copyright notice, |
arostm | 0:4af3ca173992 | 15 | * this list of conditions and the following disclaimer. |
arostm | 0:4af3ca173992 | 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
arostm | 0:4af3ca173992 | 17 | * this list of conditions and the following disclaimer in the documentation |
arostm | 0:4af3ca173992 | 18 | * and/or other materials provided with the distribution. |
arostm | 0:4af3ca173992 | 19 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
arostm | 0:4af3ca173992 | 20 | * may be used to endorse or promote products derived from this software |
arostm | 0:4af3ca173992 | 21 | * without specific prior written permission. |
arostm | 0:4af3ca173992 | 22 | * |
arostm | 0:4af3ca173992 | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
arostm | 0:4af3ca173992 | 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
arostm | 0:4af3ca173992 | 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
arostm | 0:4af3ca173992 | 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
arostm | 0:4af3ca173992 | 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
arostm | 0:4af3ca173992 | 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
arostm | 0:4af3ca173992 | 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
arostm | 0:4af3ca173992 | 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
arostm | 0:4af3ca173992 | 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
arostm | 0:4af3ca173992 | 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
arostm | 0:4af3ca173992 | 33 | * |
arostm | 0:4af3ca173992 | 34 | ****************************************************************************** |
arostm | 0:4af3ca173992 | 35 | */ |
arostm | 0:4af3ca173992 | 36 | |
arostm | 0:4af3ca173992 | 37 | /* Define to prevent recursive inclusion -------------------------------------*/ |
arostm | 0:4af3ca173992 | 38 | #ifndef __STM32F413H_DISCOVERY_AUDIO_H |
arostm | 0:4af3ca173992 | 39 | #define __STM32F413H_DISCOVERY_AUDIO_H |
arostm | 0:4af3ca173992 | 40 | |
arostm | 0:4af3ca173992 | 41 | #ifdef __cplusplus |
arostm | 0:4af3ca173992 | 42 | extern "C" { |
arostm | 0:4af3ca173992 | 43 | #endif |
arostm | 0:4af3ca173992 | 44 | |
arostm | 0:4af3ca173992 | 45 | /* Includes ------------------------------------------------------------------*/ |
arostm | 0:4af3ca173992 | 46 | /* Include audio component Driver */ |
arostm | 0:4af3ca173992 | 47 | #include "../Components/wm8994/wm8994.h" |
arostm | 0:4af3ca173992 | 48 | #include "stm32f413h_discovery.h" |
arostm | 0:4af3ca173992 | 49 | |
arostm | 0:4af3ca173992 | 50 | /** @addtogroup BSP |
arostm | 0:4af3ca173992 | 51 | * @{ |
arostm | 0:4af3ca173992 | 52 | */ |
arostm | 0:4af3ca173992 | 53 | |
arostm | 0:4af3ca173992 | 54 | /** @addtogroup STM32F413H_DISCOVERY |
arostm | 0:4af3ca173992 | 55 | * @{ |
arostm | 0:4af3ca173992 | 56 | */ |
arostm | 0:4af3ca173992 | 57 | |
arostm | 0:4af3ca173992 | 58 | /** @addtogroup STM32F413H_DISCOVERY_AUDIO |
arostm | 0:4af3ca173992 | 59 | * @{ |
arostm | 0:4af3ca173992 | 60 | */ |
arostm | 0:4af3ca173992 | 61 | |
arostm | 0:4af3ca173992 | 62 | /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Types STM32F413H DISCOVERY Audio Exported Types |
arostm | 0:4af3ca173992 | 63 | * @{ |
arostm | 0:4af3ca173992 | 64 | */ |
arostm | 0:4af3ca173992 | 65 | |
arostm | 0:4af3ca173992 | 66 | typedef struct |
arostm | 0:4af3ca173992 | 67 | { |
arostm | 0:4af3ca173992 | 68 | uint32_t Frequency; /* Record Frequency */ |
arostm | 0:4af3ca173992 | 69 | uint32_t BitResolution; /* Record bit resolution */ |
arostm | 0:4af3ca173992 | 70 | uint32_t ChannelNbr; /* Record Channel Number */ |
arostm | 0:4af3ca173992 | 71 | uint16_t *pRecBuf; /* Pointer to record user buffer */ |
arostm | 0:4af3ca173992 | 72 | uint32_t RecSize; /* Size to record in mono, double size to record in stereo */ |
arostm | 0:4af3ca173992 | 73 | uint32_t InputDevice; /* Audio Input Device */ |
arostm | 0:4af3ca173992 | 74 | uint32_t MultiBuffMode; /* Multi buffer mode selection */ |
arostm | 0:4af3ca173992 | 75 | }AUDIOIN_ContextTypeDef; |
arostm | 0:4af3ca173992 | 76 | |
arostm | 0:4af3ca173992 | 77 | /** |
arostm | 0:4af3ca173992 | 78 | * @} |
arostm | 0:4af3ca173992 | 79 | */ |
arostm | 0:4af3ca173992 | 80 | |
arostm | 0:4af3ca173992 | 81 | /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Constants STM32F413H DISCOVERY Audio Exported Constants |
arostm | 0:4af3ca173992 | 82 | * @{ |
arostm | 0:4af3ca173992 | 83 | */ |
arostm | 0:4af3ca173992 | 84 | |
arostm | 0:4af3ca173992 | 85 | /*------------------------------------------------------------------------------ |
arostm | 0:4af3ca173992 | 86 | AUDIO OUT CONFIGURATION |
arostm | 0:4af3ca173992 | 87 | ------------------------------------------------------------------------------*/ |
arostm | 0:4af3ca173992 | 88 | /* SPI Configuration defines */ |
arostm | 0:4af3ca173992 | 89 | #define AUDIO_OUT_I2Sx SPI2 |
arostm | 0:4af3ca173992 | 90 | #define AUDIO_OUT_I2Sx_CLK_ENABLE() __HAL_RCC_SPI2_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 91 | #define AUDIO_OUT_I2Sx_CLK_DISABLE() __HAL_RCC_SPI2_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 92 | |
arostm | 0:4af3ca173992 | 93 | #define AUDIO_OUT_I2Sx_MCK_PIN GPIO_PIN_3 |
arostm | 0:4af3ca173992 | 94 | #define AUDIO_OUT_I2Sx_MCK_GPIO_PORT GPIOA |
arostm | 0:4af3ca173992 | 95 | #define AUDIO_OUT_I2Sx_MCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 96 | #define AUDIO_OUT_I2Sx_MCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 97 | #define AUDIO_OUT_I2Sx_MCK_AF GPIO_AF5_SPI2 |
arostm | 0:4af3ca173992 | 98 | |
arostm | 0:4af3ca173992 | 99 | #define AUDIO_OUT_I2Sx_SCK_PIN GPIO_PIN_3 |
arostm | 0:4af3ca173992 | 100 | #define AUDIO_OUT_I2Sx_SCK_GPIO_PORT GPIOD |
arostm | 0:4af3ca173992 | 101 | #define AUDIO_OUT_I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 102 | #define AUDIO_OUT_I2Sx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 103 | #define AUDIO_OUT_I2Sx_SCK_AF GPIO_AF5_SPI2 |
arostm | 0:4af3ca173992 | 104 | |
arostm | 0:4af3ca173992 | 105 | #define AUDIO_OUT_I2Sx_WS_PIN GPIO_PIN_9 |
arostm | 0:4af3ca173992 | 106 | #define AUDIO_OUT_I2Sx_WS_GPIO_PORT GPIOB |
arostm | 0:4af3ca173992 | 107 | #define AUDIO_OUT_I2Sx_WS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 108 | #define AUDIO_OUT_I2Sx_WS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 109 | #define AUDIO_OUT_I2Sx_WS_AF GPIO_AF5_SPI2 |
arostm | 0:4af3ca173992 | 110 | |
arostm | 0:4af3ca173992 | 111 | #define AUDIO_OUT_I2Sx_SD_PIN GPIO_PIN_3 |
arostm | 0:4af3ca173992 | 112 | #define AUDIO_OUT_I2Sx_SD_GPIO_PORT GPIOC |
arostm | 0:4af3ca173992 | 113 | #define AUDIO_OUT_I2Sx_SD_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 114 | #define AUDIO_OUT_I2Sx_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 115 | #define AUDIO_OUT_I2Sx_SD_AF GPIO_AF5_SPI2 |
arostm | 0:4af3ca173992 | 116 | |
arostm | 0:4af3ca173992 | 117 | /* I2S DMA Stream Tx definitions */ |
arostm | 0:4af3ca173992 | 118 | #define AUDIO_OUT_I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 119 | #define AUDIO_OUT_I2Sx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 120 | #define AUDIO_OUT_I2Sx_DMAx_STREAM DMA1_Stream4 |
arostm | 0:4af3ca173992 | 121 | #define AUDIO_OUT_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0 |
arostm | 0:4af3ca173992 | 122 | #define AUDIO_OUT_I2Sx_DMAx_IRQ DMA1_Stream4_IRQn |
arostm | 0:4af3ca173992 | 123 | #define AUDIO_OUT_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD |
arostm | 0:4af3ca173992 | 124 | #define AUDIO_OUT_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD |
arostm | 0:4af3ca173992 | 125 | #define DMA_MAX_SIZE 0xFFFF |
arostm | 0:4af3ca173992 | 126 | |
arostm | 0:4af3ca173992 | 127 | #define AUDIO_OUT_I2Sx_DMAx_IRQHandler DMA1_Stream4_IRQHandler |
arostm | 0:4af3ca173992 | 128 | |
arostm | 0:4af3ca173992 | 129 | /* Select the interrupt preemption priority for the DMA interrupt */ |
arostm | 0:4af3ca173992 | 130 | #define AUDIO_OUT_IRQ_PREPRIO ((uint32_t)0x0E) /* Select the preemption priority level(0 is the highest) */ |
arostm | 0:4af3ca173992 | 131 | |
arostm | 0:4af3ca173992 | 132 | |
arostm | 0:4af3ca173992 | 133 | /*------------------------------------------------------------------------------ |
arostm | 0:4af3ca173992 | 134 | AUDIO IN CONFIGURATION |
arostm | 0:4af3ca173992 | 135 | ------------------------------------------------------------------------------*/ |
arostm | 0:4af3ca173992 | 136 | /* DFSDM Configuration defines */ |
arostm | 0:4af3ca173992 | 137 | #define AUDIO_DFSDMx_MIC1_CHANNEL DFSDM1_Channel1 /* MP34DT01TR U1 microphone on PCB top side */ |
arostm | 0:4af3ca173992 | 138 | #define AUDIO_DFSDMx_MIC2_CHANNEL DFSDM2_Channel1 /* MP34DT01TR U2 microphone on PCB top side */ |
arostm | 0:4af3ca173992 | 139 | #define AUDIO_DFSDMx_MIC3_CHANNEL DFSDM2_Channel0 /* MP34DT01TR U3 microphone on PCB top side */ |
arostm | 0:4af3ca173992 | 140 | #define AUDIO_DFSDMx_MIC4_CHANNEL DFSDM2_Channel7 /* MP34DT01TR U4 microphone on PCB top side */ |
arostm | 0:4af3ca173992 | 141 | #define AUDIO_DFSDMx_MIC5_CHANNEL DFSDM2_Channel6 /* MP34DT01TR U5 microphone on PCB top side */ |
arostm | 0:4af3ca173992 | 142 | |
arostm | 0:4af3ca173992 | 143 | #define AUDIO_DFSDMx_MIC1_CHANNEL_FOR_FILTER DFSDM_CHANNEL_1 |
arostm | 0:4af3ca173992 | 144 | #define AUDIO_DFSDMx_MIC2_CHANNEL_FOR_FILTER DFSDM_CHANNEL_1 |
arostm | 0:4af3ca173992 | 145 | #define AUDIO_DFSDMx_MIC3_CHANNEL_FOR_FILTER DFSDM_CHANNEL_0 |
arostm | 0:4af3ca173992 | 146 | #define AUDIO_DFSDMx_MIC4_CHANNEL_FOR_FILTER DFSDM_CHANNEL_7 |
arostm | 0:4af3ca173992 | 147 | #define AUDIO_DFSDMx_MIC5_CHANNEL_FOR_FILTER DFSDM_CHANNEL_6 |
arostm | 0:4af3ca173992 | 148 | |
arostm | 0:4af3ca173992 | 149 | #define AUDIO_DFSDMx_MIC1_FILTER DFSDM1_Filter0 /* Common MIC1 filter for MP34DT01TR (U1) microphone input */ |
arostm | 0:4af3ca173992 | 150 | #define AUDIO_DFSDMx_MIC2_FILTER DFSDM2_Filter0 /* Common MIC2 filter for MP34DT01TR(U2) microphone input */ |
arostm | 0:4af3ca173992 | 151 | #define AUDIO_DFSDMx_MIC3_FILTER DFSDM2_Filter1 /* Common MIC2 filter for MP34DT01TR(U3) microphone input */ |
arostm | 0:4af3ca173992 | 152 | #define AUDIO_DFSDMx_MIC4_FILTER DFSDM2_Filter2 /* Common MIC2 filter for MP34DT01TR(U4) microphone input */ |
arostm | 0:4af3ca173992 | 153 | #define AUDIO_DFSDMx_MIC5_FILTER DFSDM2_Filter3 /* Common MIC2 filter for MP34DT01TR(U5) microphone input */ |
arostm | 0:4af3ca173992 | 154 | |
arostm | 0:4af3ca173992 | 155 | #define AUDIO_DFSDMx_MIC2_5_CLK_ENABLE() __HAL_RCC_DFSDM2_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 156 | #define AUDIO_DFSDMx_MIC1_CLK_ENABLE() __HAL_RCC_DFSDM1_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 157 | |
arostm | 0:4af3ca173992 | 158 | #define AUDIO_DFSDMx_MIC1_CKOUT_PIN GPIO_PIN_8 |
arostm | 0:4af3ca173992 | 159 | #define AUDIO_DFSDMx_MIC1_CKOUT_DMIC_GPIO_PORT GPIOA |
arostm | 0:4af3ca173992 | 160 | #define AUDIO_DFSDMx_MIC1_CKOUT_DMIC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 161 | #define AUDIO_DFSDMx_MIC1_CKOUT_DMIC_AF GPIO_AF6_DFSDM1 |
arostm | 0:4af3ca173992 | 162 | |
arostm | 0:4af3ca173992 | 163 | #define AUDIO_DFSDMx_MIC1_DMIC_PIN GPIO_PIN_6 |
arostm | 0:4af3ca173992 | 164 | #define AUDIO_DFSDMx_MIC1_DMIC_GPIO_PORT GPIOD |
arostm | 0:4af3ca173992 | 165 | #define AUDIO_DFSDMx_MIC1_DMIC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 166 | #define AUDIO_DFSDMx_MIC1_DMIC_AF GPIO_AF6_DFSDM1 |
arostm | 0:4af3ca173992 | 167 | |
arostm | 0:4af3ca173992 | 168 | #define AUDIO_DFSDMx_MIC2_5_CKOUT_PIN GPIO_PIN_2 |
arostm | 0:4af3ca173992 | 169 | #define AUDIO_DFSDMx_MIC2_5_CKOUT_DMIC_GPIO_PORT GPIOD |
arostm | 0:4af3ca173992 | 170 | #define AUDIO_DFSDMx_MIC2_5_CKOUT_DMIC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 171 | #define AUDIO_DFSDMx_MIC2_5_CKOUT_DMIC_AF GPIO_AF3_DFSDM2 |
arostm | 0:4af3ca173992 | 172 | |
arostm | 0:4af3ca173992 | 173 | #define AUDIO_DFSDMx_MIC23_DMIC_PIN GPIO_PIN_7 |
arostm | 0:4af3ca173992 | 174 | #define AUDIO_DFSDMx_MIC23_DMIC_GPIO_PORT GPIOA |
arostm | 0:4af3ca173992 | 175 | #define AUDIO_DFSDMx_MIC23_DMIC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 176 | #define AUDIO_DFSDMx_MIC23_DMIC_AF GPIO_AF7_DFSDM2 |
arostm | 0:4af3ca173992 | 177 | |
arostm | 0:4af3ca173992 | 178 | #define AUDIO_DFSDMx_MIC45_DMIC_PIN GPIO_PIN_7 |
arostm | 0:4af3ca173992 | 179 | #define AUDIO_DFSDMx_MIC45_DMIC_GPIO_PORT GPIOB |
arostm | 0:4af3ca173992 | 180 | #define AUDIO_DFSDMx_MIC45_DMIC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 181 | #define AUDIO_DFSDMx_MIC45_DMIC_AF GPIO_AF6_DFSDM2 |
arostm | 0:4af3ca173992 | 182 | |
arostm | 0:4af3ca173992 | 183 | /* DFSDM DMA Right and Left channels definitions */ |
arostm | 0:4af3ca173992 | 184 | #define AUDIO_DFSDMx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 185 | #define AUDIO_DFSDMx_DMAx_MIC1_STREAM DMA2_Stream6 |
arostm | 0:4af3ca173992 | 186 | #define AUDIO_DFSDMx_DMAx_MIC1_CHANNEL DMA_CHANNEL_3 |
arostm | 0:4af3ca173992 | 187 | #define AUDIO_DFSDMx_DMAx_MIC2_STREAM DMA2_Stream0 |
arostm | 0:4af3ca173992 | 188 | #define AUDIO_DFSDMx_DMAx_MIC2_CHANNEL DMA_CHANNEL_8 |
arostm | 0:4af3ca173992 | 189 | #define AUDIO_DFSDMx_DMAx_MIC3_STREAM DMA2_Stream1 |
arostm | 0:4af3ca173992 | 190 | #define AUDIO_DFSDMx_DMAx_MIC3_CHANNEL DMA_CHANNEL_8 |
arostm | 0:4af3ca173992 | 191 | #define AUDIO_DFSDMx_DMAx_MIC4_STREAM DMA2_Stream2 |
arostm | 0:4af3ca173992 | 192 | #define AUDIO_DFSDMx_DMAx_MIC4_CHANNEL DMA_CHANNEL_8 |
arostm | 0:4af3ca173992 | 193 | #define AUDIO_DFSDMx_DMAx_MIC5_STREAM DMA2_Stream7 |
arostm | 0:4af3ca173992 | 194 | #define AUDIO_DFSDMx_DMAx_MIC5_CHANNEL DMA_CHANNEL_8 |
arostm | 0:4af3ca173992 | 195 | #define AUDIO_DFSDMx_DMAx_MIC1_IRQ DMA2_Stream6_IRQn |
arostm | 0:4af3ca173992 | 196 | #define AUDIO_DFSDMx_DMAx_MIC2_IRQ DMA2_Stream0_IRQn |
arostm | 0:4af3ca173992 | 197 | #define AUDIO_DFSDMx_DMAx_MIC3_IRQ DMA2_Stream1_IRQn |
arostm | 0:4af3ca173992 | 198 | #define AUDIO_DFSDMx_DMAx_MIC4_IRQ DMA2_Stream2_IRQn |
arostm | 0:4af3ca173992 | 199 | #define AUDIO_DFSDMx_DMAx_MIC5_IRQ DMA2_Stream7_IRQn |
arostm | 0:4af3ca173992 | 200 | |
arostm | 0:4af3ca173992 | 201 | #define AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_WORD |
arostm | 0:4af3ca173992 | 202 | #define AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_WORD |
arostm | 0:4af3ca173992 | 203 | |
arostm | 0:4af3ca173992 | 204 | #define AUDIO_DFSDM_DMAx_MIC1_IRQHandler DMA2_Stream6_IRQHandler |
arostm | 0:4af3ca173992 | 205 | #define AUDIO_DFSDM_DMAx_MIC2_IRQHandler DMA2_Stream0_IRQHandler |
arostm | 0:4af3ca173992 | 206 | #define AUDIO_DFSDM_DMAx_MIC3_IRQHandler DMA2_Stream1_IRQHandler |
arostm | 0:4af3ca173992 | 207 | #define AUDIO_DFSDM_DMAx_MIC4_IRQHandler DMA2_Stream2_IRQHandler |
arostm | 0:4af3ca173992 | 208 | #define AUDIO_DFSDM_DMAx_MIC5_IRQHandler DMA2_Stream7_IRQHandler |
arostm | 0:4af3ca173992 | 209 | |
arostm | 0:4af3ca173992 | 210 | |
arostm | 0:4af3ca173992 | 211 | /* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */ |
arostm | 0:4af3ca173992 | 212 | #define AUDIO_IN_IRQ_PREPRIO 0x0F /* Select the preemption priority level(0 is the highest) */ |
arostm | 0:4af3ca173992 | 213 | |
arostm | 0:4af3ca173992 | 214 | /* HW defines for Analog mic configuration */ |
arostm | 0:4af3ca173992 | 215 | #define AUDIO_IN_I2Sx SPI3 |
arostm | 0:4af3ca173992 | 216 | #define AUDIO_IN_I2Sx_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 217 | #define AUDIO_IN_I2Sx_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 218 | |
arostm | 0:4af3ca173992 | 219 | #define AUDIO_IN_I2Sx_EXT_SD_PIN GPIO_PIN_4 |
arostm | 0:4af3ca173992 | 220 | #define AUDIO_IN_I2Sx_EXT_SD_GPIO_PORT GPIOB |
arostm | 0:4af3ca173992 | 221 | #define AUDIO_IN_I2Sx_EXT_SD_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 222 | #define AUDIO_IN_I2Sx_EXT_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 223 | #define AUDIO_IN_I2Sx_EXT_SD_AF GPIO_AF7_SPI3 |
arostm | 0:4af3ca173992 | 224 | |
arostm | 0:4af3ca173992 | 225 | #define AUDIO_IN_CODEC_INT_PIN GPIO_PIN_2 |
arostm | 0:4af3ca173992 | 226 | #define AUDIO_IN_CODEC_INT_GPIO_PORT GPIOG |
arostm | 0:4af3ca173992 | 227 | #define AUDIO_IN_CODEC_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 228 | #define AUDIO_IN_CODEC_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 229 | #define AUDIO_IN_CODEC_INT_IRQ EXTI2_IRQn |
arostm | 0:4af3ca173992 | 230 | |
arostm | 0:4af3ca173992 | 231 | /* I2S DMA Stream Rx definitions */ |
arostm | 0:4af3ca173992 | 232 | #define AUDIO_IN_I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() |
arostm | 0:4af3ca173992 | 233 | #define AUDIO_IN_I2Sx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE() |
arostm | 0:4af3ca173992 | 234 | #define AUDIO_IN_I2Sx_DMAx_STREAM DMA1_Stream0 |
arostm | 0:4af3ca173992 | 235 | #define AUDIO_IN_I2Sx_DMAx_CHANNEL DMA_CHANNEL_3 |
arostm | 0:4af3ca173992 | 236 | #define AUDIO_IN_I2Sx_DMAx_IRQ DMA1_Stream0_IRQn |
arostm | 0:4af3ca173992 | 237 | #define AUDIO_IN_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD |
arostm | 0:4af3ca173992 | 238 | #define AUDIO_IN_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD |
arostm | 0:4af3ca173992 | 239 | |
arostm | 0:4af3ca173992 | 240 | #define AUDIO_IN_I2Sx_DMAx_IRQHandler DMA1_Stream0_IRQHandler |
arostm | 0:4af3ca173992 | 241 | #define AUDIO_IN_I2Sx_DMAx_IRQ DMA1_Stream0_IRQn |
arostm | 0:4af3ca173992 | 242 | |
arostm | 0:4af3ca173992 | 243 | /*------------------------------------------------------------------------------ |
arostm | 0:4af3ca173992 | 244 | CONFIGURATION: Audio Driver Configuration parameters |
arostm | 0:4af3ca173992 | 245 | ------------------------------------------------------------------------------*/ |
arostm | 0:4af3ca173992 | 246 | |
arostm | 0:4af3ca173992 | 247 | #define AUDIODATA_SIZE 2 /* 16-bits audio data size */ |
arostm | 0:4af3ca173992 | 248 | |
arostm | 0:4af3ca173992 | 249 | /* Audio status definition */ |
arostm | 0:4af3ca173992 | 250 | #define AUDIO_OK ((uint8_t)0) |
arostm | 0:4af3ca173992 | 251 | #define AUDIO_ERROR ((uint8_t)1) |
arostm | 0:4af3ca173992 | 252 | #define AUDIO_TIMEOUT ((uint8_t)2) |
arostm | 0:4af3ca173992 | 253 | |
arostm | 0:4af3ca173992 | 254 | /* Audio out parameters */ |
arostm | 0:4af3ca173992 | 255 | #define DEFAULT_AUDIO_OUT_FREQ I2S_AUDIOFREQ_48K |
arostm | 0:4af3ca173992 | 256 | #define DEFAULT_AUDIO_OUT_BIT_RESOLUTION ((uint8_t)16) |
arostm | 0:4af3ca173992 | 257 | #define DEFAULT_AUDIO_OUT_CHANNEL_NBR ((uint8_t)2) /* Mono = 1, Stereo = 2 */ |
arostm | 0:4af3ca173992 | 258 | #define DEFAULT_AUDIO_OUT_VOLUME ((uint16_t)64) |
arostm | 0:4af3ca173992 | 259 | |
arostm | 0:4af3ca173992 | 260 | /* Audio in parameters */ |
arostm | 0:4af3ca173992 | 261 | #define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K |
arostm | 0:4af3ca173992 | 262 | #define DEFAULT_AUDIO_IN_BIT_RESOLUTION ((uint8_t)16) |
arostm | 0:4af3ca173992 | 263 | #define DEFAULT_AUDIO_IN_CHANNEL_NBR ((uint8_t)2) /* Mono = 1, Stereo = 2 */ |
arostm | 0:4af3ca173992 | 264 | #define DEFAULT_AUDIO_IN_VOLUME ((uint16_t)64) |
arostm | 0:4af3ca173992 | 265 | |
arostm | 0:4af3ca173992 | 266 | /*------------------------------------------------------------------------------ |
arostm | 0:4af3ca173992 | 267 | OUTPUT DEVICES definition |
arostm | 0:4af3ca173992 | 268 | ------------------------------------------------------------------------------*/ |
arostm | 0:4af3ca173992 | 269 | |
arostm | 0:4af3ca173992 | 270 | /* Alias on existing output devices to adapt for 2 headphones output */ |
arostm | 0:4af3ca173992 | 271 | #define OUTPUT_DEVICE_HEADPHONE1 OUTPUT_DEVICE_HEADPHONE |
arostm | 0:4af3ca173992 | 272 | #define OUTPUT_DEVICE_HEADPHONE2 OUTPUT_DEVICE_SPEAKER /* Headphone2 is connected to Speaker output of the wm8994 */ |
arostm | 0:4af3ca173992 | 273 | |
arostm | 0:4af3ca173992 | 274 | /*------------------------------------------------------------------------------ |
arostm | 0:4af3ca173992 | 275 | INPUT DEVICES definition |
arostm | 0:4af3ca173992 | 276 | ------------------------------------------------------------------------------*/ |
arostm | 0:4af3ca173992 | 277 | /* Analog microphone input from 3.5 audio jack connector */ |
arostm | 0:4af3ca173992 | 278 | #define INPUT_DEVICE_ANALOG_MIC ((uint32_t)0x00000001) |
arostm | 0:4af3ca173992 | 279 | /* MP34DT01TR digital microphone on PCB top side */ |
arostm | 0:4af3ca173992 | 280 | #define INPUT_DEVICE_DIGITAL_MIC1 ((uint32_t)0x00000010) |
arostm | 0:4af3ca173992 | 281 | #define INPUT_DEVICE_DIGITAL_MIC2 ((uint32_t)0x00000020) |
arostm | 0:4af3ca173992 | 282 | #define INPUT_DEVICE_DIGITAL_MIC3 ((uint32_t)0x00000040) |
arostm | 0:4af3ca173992 | 283 | #define INPUT_DEVICE_DIGITAL_MIC4 ((uint32_t)0x00000080) |
arostm | 0:4af3ca173992 | 284 | #define INPUT_DEVICE_DIGITAL_MIC5 ((uint32_t)0x00000100) |
arostm | 0:4af3ca173992 | 285 | #define INPUT_DEVICE_DIGITAL_MIC ((uint32_t)(INPUT_DEVICE_DIGITAL_MIC1 | INPUT_DEVICE_DIGITAL_MIC2)) |
arostm | 0:4af3ca173992 | 286 | #define INPUT_DEVICE_DIGITAL_MIC_ALL ((uint32_t)(INPUT_DEVICE_DIGITAL_MIC1 | INPUT_DEVICE_DIGITAL_MIC2 |\ |
arostm | 0:4af3ca173992 | 287 | INPUT_DEVICE_DIGITAL_MIC3 | INPUT_DEVICE_DIGITAL_MIC4 |\ |
arostm | 0:4af3ca173992 | 288 | INPUT_DEVICE_DIGITAL_MIC5)) |
arostm | 0:4af3ca173992 | 289 | |
arostm | 0:4af3ca173992 | 290 | #define DFSDM_MIC_NUMBER (5) |
arostm | 0:4af3ca173992 | 291 | |
arostm | 0:4af3ca173992 | 292 | /** |
arostm | 0:4af3ca173992 | 293 | * @} |
arostm | 0:4af3ca173992 | 294 | */ |
arostm | 0:4af3ca173992 | 295 | |
arostm | 0:4af3ca173992 | 296 | /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Variables STM32F413H DISCOVERY Audio Exported Variables |
arostm | 0:4af3ca173992 | 297 | * @{ |
arostm | 0:4af3ca173992 | 298 | */ |
arostm | 0:4af3ca173992 | 299 | extern __IO uint16_t AudioInVolume; |
arostm | 0:4af3ca173992 | 300 | /** |
arostm | 0:4af3ca173992 | 301 | * @} |
arostm | 0:4af3ca173992 | 302 | */ |
arostm | 0:4af3ca173992 | 303 | |
arostm | 0:4af3ca173992 | 304 | /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Macros STM32F413H DISCOVERY Audio Exported Macros |
arostm | 0:4af3ca173992 | 305 | * @{ |
arostm | 0:4af3ca173992 | 306 | */ |
arostm | 0:4af3ca173992 | 307 | #define DMA_MAX(x) (((x) <= DMA_MAX_SIZE)? (x):DMA_MAX_SIZE) |
arostm | 0:4af3ca173992 | 308 | #define POS_VAL(VAL) (POSITION_VAL(VAL) - 4) |
arostm | 0:4af3ca173992 | 309 | /** |
arostm | 0:4af3ca173992 | 310 | * @} |
arostm | 0:4af3ca173992 | 311 | */ |
arostm | 0:4af3ca173992 | 312 | |
arostm | 0:4af3ca173992 | 313 | /** @defgroup STM32F413H_DISCOVERY_AUDIO_OUT_Exported_Functions STM32F413H DISCOVERY Audio OUT Exported Functions |
arostm | 0:4af3ca173992 | 314 | * @{ |
arostm | 0:4af3ca173992 | 315 | */ |
arostm | 0:4af3ca173992 | 316 | uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); |
arostm | 0:4af3ca173992 | 317 | uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size); |
arostm | 0:4af3ca173992 | 318 | void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); |
arostm | 0:4af3ca173992 | 319 | uint8_t BSP_AUDIO_OUT_Pause(void); |
arostm | 0:4af3ca173992 | 320 | uint8_t BSP_AUDIO_OUT_Resume(void); |
arostm | 0:4af3ca173992 | 321 | uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); |
arostm | 0:4af3ca173992 | 322 | uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); |
arostm | 0:4af3ca173992 | 323 | void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); |
arostm | 0:4af3ca173992 | 324 | uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); |
arostm | 0:4af3ca173992 | 325 | uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); |
arostm | 0:4af3ca173992 | 326 | void BSP_AUDIO_OUT_DeInit(void); |
arostm | 0:4af3ca173992 | 327 | |
arostm | 0:4af3ca173992 | 328 | /* User Callbacks: user has to implement these functions in his code if they are needed. */ |
arostm | 0:4af3ca173992 | 329 | /* This function is called when the requested data has been completely transferred.*/ |
arostm | 0:4af3ca173992 | 330 | void BSP_AUDIO_OUT_TransferComplete_CallBack(void); |
arostm | 0:4af3ca173992 | 331 | |
arostm | 0:4af3ca173992 | 332 | /* This function is called when half of the requested buffer has been transferred. */ |
arostm | 0:4af3ca173992 | 333 | void BSP_AUDIO_OUT_HalfTransfer_CallBack(void); |
arostm | 0:4af3ca173992 | 334 | |
arostm | 0:4af3ca173992 | 335 | /* This function is called when an Interrupt due to transfer error on or peripheral |
arostm | 0:4af3ca173992 | 336 | error occurs. */ |
arostm | 0:4af3ca173992 | 337 | void BSP_AUDIO_OUT_Error_CallBack(void); |
arostm | 0:4af3ca173992 | 338 | |
arostm | 0:4af3ca173992 | 339 | /* These function can be modified in case the current settings (e.g. DMA stream) |
arostm | 0:4af3ca173992 | 340 | need to be changed for specific application needs */ |
arostm | 0:4af3ca173992 | 341 | void BSP_AUDIO_OUT_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params); |
arostm | 0:4af3ca173992 | 342 | void BSP_AUDIO_OUT_MspInit(I2S_HandleTypeDef *hi2s, void *Params); |
arostm | 0:4af3ca173992 | 343 | void BSP_AUDIO_OUT_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params); |
arostm | 0:4af3ca173992 | 344 | |
arostm | 0:4af3ca173992 | 345 | /** |
arostm | 0:4af3ca173992 | 346 | * @} |
arostm | 0:4af3ca173992 | 347 | */ |
arostm | 0:4af3ca173992 | 348 | |
arostm | 0:4af3ca173992 | 349 | /** @defgroup STM32F413H_DISCOVERY_AUDIO_IN_Exported_Functions STM32F413H DISCOVERY AudioIN Exported Functions |
arostm | 0:4af3ca173992 | 350 | * @{ |
arostm | 0:4af3ca173992 | 351 | */ |
arostm | 0:4af3ca173992 | 352 | uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); |
arostm | 0:4af3ca173992 | 353 | uint8_t BSP_AUDIO_IN_InitEx(uint32_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); |
arostm | 0:4af3ca173992 | 354 | uint8_t BSP_AUDIO_IN_ConfigMicDefault(uint32_t InputDevice); |
arostm | 0:4af3ca173992 | 355 | uint8_t BSP_AUDIO_IN_ConfigDigitalMic(uint32_t InputDevice, void *Params); |
arostm | 0:4af3ca173992 | 356 | uint8_t BSP_AUDIO_IN_AllocScratch (int32_t *pScratch, uint32_t size); |
arostm | 0:4af3ca173992 | 357 | uint8_t BSP_AUDIO_IN_Record(uint16_t *pBuf, uint32_t Size); |
arostm | 0:4af3ca173992 | 358 | uint8_t BSP_AUDIO_IN_RecordEx(uint32_t *pBuf, uint32_t Size); |
arostm | 0:4af3ca173992 | 359 | uint8_t BSP_AUDIO_IN_SetFrequency(uint32_t AudioFreq); |
arostm | 0:4af3ca173992 | 360 | uint8_t BSP_AUDIO_IN_Stop(void); |
arostm | 0:4af3ca173992 | 361 | uint8_t BSP_AUDIO_IN_StopEx(uint32_t InputDevice); |
arostm | 0:4af3ca173992 | 362 | uint8_t BSP_AUDIO_IN_Pause(void); |
arostm | 0:4af3ca173992 | 363 | uint8_t BSP_AUDIO_IN_PauseEx(uint32_t InputDevice); |
arostm | 0:4af3ca173992 | 364 | uint8_t BSP_AUDIO_IN_Resume(void); |
arostm | 0:4af3ca173992 | 365 | uint8_t BSP_AUDIO_IN_ResumeEx(uint32_t *pBuf, uint32_t InputDevice); |
arostm | 0:4af3ca173992 | 366 | uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume); |
arostm | 0:4af3ca173992 | 367 | void BSP_AUDIO_IN_DeInit(void); |
arostm | 0:4af3ca173992 | 368 | |
arostm | 0:4af3ca173992 | 369 | /* User Callbacks: user has to implement these functions in his code if they are needed. */ |
arostm | 0:4af3ca173992 | 370 | /* This function should be implemented by the user application. |
arostm | 0:4af3ca173992 | 371 | It is called into this driver when the current buffer is filled to prepare the next |
arostm | 0:4af3ca173992 | 372 | buffer pointer and its size. */ |
arostm | 0:4af3ca173992 | 373 | void BSP_AUDIO_IN_TransferComplete_CallBack(void); |
arostm | 0:4af3ca173992 | 374 | void BSP_AUDIO_IN_HalfTransfer_CallBack(void); |
arostm | 0:4af3ca173992 | 375 | void BSP_AUDIO_IN_TransferComplete_CallBackEx(uint32_t InputDevice); |
arostm | 0:4af3ca173992 | 376 | void BSP_AUDIO_IN_HalfTransfer_CallBackEx(uint32_t InputDevice); |
arostm | 0:4af3ca173992 | 377 | |
arostm | 0:4af3ca173992 | 378 | /* This function is called when an Interrupt due to transfer error on or peripheral |
arostm | 0:4af3ca173992 | 379 | error occurs. */ |
arostm | 0:4af3ca173992 | 380 | void BSP_AUDIO_IN_Error_Callback(void); |
arostm | 0:4af3ca173992 | 381 | |
arostm | 0:4af3ca173992 | 382 | /* These function can be modified in case the current settings (e.g. DMA stream) |
arostm | 0:4af3ca173992 | 383 | need to be changed for specific application needs */ |
arostm | 0:4af3ca173992 | 384 | uint8_t BSP_AUDIO_IN_ClockConfig(uint32_t AudioFreq, void *Params); |
arostm | 0:4af3ca173992 | 385 | void BSP_AUDIO_IN_MspInit(void *Params); |
arostm | 0:4af3ca173992 | 386 | void BSP_AUDIO_IN_MspDeInit(void *Params); |
arostm | 0:4af3ca173992 | 387 | |
arostm | 0:4af3ca173992 | 388 | /** |
arostm | 0:4af3ca173992 | 389 | * @} |
arostm | 0:4af3ca173992 | 390 | */ |
arostm | 0:4af3ca173992 | 391 | |
arostm | 0:4af3ca173992 | 392 | /** |
arostm | 0:4af3ca173992 | 393 | * @} |
arostm | 0:4af3ca173992 | 394 | */ |
arostm | 0:4af3ca173992 | 395 | |
arostm | 0:4af3ca173992 | 396 | /** |
arostm | 0:4af3ca173992 | 397 | * @} |
arostm | 0:4af3ca173992 | 398 | */ |
arostm | 0:4af3ca173992 | 399 | |
arostm | 0:4af3ca173992 | 400 | /** |
arostm | 0:4af3ca173992 | 401 | * @} |
arostm | 0:4af3ca173992 | 402 | */ |
arostm | 0:4af3ca173992 | 403 | |
arostm | 0:4af3ca173992 | 404 | #ifdef __cplusplus |
arostm | 0:4af3ca173992 | 405 | } |
arostm | 0:4af3ca173992 | 406 | #endif |
arostm | 0:4af3ca173992 | 407 | |
arostm | 0:4af3ca173992 | 408 | #endif /* __STM32F413H_DISCOVERY_AUDIO_H */ |
arostm | 0:4af3ca173992 | 409 | |
arostm | 0:4af3ca173992 | 410 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |