DISCOVERY BOARD AUDIO RECORD AND PLAYBACK. Errors are currently with LCD and QSPI definitions.
Dependencies: BSP
main.c@3:233580d5c68e, 2015-11-22 (annotated)
- Committer:
- EricLew
- Date:
- Sun Nov 22 21:16:18 2015 +0000
- Revision:
- 3:233580d5c68e
- Parent:
- 0:c8cd09e8b137
11/22/2015
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EricLew | 0:c8cd09e8b137 | 1 | /** |
EricLew | 0:c8cd09e8b137 | 2 | ****************************************************************************** |
EricLew | 0:c8cd09e8b137 | 3 | * @file DFSDM/DFSDM_AudioRecord/Src/main.c |
EricLew | 0:c8cd09e8b137 | 4 | * @author MCD Application Team |
EricLew | 0:c8cd09e8b137 | 5 | * @version V1.1.0 |
EricLew | 0:c8cd09e8b137 | 6 | * @date 16-September-2015 |
EricLew | 0:c8cd09e8b137 | 7 | * @brief This example describes how to use DFSDM HAL API to realize |
EricLew | 0:c8cd09e8b137 | 8 | * audio recording. |
EricLew | 0:c8cd09e8b137 | 9 | ****************************************************************************** |
EricLew | 0:c8cd09e8b137 | 10 | * @attention |
EricLew | 0:c8cd09e8b137 | 11 | * |
EricLew | 0:c8cd09e8b137 | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
EricLew | 0:c8cd09e8b137 | 13 | * |
EricLew | 0:c8cd09e8b137 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
EricLew | 0:c8cd09e8b137 | 15 | * are permitted provided that the following conditions are met: |
EricLew | 0:c8cd09e8b137 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
EricLew | 0:c8cd09e8b137 | 17 | * this list of conditions and the following disclaimer. |
EricLew | 0:c8cd09e8b137 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
EricLew | 0:c8cd09e8b137 | 19 | * this list of conditions and the following disclaimer in the documentation |
EricLew | 0:c8cd09e8b137 | 20 | * and/or other materials provided with the distribution. |
EricLew | 0:c8cd09e8b137 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
EricLew | 0:c8cd09e8b137 | 22 | * may be used to endorse or promote products derived from this software |
EricLew | 0:c8cd09e8b137 | 23 | * without specific prior written permission. |
EricLew | 0:c8cd09e8b137 | 24 | * |
EricLew | 0:c8cd09e8b137 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
EricLew | 0:c8cd09e8b137 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
EricLew | 0:c8cd09e8b137 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
EricLew | 0:c8cd09e8b137 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
EricLew | 0:c8cd09e8b137 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
EricLew | 0:c8cd09e8b137 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
EricLew | 0:c8cd09e8b137 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
EricLew | 0:c8cd09e8b137 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
EricLew | 0:c8cd09e8b137 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
EricLew | 0:c8cd09e8b137 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
EricLew | 0:c8cd09e8b137 | 35 | * |
EricLew | 0:c8cd09e8b137 | 36 | ****************************************************************************** |
EricLew | 0:c8cd09e8b137 | 37 | */ |
EricLew | 0:c8cd09e8b137 | 38 | |
EricLew | 0:c8cd09e8b137 | 39 | /* Includes ------------------------------------------------------------------*/ |
EricLew | 0:c8cd09e8b137 | 40 | #include "main.h" |
EricLew | 0:c8cd09e8b137 | 41 | |
EricLew | 0:c8cd09e8b137 | 42 | /** @addtogroup STM32L4xx_HAL_Examples |
EricLew | 0:c8cd09e8b137 | 43 | * @{ |
EricLew | 0:c8cd09e8b137 | 44 | */ |
EricLew | 0:c8cd09e8b137 | 45 | |
EricLew | 0:c8cd09e8b137 | 46 | /** @addtogroup DFSDM_AudioRecord |
EricLew | 0:c8cd09e8b137 | 47 | * @{ |
EricLew | 0:c8cd09e8b137 | 48 | */ |
EricLew | 0:c8cd09e8b137 | 49 | |
EricLew | 0:c8cd09e8b137 | 50 | /* Private typedef -----------------------------------------------------------*/ |
EricLew | 0:c8cd09e8b137 | 51 | /* Private define ------------------------------------------------------------*/ |
EricLew | 0:c8cd09e8b137 | 52 | /* Private macro -------------------------------------------------------------*/ |
EricLew | 0:c8cd09e8b137 | 53 | #define SaturaLH(N, L, H) (((N)<(L))?(L):(((N)>(H))?(H):(N))) |
EricLew | 0:c8cd09e8b137 | 54 | /* Private variables ---------------------------------------------------------*/ |
EricLew | 0:c8cd09e8b137 | 55 | DFSDM_Channel_HandleTypeDef DfsdmChannelHandle; |
EricLew | 0:c8cd09e8b137 | 56 | DFSDM_Filter_HandleTypeDef DfsdmFilterHandle; |
EricLew | 0:c8cd09e8b137 | 57 | DMA_HandleTypeDef hDfsdmDma; |
EricLew | 0:c8cd09e8b137 | 58 | SAI_HandleTypeDef SaiHandle; |
EricLew | 0:c8cd09e8b137 | 59 | DMA_HandleTypeDef hSaiDma; |
EricLew | 0:c8cd09e8b137 | 60 | AUDIO_DrvTypeDef *audio_drv; |
EricLew | 0:c8cd09e8b137 | 61 | int32_t RecBuff[2048]; |
EricLew | 0:c8cd09e8b137 | 62 | int16_t PlayBuff[4096]; |
EricLew | 0:c8cd09e8b137 | 63 | uint32_t DmaRecHalfBuffCplt = 0; |
EricLew | 0:c8cd09e8b137 | 64 | uint32_t DmaRecBuffCplt = 0; |
EricLew | 0:c8cd09e8b137 | 65 | uint32_t PlaybackStarted = 0; |
EricLew | 0:c8cd09e8b137 | 66 | /* Private function prototypes -----------------------------------------------*/ |
EricLew | 0:c8cd09e8b137 | 67 | void SystemClock_Config(void); |
EricLew | 0:c8cd09e8b137 | 68 | static void DFSDM_Init(void); |
EricLew | 0:c8cd09e8b137 | 69 | static void Playback_Init(void); |
EricLew | 0:c8cd09e8b137 | 70 | |
EricLew | 0:c8cd09e8b137 | 71 | /* Private functions ---------------------------------------------------------*/ |
EricLew | 0:c8cd09e8b137 | 72 | |
EricLew | 0:c8cd09e8b137 | 73 | /** |
EricLew | 0:c8cd09e8b137 | 74 | * @brief Main program |
EricLew | 0:c8cd09e8b137 | 75 | * @param None |
EricLew | 0:c8cd09e8b137 | 76 | * @retval None |
EricLew | 0:c8cd09e8b137 | 77 | */ |
EricLew | 0:c8cd09e8b137 | 78 | int main(void) |
EricLew | 0:c8cd09e8b137 | 79 | { |
EricLew | 0:c8cd09e8b137 | 80 | uint32_t i; |
EricLew | 0:c8cd09e8b137 | 81 | /* STM32L4xx HAL library initialization: |
EricLew | 0:c8cd09e8b137 | 82 | - Configure the Flash prefetch |
EricLew | 0:c8cd09e8b137 | 83 | - Systick timer is configured by default as source of time base, but user |
EricLew | 0:c8cd09e8b137 | 84 | can eventually implement his proper time base source (a general purpose |
EricLew | 0:c8cd09e8b137 | 85 | timer for example or other time source), keeping in mind that Time base |
EricLew | 0:c8cd09e8b137 | 86 | duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and |
EricLew | 0:c8cd09e8b137 | 87 | handled in milliseconds basis. |
EricLew | 0:c8cd09e8b137 | 88 | - Set NVIC Group Priority to 4 |
EricLew | 0:c8cd09e8b137 | 89 | - Low Level Initialization |
EricLew | 0:c8cd09e8b137 | 90 | */ |
EricLew | 0:c8cd09e8b137 | 91 | HAL_Init(); |
EricLew | 0:c8cd09e8b137 | 92 | |
EricLew | 0:c8cd09e8b137 | 93 | /* Configure the system clock to have a frequency of 80 MHz */ |
EricLew | 0:c8cd09e8b137 | 94 | SystemClock_Config(); |
EricLew | 0:c8cd09e8b137 | 95 | |
EricLew | 0:c8cd09e8b137 | 96 | /* Configure LED4 */ |
EricLew | 0:c8cd09e8b137 | 97 | BSP_LED_Init(LED4); |
EricLew | 0:c8cd09e8b137 | 98 | |
EricLew | 0:c8cd09e8b137 | 99 | /* Initialize DFSDM channels and filter for record */ |
EricLew | 0:c8cd09e8b137 | 100 | DFSDM_Init(); |
EricLew | 0:c8cd09e8b137 | 101 | |
EricLew | 0:c8cd09e8b137 | 102 | /* Initialize playback */ |
EricLew | 0:c8cd09e8b137 | 103 | Playback_Init(); |
EricLew | 0:c8cd09e8b137 | 104 | |
EricLew | 0:c8cd09e8b137 | 105 | /* Start DFSDM conversions */ |
EricLew | 0:c8cd09e8b137 | 106 | if(HAL_OK != HAL_DFSDM_FilterRegularStart_DMA(&DfsdmFilterHandle, RecBuff, 2048)) |
EricLew | 0:c8cd09e8b137 | 107 | { |
EricLew | 0:c8cd09e8b137 | 108 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 109 | } |
EricLew | 0:c8cd09e8b137 | 110 | |
EricLew | 0:c8cd09e8b137 | 111 | /* Start loopback */ |
EricLew | 0:c8cd09e8b137 | 112 | while(1) |
EricLew | 0:c8cd09e8b137 | 113 | { |
EricLew | 0:c8cd09e8b137 | 114 | if(DmaRecHalfBuffCplt == 1) |
EricLew | 0:c8cd09e8b137 | 115 | { |
EricLew | 0:c8cd09e8b137 | 116 | /* Store values on Play buff */ |
EricLew | 0:c8cd09e8b137 | 117 | for(i = 0; i < 1024; i++) |
EricLew | 0:c8cd09e8b137 | 118 | { |
EricLew | 0:c8cd09e8b137 | 119 | PlayBuff[2*i] = SaturaLH((RecBuff[i] >> 8), -32768, 32767); |
EricLew | 0:c8cd09e8b137 | 120 | PlayBuff[(2*i)+1] = PlayBuff[2*i]; |
EricLew | 0:c8cd09e8b137 | 121 | } |
EricLew | 0:c8cd09e8b137 | 122 | if(PlaybackStarted == 0) |
EricLew | 0:c8cd09e8b137 | 123 | { |
EricLew | 0:c8cd09e8b137 | 124 | if(0 != audio_drv->Play(AUDIO_I2C_ADDRESS, (uint16_t *) &PlayBuff[0], 4096)) |
EricLew | 0:c8cd09e8b137 | 125 | { |
EricLew | 0:c8cd09e8b137 | 126 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 127 | } |
EricLew | 0:c8cd09e8b137 | 128 | if(HAL_OK != HAL_SAI_Transmit_DMA(&SaiHandle, (uint8_t *) &PlayBuff[0], 4096)) |
EricLew | 0:c8cd09e8b137 | 129 | { |
EricLew | 0:c8cd09e8b137 | 130 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 131 | } |
EricLew | 0:c8cd09e8b137 | 132 | PlaybackStarted = 1; |
EricLew | 0:c8cd09e8b137 | 133 | } |
EricLew | 0:c8cd09e8b137 | 134 | DmaRecHalfBuffCplt = 0; |
EricLew | 0:c8cd09e8b137 | 135 | } |
EricLew | 0:c8cd09e8b137 | 136 | if(DmaRecBuffCplt == 1) |
EricLew | 0:c8cd09e8b137 | 137 | { |
EricLew | 0:c8cd09e8b137 | 138 | /* Store values on Play buff */ |
EricLew | 0:c8cd09e8b137 | 139 | for(i = 1024; i < 2048; i++) |
EricLew | 0:c8cd09e8b137 | 140 | { |
EricLew | 0:c8cd09e8b137 | 141 | PlayBuff[2*i] = SaturaLH((RecBuff[i] >> 8), -32768, 32767); |
EricLew | 0:c8cd09e8b137 | 142 | PlayBuff[(2*i)+1] = PlayBuff[2*i]; |
EricLew | 0:c8cd09e8b137 | 143 | } |
EricLew | 0:c8cd09e8b137 | 144 | DmaRecBuffCplt = 0; |
EricLew | 0:c8cd09e8b137 | 145 | } |
EricLew | 0:c8cd09e8b137 | 146 | } |
EricLew | 0:c8cd09e8b137 | 147 | } |
EricLew | 0:c8cd09e8b137 | 148 | |
EricLew | 0:c8cd09e8b137 | 149 | /** |
EricLew | 0:c8cd09e8b137 | 150 | * @brief System Clock Configuration |
EricLew | 0:c8cd09e8b137 | 151 | * The system Clock is configured as follows : |
EricLew | 0:c8cd09e8b137 | 152 | * System Clock source = PLL (MSI) |
EricLew | 0:c8cd09e8b137 | 153 | * SYSCLK(Hz) = 80000000 |
EricLew | 0:c8cd09e8b137 | 154 | * HCLK(Hz) = 80000000 |
EricLew | 0:c8cd09e8b137 | 155 | * AHB Prescaler = 1 |
EricLew | 0:c8cd09e8b137 | 156 | * APB1 Prescaler = 1 |
EricLew | 0:c8cd09e8b137 | 157 | * APB2 Prescaler = 1 |
EricLew | 0:c8cd09e8b137 | 158 | * MSI Frequency(Hz) = 4000000 |
EricLew | 0:c8cd09e8b137 | 159 | * PLL_M = 1 |
EricLew | 0:c8cd09e8b137 | 160 | * PLL_N = 40 |
EricLew | 0:c8cd09e8b137 | 161 | * PLL_R = 2 |
EricLew | 0:c8cd09e8b137 | 162 | * PLL_P = 7 |
EricLew | 0:c8cd09e8b137 | 163 | * PLL_Q = 4 |
EricLew | 0:c8cd09e8b137 | 164 | * Flash Latency(WS) = 4 |
EricLew | 0:c8cd09e8b137 | 165 | * @param None |
EricLew | 0:c8cd09e8b137 | 166 | * @retval None |
EricLew | 0:c8cd09e8b137 | 167 | */ |
EricLew | 0:c8cd09e8b137 | 168 | void SystemClock_Config(void) |
EricLew | 0:c8cd09e8b137 | 169 | { |
EricLew | 0:c8cd09e8b137 | 170 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
EricLew | 0:c8cd09e8b137 | 171 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
EricLew | 0:c8cd09e8b137 | 172 | |
EricLew | 0:c8cd09e8b137 | 173 | /* MSI is enabled after System reset, activate PLL with MSI as source */ |
EricLew | 0:c8cd09e8b137 | 174 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; |
EricLew | 0:c8cd09e8b137 | 175 | RCC_OscInitStruct.MSIState = RCC_MSI_ON; |
EricLew | 0:c8cd09e8b137 | 176 | RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; |
EricLew | 0:c8cd09e8b137 | 177 | RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; |
EricLew | 0:c8cd09e8b137 | 178 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
EricLew | 0:c8cd09e8b137 | 179 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; |
EricLew | 0:c8cd09e8b137 | 180 | RCC_OscInitStruct.PLL.PLLM = 1; |
EricLew | 0:c8cd09e8b137 | 181 | RCC_OscInitStruct.PLL.PLLN = 40; |
EricLew | 0:c8cd09e8b137 | 182 | RCC_OscInitStruct.PLL.PLLR = 2; |
EricLew | 0:c8cd09e8b137 | 183 | RCC_OscInitStruct.PLL.PLLP = 7; |
EricLew | 0:c8cd09e8b137 | 184 | RCC_OscInitStruct.PLL.PLLQ = 4; |
EricLew | 0:c8cd09e8b137 | 185 | if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
EricLew | 0:c8cd09e8b137 | 186 | { |
EricLew | 0:c8cd09e8b137 | 187 | /* Initialization Error */ |
EricLew | 0:c8cd09e8b137 | 188 | while(1); |
EricLew | 0:c8cd09e8b137 | 189 | } |
EricLew | 0:c8cd09e8b137 | 190 | |
EricLew | 0:c8cd09e8b137 | 191 | /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 |
EricLew | 0:c8cd09e8b137 | 192 | clocks dividers */ |
EricLew | 0:c8cd09e8b137 | 193 | RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); |
EricLew | 0:c8cd09e8b137 | 194 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
EricLew | 0:c8cd09e8b137 | 195 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
EricLew | 0:c8cd09e8b137 | 196 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
EricLew | 0:c8cd09e8b137 | 197 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
EricLew | 0:c8cd09e8b137 | 198 | if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) |
EricLew | 0:c8cd09e8b137 | 199 | { |
EricLew | 0:c8cd09e8b137 | 200 | /* Initialization Error */ |
EricLew | 0:c8cd09e8b137 | 201 | while(1); |
EricLew | 0:c8cd09e8b137 | 202 | } |
EricLew | 0:c8cd09e8b137 | 203 | } |
EricLew | 0:c8cd09e8b137 | 204 | |
EricLew | 0:c8cd09e8b137 | 205 | /** |
EricLew | 0:c8cd09e8b137 | 206 | * @brief DFSDM channels and filter initialization |
EricLew | 0:c8cd09e8b137 | 207 | * @param None |
EricLew | 0:c8cd09e8b137 | 208 | * @retval None |
EricLew | 0:c8cd09e8b137 | 209 | */ |
EricLew | 0:c8cd09e8b137 | 210 | static void DFSDM_Init(void) |
EricLew | 0:c8cd09e8b137 | 211 | { |
EricLew | 0:c8cd09e8b137 | 212 | /* Initialize channel 2 */ |
EricLew | 0:c8cd09e8b137 | 213 | __HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(&DfsdmChannelHandle); |
EricLew | 0:c8cd09e8b137 | 214 | DfsdmChannelHandle.Instance = DFSDM_Channel2; |
EricLew | 0:c8cd09e8b137 | 215 | DfsdmChannelHandle.Init.OutputClock.Activation = ENABLE; |
EricLew | 0:c8cd09e8b137 | 216 | DfsdmChannelHandle.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO; |
EricLew | 0:c8cd09e8b137 | 217 | DfsdmChannelHandle.Init.OutputClock.Divider = 4; /* 11.294MHz/4 = 2.82MHz */ |
EricLew | 0:c8cd09e8b137 | 218 | DfsdmChannelHandle.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS; |
EricLew | 0:c8cd09e8b137 | 219 | DfsdmChannelHandle.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 220 | DfsdmChannelHandle.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS; |
EricLew | 0:c8cd09e8b137 | 221 | DfsdmChannelHandle.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING; |
EricLew | 0:c8cd09e8b137 | 222 | DfsdmChannelHandle.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL; |
EricLew | 0:c8cd09e8b137 | 223 | DfsdmChannelHandle.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 224 | DfsdmChannelHandle.Init.Awd.Oversampling = 10; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 225 | DfsdmChannelHandle.Init.Offset = 0; |
EricLew | 0:c8cd09e8b137 | 226 | DfsdmChannelHandle.Init.RightBitShift = 2; |
EricLew | 0:c8cd09e8b137 | 227 | if(HAL_OK != HAL_DFSDM_ChannelInit(&DfsdmChannelHandle)) |
EricLew | 0:c8cd09e8b137 | 228 | { |
EricLew | 0:c8cd09e8b137 | 229 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 230 | } |
EricLew | 0:c8cd09e8b137 | 231 | |
EricLew | 0:c8cd09e8b137 | 232 | /* Initialize filter 0 */ |
EricLew | 0:c8cd09e8b137 | 233 | __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(&DfsdmFilterHandle); |
EricLew | 0:c8cd09e8b137 | 234 | DfsdmFilterHandle.Instance = DFSDM_Filter0; |
EricLew | 0:c8cd09e8b137 | 235 | DfsdmFilterHandle.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER; |
EricLew | 0:c8cd09e8b137 | 236 | DfsdmFilterHandle.Init.RegularParam.FastMode = ENABLE; |
EricLew | 0:c8cd09e8b137 | 237 | DfsdmFilterHandle.Init.RegularParam.DmaMode = ENABLE; |
EricLew | 0:c8cd09e8b137 | 238 | DfsdmFilterHandle.Init.InjectedParam.Trigger = DFSDM_FILTER_SW_TRIGGER; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 239 | DfsdmFilterHandle.Init.InjectedParam.ScanMode = ENABLE; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 240 | DfsdmFilterHandle.Init.InjectedParam.DmaMode = DISABLE; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 241 | DfsdmFilterHandle.Init.InjectedParam.ExtTrigger = DFSDM_FILTER_EXT_TRIG_TIM1_TRGO; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 242 | DfsdmFilterHandle.Init.InjectedParam.ExtTriggerEdge = DFSDM_FILTER_EXT_TRIG_RISING_EDGE; /* N.U. */ |
EricLew | 0:c8cd09e8b137 | 243 | DfsdmFilterHandle.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER; |
EricLew | 0:c8cd09e8b137 | 244 | DfsdmFilterHandle.Init.FilterParam.Oversampling = 64; /* 11.294MHz/(4*64) = 44.1KHz */ |
EricLew | 0:c8cd09e8b137 | 245 | DfsdmFilterHandle.Init.FilterParam.IntOversampling = 1; |
EricLew | 0:c8cd09e8b137 | 246 | if(HAL_OK != HAL_DFSDM_FilterInit(&DfsdmFilterHandle)) |
EricLew | 0:c8cd09e8b137 | 247 | { |
EricLew | 0:c8cd09e8b137 | 248 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 249 | } |
EricLew | 0:c8cd09e8b137 | 250 | |
EricLew | 0:c8cd09e8b137 | 251 | /* Configure regular channel and continuous mode for filter 0 */ |
EricLew | 0:c8cd09e8b137 | 252 | if(HAL_OK != HAL_DFSDM_FilterConfigRegChannel(&DfsdmFilterHandle, DFSDM_CHANNEL_2, DFSDM_CONTINUOUS_CONV_ON)) |
EricLew | 0:c8cd09e8b137 | 253 | { |
EricLew | 0:c8cd09e8b137 | 254 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 255 | } |
EricLew | 0:c8cd09e8b137 | 256 | } |
EricLew | 0:c8cd09e8b137 | 257 | |
EricLew | 0:c8cd09e8b137 | 258 | /** |
EricLew | 0:c8cd09e8b137 | 259 | * @brief Playback initialization |
EricLew | 0:c8cd09e8b137 | 260 | * @param None |
EricLew | 0:c8cd09e8b137 | 261 | * @retval None |
EricLew | 0:c8cd09e8b137 | 262 | */ |
EricLew | 0:c8cd09e8b137 | 263 | static void Playback_Init(void) |
EricLew | 0:c8cd09e8b137 | 264 | { |
EricLew | 0:c8cd09e8b137 | 265 | /* Initialize SAI */ |
EricLew | 0:c8cd09e8b137 | 266 | __HAL_SAI_RESET_HANDLE_STATE(&SaiHandle); |
EricLew | 0:c8cd09e8b137 | 267 | |
EricLew | 0:c8cd09e8b137 | 268 | SaiHandle.Instance = SAI1_Block_A; |
EricLew | 0:c8cd09e8b137 | 269 | |
EricLew | 0:c8cd09e8b137 | 270 | SaiHandle.Init.AudioMode = SAI_MODEMASTER_TX; |
EricLew | 0:c8cd09e8b137 | 271 | SaiHandle.Init.Synchro = SAI_ASYNCHRONOUS; |
EricLew | 0:c8cd09e8b137 | 272 | SaiHandle.Init.SynchroExt = SAI_SYNCEXT_DISABLE; |
EricLew | 0:c8cd09e8b137 | 273 | SaiHandle.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; |
EricLew | 0:c8cd09e8b137 | 274 | SaiHandle.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; |
EricLew | 0:c8cd09e8b137 | 275 | SaiHandle.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF; |
EricLew | 0:c8cd09e8b137 | 276 | SaiHandle.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_44K; |
EricLew | 0:c8cd09e8b137 | 277 | SaiHandle.Init.Mckdiv = 0; /* N.U */ |
EricLew | 0:c8cd09e8b137 | 278 | SaiHandle.Init.MonoStereoMode = SAI_STEREOMODE; |
EricLew | 0:c8cd09e8b137 | 279 | SaiHandle.Init.CompandingMode = SAI_NOCOMPANDING; |
EricLew | 0:c8cd09e8b137 | 280 | SaiHandle.Init.TriState = SAI_OUTPUT_NOTRELEASED; |
EricLew | 0:c8cd09e8b137 | 281 | SaiHandle.Init.Protocol = SAI_FREE_PROTOCOL; |
EricLew | 0:c8cd09e8b137 | 282 | SaiHandle.Init.DataSize = SAI_DATASIZE_16; |
EricLew | 0:c8cd09e8b137 | 283 | SaiHandle.Init.FirstBit = SAI_FIRSTBIT_MSB; |
EricLew | 0:c8cd09e8b137 | 284 | SaiHandle.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; |
EricLew | 0:c8cd09e8b137 | 285 | |
EricLew | 0:c8cd09e8b137 | 286 | SaiHandle.FrameInit.FrameLength = 32; |
EricLew | 0:c8cd09e8b137 | 287 | SaiHandle.FrameInit.ActiveFrameLength = 16; |
EricLew | 0:c8cd09e8b137 | 288 | SaiHandle.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; |
EricLew | 0:c8cd09e8b137 | 289 | SaiHandle.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; |
EricLew | 0:c8cd09e8b137 | 290 | SaiHandle.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; |
EricLew | 0:c8cd09e8b137 | 291 | |
EricLew | 0:c8cd09e8b137 | 292 | SaiHandle.SlotInit.FirstBitOffset = 0; |
EricLew | 0:c8cd09e8b137 | 293 | SaiHandle.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE; |
EricLew | 0:c8cd09e8b137 | 294 | SaiHandle.SlotInit.SlotNumber = 2; |
EricLew | 0:c8cd09e8b137 | 295 | SaiHandle.SlotInit.SlotActive = (SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1); |
EricLew | 0:c8cd09e8b137 | 296 | |
EricLew | 0:c8cd09e8b137 | 297 | if(HAL_OK != HAL_SAI_Init(&SaiHandle)) |
EricLew | 0:c8cd09e8b137 | 298 | { |
EricLew | 0:c8cd09e8b137 | 299 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 300 | } |
EricLew | 0:c8cd09e8b137 | 301 | |
EricLew | 0:c8cd09e8b137 | 302 | /* Enable SAI to generate clock used by audio driver */ |
EricLew | 0:c8cd09e8b137 | 303 | __HAL_SAI_ENABLE(&SaiHandle); |
EricLew | 0:c8cd09e8b137 | 304 | |
EricLew | 0:c8cd09e8b137 | 305 | /* Initialize audio driver */ |
EricLew | 0:c8cd09e8b137 | 306 | if(CS43L22_ID != cs43l22_drv.ReadID(AUDIO_I2C_ADDRESS)) |
EricLew | 0:c8cd09e8b137 | 307 | { |
EricLew | 0:c8cd09e8b137 | 308 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 309 | } |
EricLew | 0:c8cd09e8b137 | 310 | audio_drv = &cs43l22_drv; |
EricLew | 0:c8cd09e8b137 | 311 | audio_drv->Reset(AUDIO_I2C_ADDRESS); |
EricLew | 0:c8cd09e8b137 | 312 | if(0 != audio_drv->Init(AUDIO_I2C_ADDRESS, OUTPUT_DEVICE_HEADPHONE, 90, AUDIO_FREQUENCY_44K)) |
EricLew | 0:c8cd09e8b137 | 313 | { |
EricLew | 0:c8cd09e8b137 | 314 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 315 | } |
EricLew | 0:c8cd09e8b137 | 316 | } |
EricLew | 0:c8cd09e8b137 | 317 | |
EricLew | 0:c8cd09e8b137 | 318 | /** |
EricLew | 0:c8cd09e8b137 | 319 | * @brief This function is executed in case of error occurrence. |
EricLew | 0:c8cd09e8b137 | 320 | * @param None |
EricLew | 0:c8cd09e8b137 | 321 | * @retval None |
EricLew | 0:c8cd09e8b137 | 322 | */ |
EricLew | 0:c8cd09e8b137 | 323 | void Error_Handler(void) |
EricLew | 0:c8cd09e8b137 | 324 | { |
EricLew | 0:c8cd09e8b137 | 325 | while (1) |
EricLew | 0:c8cd09e8b137 | 326 | { |
EricLew | 0:c8cd09e8b137 | 327 | /* Toggle LED4 with a period of one second */ |
EricLew | 0:c8cd09e8b137 | 328 | BSP_LED_Toggle(LED4); |
EricLew | 0:c8cd09e8b137 | 329 | HAL_Delay(1000); |
EricLew | 0:c8cd09e8b137 | 330 | } |
EricLew | 0:c8cd09e8b137 | 331 | } |
EricLew | 0:c8cd09e8b137 | 332 | |
EricLew | 0:c8cd09e8b137 | 333 | /** |
EricLew | 0:c8cd09e8b137 | 334 | * @brief Initializes the DFSDM channel MSP. |
EricLew | 0:c8cd09e8b137 | 335 | * @param hdfsdm_channel : DFSDM channel handle. |
EricLew | 0:c8cd09e8b137 | 336 | * @retval None |
EricLew | 0:c8cd09e8b137 | 337 | */ |
EricLew | 3:233580d5c68e | 338 | |
EricLew | 3:233580d5c68e | 339 | |
EricLew | 0:c8cd09e8b137 | 340 | void HAL_DFSDM_ChannelMspInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel) |
EricLew | 0:c8cd09e8b137 | 341 | { |
EricLew | 0:c8cd09e8b137 | 342 | /* Init of clock, gpio and PLLSAI1 clock */ |
EricLew | 0:c8cd09e8b137 | 343 | GPIO_InitTypeDef GPIO_Init; |
EricLew | 0:c8cd09e8b137 | 344 | RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct; |
EricLew | 0:c8cd09e8b137 | 345 | |
EricLew | 0:c8cd09e8b137 | 346 | /* Enable DFSDM clock */ |
EricLew | 0:c8cd09e8b137 | 347 | __HAL_RCC_DFSDM_CLK_ENABLE(); |
EricLew | 0:c8cd09e8b137 | 348 | |
EricLew | 0:c8cd09e8b137 | 349 | /* Configure PE9 for DFSDM_CKOUT and PE7 for DFSDM_DATIN2 */ |
EricLew | 0:c8cd09e8b137 | 350 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
EricLew | 0:c8cd09e8b137 | 351 | GPIO_Init.Mode = GPIO_MODE_AF_PP; |
EricLew | 0:c8cd09e8b137 | 352 | GPIO_Init.Pull = GPIO_PULLDOWN; |
EricLew | 0:c8cd09e8b137 | 353 | GPIO_Init.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
EricLew | 0:c8cd09e8b137 | 354 | GPIO_Init.Alternate = GPIO_AF6_DFSDM; |
EricLew | 0:c8cd09e8b137 | 355 | GPIO_Init.Pin = GPIO_PIN_9; |
EricLew | 0:c8cd09e8b137 | 356 | HAL_GPIO_Init(GPIOE, &GPIO_Init); |
EricLew | 0:c8cd09e8b137 | 357 | GPIO_Init.Pin = GPIO_PIN_7; |
EricLew | 0:c8cd09e8b137 | 358 | HAL_GPIO_Init(GPIOE, &GPIO_Init); |
EricLew | 0:c8cd09e8b137 | 359 | |
EricLew | 0:c8cd09e8b137 | 360 | /* Configure and enable PLLSAI1 clock to generate 11.294MHz */ |
EricLew | 0:c8cd09e8b137 | 361 | RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1; |
EricLew | 0:c8cd09e8b137 | 362 | RCC_PeriphCLKInitStruct.PLLSAI1.PLLSAI1N = 48; |
EricLew | 0:c8cd09e8b137 | 363 | RCC_PeriphCLKInitStruct.PLLSAI1.PLLSAI1P = 17; |
EricLew | 0:c8cd09e8b137 | 364 | RCC_PeriphCLKInitStruct.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_SAI1CLK; |
EricLew | 0:c8cd09e8b137 | 365 | RCC_PeriphCLKInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLLSAI1; |
EricLew | 0:c8cd09e8b137 | 366 | if(HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct) != HAL_OK) |
EricLew | 0:c8cd09e8b137 | 367 | { |
EricLew | 0:c8cd09e8b137 | 368 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 369 | } |
EricLew | 0:c8cd09e8b137 | 370 | } |
EricLew | 0:c8cd09e8b137 | 371 | |
EricLew | 0:c8cd09e8b137 | 372 | /** |
EricLew | 0:c8cd09e8b137 | 373 | * @brief Initializes the DFSDM filter MSP. |
EricLew | 0:c8cd09e8b137 | 374 | * @param hdfsdm_filter : DFSDM filter handle. |
EricLew | 0:c8cd09e8b137 | 375 | * @retval None |
EricLew | 0:c8cd09e8b137 | 376 | */ |
EricLew | 0:c8cd09e8b137 | 377 | void HAL_DFSDM_FilterMspInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter) |
EricLew | 0:c8cd09e8b137 | 378 | { |
EricLew | 0:c8cd09e8b137 | 379 | /* Configure DMA1_Channel4 */ |
EricLew | 0:c8cd09e8b137 | 380 | __HAL_RCC_DMA1_CLK_ENABLE(); |
EricLew | 0:c8cd09e8b137 | 381 | hDfsdmDma.Init.Request = DMA_REQUEST_0; |
EricLew | 0:c8cd09e8b137 | 382 | hDfsdmDma.Init.Direction = DMA_PERIPH_TO_MEMORY; |
EricLew | 0:c8cd09e8b137 | 383 | hDfsdmDma.Init.PeriphInc = DMA_PINC_DISABLE; |
EricLew | 0:c8cd09e8b137 | 384 | hDfsdmDma.Init.MemInc = DMA_MINC_ENABLE; |
EricLew | 0:c8cd09e8b137 | 385 | hDfsdmDma.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; |
EricLew | 0:c8cd09e8b137 | 386 | hDfsdmDma.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; |
EricLew | 0:c8cd09e8b137 | 387 | hDfsdmDma.Init.Mode = DMA_CIRCULAR; |
EricLew | 0:c8cd09e8b137 | 388 | hDfsdmDma.Init.Priority = DMA_PRIORITY_HIGH; |
EricLew | 0:c8cd09e8b137 | 389 | hDfsdmDma.Instance = DMA1_Channel4; |
EricLew | 0:c8cd09e8b137 | 390 | __HAL_LINKDMA(hdfsdm_filter, hdmaReg, hDfsdmDma); |
EricLew | 0:c8cd09e8b137 | 391 | if (HAL_OK != HAL_DMA_Init(&hDfsdmDma)) |
EricLew | 0:c8cd09e8b137 | 392 | { |
EricLew | 0:c8cd09e8b137 | 393 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 394 | } |
EricLew | 0:c8cd09e8b137 | 395 | HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0x01, 0); |
EricLew | 0:c8cd09e8b137 | 396 | HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn); |
EricLew | 0:c8cd09e8b137 | 397 | } |
EricLew | 0:c8cd09e8b137 | 398 | |
EricLew | 0:c8cd09e8b137 | 399 | /** |
EricLew | 0:c8cd09e8b137 | 400 | * @brief SAI MSP Init. |
EricLew | 0:c8cd09e8b137 | 401 | * @param hsai : pointer to a SAI_HandleTypeDef structure that contains |
EricLew | 0:c8cd09e8b137 | 402 | * the configuration information for SAI module. |
EricLew | 0:c8cd09e8b137 | 403 | * @retval None |
EricLew | 0:c8cd09e8b137 | 404 | */ |
EricLew | 0:c8cd09e8b137 | 405 | void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai) |
EricLew | 0:c8cd09e8b137 | 406 | { |
EricLew | 0:c8cd09e8b137 | 407 | GPIO_InitTypeDef GPIO_Init; |
EricLew | 0:c8cd09e8b137 | 408 | |
EricLew | 0:c8cd09e8b137 | 409 | /* Enable SAI1 clock */ |
EricLew | 0:c8cd09e8b137 | 410 | __HAL_RCC_SAI1_CLK_ENABLE(); |
EricLew | 0:c8cd09e8b137 | 411 | |
EricLew | 0:c8cd09e8b137 | 412 | /* Configure GPIOs used for SAI1 */ |
EricLew | 0:c8cd09e8b137 | 413 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
EricLew | 0:c8cd09e8b137 | 414 | GPIO_Init.Mode = GPIO_MODE_AF_PP; |
EricLew | 0:c8cd09e8b137 | 415 | GPIO_Init.Pull = GPIO_NOPULL; |
EricLew | 0:c8cd09e8b137 | 416 | GPIO_Init.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
EricLew | 0:c8cd09e8b137 | 417 | GPIO_Init.Alternate = GPIO_AF13_SAI1; |
EricLew | 0:c8cd09e8b137 | 418 | GPIO_Init.Pin = (GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6); |
EricLew | 0:c8cd09e8b137 | 419 | HAL_GPIO_Init(GPIOE, &GPIO_Init); |
EricLew | 0:c8cd09e8b137 | 420 | |
EricLew | 0:c8cd09e8b137 | 421 | /* Configure DMA used for SAI1 */ |
EricLew | 0:c8cd09e8b137 | 422 | __HAL_RCC_DMA2_CLK_ENABLE(); |
EricLew | 0:c8cd09e8b137 | 423 | hSaiDma.Init.Request = DMA_REQUEST_1; |
EricLew | 0:c8cd09e8b137 | 424 | hSaiDma.Init.Direction = DMA_MEMORY_TO_PERIPH; |
EricLew | 0:c8cd09e8b137 | 425 | hSaiDma.Init.PeriphInc = DMA_PINC_DISABLE; |
EricLew | 0:c8cd09e8b137 | 426 | hSaiDma.Init.MemInc = DMA_MINC_ENABLE; |
EricLew | 0:c8cd09e8b137 | 427 | hSaiDma.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; |
EricLew | 0:c8cd09e8b137 | 428 | hSaiDma.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; |
EricLew | 0:c8cd09e8b137 | 429 | hSaiDma.Init.Mode = DMA_CIRCULAR; |
EricLew | 0:c8cd09e8b137 | 430 | hSaiDma.Init.Priority = DMA_PRIORITY_HIGH; |
EricLew | 0:c8cd09e8b137 | 431 | hSaiDma.Instance = DMA2_Channel1; |
EricLew | 0:c8cd09e8b137 | 432 | __HAL_LINKDMA(hsai, hdmatx, hSaiDma); |
EricLew | 0:c8cd09e8b137 | 433 | if (HAL_OK != HAL_DMA_Init(&hSaiDma)) |
EricLew | 0:c8cd09e8b137 | 434 | { |
EricLew | 0:c8cd09e8b137 | 435 | Error_Handler(); |
EricLew | 0:c8cd09e8b137 | 436 | } |
EricLew | 0:c8cd09e8b137 | 437 | HAL_NVIC_SetPriority(DMA2_Channel1_IRQn, 0x01, 0); |
EricLew | 0:c8cd09e8b137 | 438 | HAL_NVIC_EnableIRQ(DMA2_Channel1_IRQn); |
EricLew | 0:c8cd09e8b137 | 439 | } |
EricLew | 0:c8cd09e8b137 | 440 | |
EricLew | 0:c8cd09e8b137 | 441 | /** |
EricLew | 0:c8cd09e8b137 | 442 | * @brief Half regular conversion complete callback. |
EricLew | 0:c8cd09e8b137 | 443 | * @param hdfsdm_filter : DFSDM filter handle. |
EricLew | 0:c8cd09e8b137 | 444 | * @retval None |
EricLew | 0:c8cd09e8b137 | 445 | */ |
EricLew | 0:c8cd09e8b137 | 446 | void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter) |
EricLew | 0:c8cd09e8b137 | 447 | { |
EricLew | 0:c8cd09e8b137 | 448 | DmaRecHalfBuffCplt = 1; |
EricLew | 0:c8cd09e8b137 | 449 | } |
EricLew | 0:c8cd09e8b137 | 450 | |
EricLew | 0:c8cd09e8b137 | 451 | /** |
EricLew | 0:c8cd09e8b137 | 452 | * @brief Regular conversion complete callback. |
EricLew | 0:c8cd09e8b137 | 453 | * @note In interrupt mode, user has to read conversion value in this function |
EricLew | 0:c8cd09e8b137 | 454 | using HAL_DFSDM_FilterGetRegularValue. |
EricLew | 0:c8cd09e8b137 | 455 | * @param hdfsdm_filter : DFSDM filter handle. |
EricLew | 0:c8cd09e8b137 | 456 | * @retval None |
EricLew | 0:c8cd09e8b137 | 457 | */ |
EricLew | 0:c8cd09e8b137 | 458 | void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter) |
EricLew | 0:c8cd09e8b137 | 459 | { |
EricLew | 0:c8cd09e8b137 | 460 | DmaRecBuffCplt = 1; |
EricLew | 0:c8cd09e8b137 | 461 | } |
EricLew | 0:c8cd09e8b137 | 462 | |
EricLew | 0:c8cd09e8b137 | 463 | #ifdef USE_FULL_ASSERT |
EricLew | 0:c8cd09e8b137 | 464 | /** |
EricLew | 0:c8cd09e8b137 | 465 | * @brief Reports the name of the source file and the source line number |
EricLew | 0:c8cd09e8b137 | 466 | * where the assert_param error has occurred. |
EricLew | 0:c8cd09e8b137 | 467 | * @param file: pointer to the source file name |
EricLew | 0:c8cd09e8b137 | 468 | * @param line: assert_param error line source number |
EricLew | 0:c8cd09e8b137 | 469 | * @retval None |
EricLew | 0:c8cd09e8b137 | 470 | */ |
EricLew | 0:c8cd09e8b137 | 471 | void assert_failed(uint8_t* file, uint32_t line) |
EricLew | 0:c8cd09e8b137 | 472 | { |
EricLew | 0:c8cd09e8b137 | 473 | /* User can add his own implementation to report the file name and line number, |
EricLew | 0:c8cd09e8b137 | 474 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
EricLew | 0:c8cd09e8b137 | 475 | |
EricLew | 0:c8cd09e8b137 | 476 | /* Infinite loop */ |
EricLew | 0:c8cd09e8b137 | 477 | while (1) |
EricLew | 0:c8cd09e8b137 | 478 | { |
EricLew | 0:c8cd09e8b137 | 479 | } |
EricLew | 0:c8cd09e8b137 | 480 | } |
EricLew | 0:c8cd09e8b137 | 481 | #endif |
EricLew | 0:c8cd09e8b137 | 482 | |
EricLew | 0:c8cd09e8b137 | 483 | /** |
EricLew | 0:c8cd09e8b137 | 484 | * @} |
EricLew | 0:c8cd09e8b137 | 485 | */ |
EricLew | 0:c8cd09e8b137 | 486 | |
EricLew | 0:c8cd09e8b137 | 487 | /** |
EricLew | 0:c8cd09e8b137 | 488 | * @} |
EricLew | 0:c8cd09e8b137 | 489 | */ |
EricLew | 0:c8cd09e8b137 | 490 | |
EricLew | 0:c8cd09e8b137 | 491 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
EricLew | 0:c8cd09e8b137 | 492 |