The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Thu Nov 27 13:33:22 2014 +0000
Revision:
92:4fc01daae5a5
Parent:
89:552587b429a1
Release 92 of the mbed libray

Main changes:

- nRF51822: fixed pin assignment issues
- ST targets moving to the STM32Cube driver
- LPC1439: fixed serial interrupt issue
- first Cortex-A platform supported in mbed (RZ_A1H)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 89:552587b429a1 1 /**
bogdanm 89:552587b429a1 2 ******************************************************************************
bogdanm 89:552587b429a1 3 * @file stm32f4xx_hal_sai.h
bogdanm 89:552587b429a1 4 * @author MCD Application Team
bogdanm 92:4fc01daae5a5 5 * @version V1.1.0
bogdanm 92:4fc01daae5a5 6 * @date 19-June-2014
bogdanm 89:552587b429a1 7 * @brief Header file of SAI HAL module.
bogdanm 89:552587b429a1 8 ******************************************************************************
bogdanm 89:552587b429a1 9 * @attention
bogdanm 89:552587b429a1 10 *
bogdanm 89:552587b429a1 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 89:552587b429a1 12 *
bogdanm 89:552587b429a1 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 89:552587b429a1 14 * are permitted provided that the following conditions are met:
bogdanm 89:552587b429a1 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 89:552587b429a1 16 * this list of conditions and the following disclaimer.
bogdanm 89:552587b429a1 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 89:552587b429a1 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 89:552587b429a1 19 * and/or other materials provided with the distribution.
bogdanm 89:552587b429a1 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 89:552587b429a1 21 * may be used to endorse or promote products derived from this software
bogdanm 89:552587b429a1 22 * without specific prior written permission.
bogdanm 89:552587b429a1 23 *
bogdanm 89:552587b429a1 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 89:552587b429a1 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 89:552587b429a1 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 89:552587b429a1 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 89:552587b429a1 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 89:552587b429a1 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 89:552587b429a1 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 89:552587b429a1 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 89:552587b429a1 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 89:552587b429a1 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 89:552587b429a1 34 *
bogdanm 89:552587b429a1 35 ******************************************************************************
bogdanm 89:552587b429a1 36 */
bogdanm 89:552587b429a1 37
bogdanm 89:552587b429a1 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 89:552587b429a1 39 #ifndef __STM32F4xx_HAL_SAI_H
bogdanm 89:552587b429a1 40 #define __STM32F4xx_HAL_SAI_H
bogdanm 89:552587b429a1 41
bogdanm 89:552587b429a1 42 #ifdef __cplusplus
bogdanm 89:552587b429a1 43 extern "C" {
bogdanm 89:552587b429a1 44 #endif
bogdanm 89:552587b429a1 45
bogdanm 89:552587b429a1 46 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
bogdanm 89:552587b429a1 47
bogdanm 89:552587b429a1 48 /* Includes ------------------------------------------------------------------*/
bogdanm 89:552587b429a1 49 #include "stm32f4xx_hal_def.h"
bogdanm 89:552587b429a1 50
bogdanm 89:552587b429a1 51 /** @addtogroup STM32F4xx_HAL_Driver
bogdanm 89:552587b429a1 52 * @{
bogdanm 89:552587b429a1 53 */
bogdanm 89:552587b429a1 54
bogdanm 89:552587b429a1 55 /** @addtogroup SAI
bogdanm 89:552587b429a1 56 * @{
bogdanm 89:552587b429a1 57 */
bogdanm 89:552587b429a1 58
bogdanm 89:552587b429a1 59 /* Exported types ------------------------------------------------------------*/
bogdanm 89:552587b429a1 60
bogdanm 89:552587b429a1 61 /**
bogdanm 89:552587b429a1 62 * @brief SAI Init Structure definition
bogdanm 89:552587b429a1 63 */
bogdanm 89:552587b429a1 64 typedef struct
bogdanm 89:552587b429a1 65 {
bogdanm 89:552587b429a1 66 uint32_t Protocol; /*!< Specifies the SAI Block protocol.
bogdanm 89:552587b429a1 67 This parameter can be a value of @ref SAI_Block_Protocol */
bogdanm 89:552587b429a1 68
bogdanm 89:552587b429a1 69 uint32_t AudioMode; /*!< Specifies the SAI Block audio Mode.
bogdanm 89:552587b429a1 70 This parameter can be a value of @ref SAI_Block_Mode */
bogdanm 89:552587b429a1 71
bogdanm 89:552587b429a1 72 uint32_t DataSize; /*!< Specifies the SAI Block data size.
bogdanm 89:552587b429a1 73 This parameter can be a value of @ref SAI_Block_Data_Size */
bogdanm 89:552587b429a1 74
bogdanm 89:552587b429a1 75 uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
bogdanm 89:552587b429a1 76 This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */
bogdanm 89:552587b429a1 77
bogdanm 89:552587b429a1 78 uint32_t ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity.
bogdanm 89:552587b429a1 79 This parameter can be a value of @ref SAI_Block_Clock_Strobing */
bogdanm 89:552587b429a1 80
bogdanm 89:552587b429a1 81 uint32_t Synchro; /*!< Specifies SAI Block synchronization
bogdanm 89:552587b429a1 82 This parameter can be a value of @ref SAI_Block_Synchronization */
bogdanm 89:552587b429a1 83
bogdanm 89:552587b429a1 84 uint32_t OutputDrive; /*!< Specifies when SAI Block outputs are driven.
bogdanm 89:552587b429a1 85 This parameter can be a value of @ref SAI_Block_Output_Drive
bogdanm 89:552587b429a1 86 @note this value has to be set before enabling the audio block
bogdanm 89:552587b429a1 87 but after the audio block configuration. */
bogdanm 89:552587b429a1 88
bogdanm 89:552587b429a1 89 uint32_t NoDivider; /*!< Specifies whether master clock will be divided or not.
bogdanm 89:552587b429a1 90 This parameter can be a value of @ref SAI_Block_NoDivider
bogdanm 89:552587b429a1 91 @note: If bit NODIV in the SAI_xCR1 register is cleared, the frame length
bogdanm 89:552587b429a1 92 should be aligned to a number equal to a power of 2, from 8 to 256.
bogdanm 89:552587b429a1 93 If bit NODIV in the SAI_xCR1 register is set, the frame length can
bogdanm 89:552587b429a1 94 take any of the values without constraint since the input clock of
bogdanm 89:552587b429a1 95 the audio block should be equal to the bit clock.
bogdanm 89:552587b429a1 96 There is no MCLK_x clock which can be output. */
bogdanm 89:552587b429a1 97
bogdanm 89:552587b429a1 98 uint32_t FIFOThreshold; /*!< Specifies SAI Block FIFO threshold.
bogdanm 89:552587b429a1 99 This parameter can be a value of @ref SAI_Block_Fifo_Threshold */
bogdanm 89:552587b429a1 100
bogdanm 89:552587b429a1 101 uint32_t ClockSource; /*!< Specifies the SAI Block x Clock source.
bogdanm 89:552587b429a1 102 This parameter can be a value of @ref SAI_Clock_Source
bogdanm 89:552587b429a1 103 @note: If ClockSource is equal to SAI_CLKSource_Ext, the PLLI2S
bogdanm 89:552587b429a1 104 and PLLSAI divisions factors will be ignored. */
bogdanm 89:552587b429a1 105
bogdanm 89:552587b429a1 106 uint32_t AudioFrequency; /*!< Specifies the audio frequency sampling.
bogdanm 89:552587b429a1 107 This parameter can be a value of @ref SAI_Audio_Frequency */
bogdanm 89:552587b429a1 108
bogdanm 89:552587b429a1 109 }SAI_InitTypeDef;
bogdanm 89:552587b429a1 110
bogdanm 89:552587b429a1 111 /**
bogdanm 89:552587b429a1 112 * @brief SAI Block Frame Init structure definition
bogdanm 89:552587b429a1 113 */
bogdanm 89:552587b429a1 114
bogdanm 89:552587b429a1 115 typedef struct
bogdanm 89:552587b429a1 116 {
bogdanm 89:552587b429a1 117
bogdanm 89:552587b429a1 118 uint32_t FrameLength; /*!< Specifies the Frame length, the number of SCK clocks for each audio frame.
bogdanm 89:552587b429a1 119 This parameter must be a number between Min_Data = 8 and Max_Data = 256.
bogdanm 89:552587b429a1 120 @note: If master clock MCLK_x pin is declared as an output, the frame length
bogdanm 89:552587b429a1 121 should be aligned to a number equal to power of 2 in order to keep
bogdanm 89:552587b429a1 122 in an audio frame, an integer number of MCLK pulses by bit Clock. */
bogdanm 89:552587b429a1 123
bogdanm 89:552587b429a1 124 uint32_t ActiveFrameLength; /*!< Specifies the Frame synchronization active level length.
bogdanm 89:552587b429a1 125 This Parameter specifies the length in number of bit clock (SCK + 1)
bogdanm 89:552587b429a1 126 of the active level of FS signal in audio frame.
bogdanm 89:552587b429a1 127 This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
bogdanm 89:552587b429a1 128
bogdanm 89:552587b429a1 129 uint32_t FSDefinition; /*!< Specifies the Frame synchronization definition.
bogdanm 89:552587b429a1 130 This parameter can be a value of @ref SAI_Block_FS_Definition */
bogdanm 89:552587b429a1 131
bogdanm 89:552587b429a1 132 uint32_t FSPolarity; /*!< Specifies the Frame synchronization Polarity.
bogdanm 89:552587b429a1 133 This parameter can be a value of @ref SAI_Block_FS_Polarity */
bogdanm 89:552587b429a1 134
bogdanm 89:552587b429a1 135 uint32_t FSOffset; /*!< Specifies the Frame synchronization Offset.
bogdanm 89:552587b429a1 136 This parameter can be a value of @ref SAI_Block_FS_Offset */
bogdanm 89:552587b429a1 137
bogdanm 89:552587b429a1 138 }SAI_FrameInitTypeDef;
bogdanm 89:552587b429a1 139
bogdanm 89:552587b429a1 140 /**
bogdanm 89:552587b429a1 141 * @brief SAI Block Slot Init Structure definition
bogdanm 89:552587b429a1 142 */
bogdanm 89:552587b429a1 143
bogdanm 89:552587b429a1 144 typedef struct
bogdanm 89:552587b429a1 145 {
bogdanm 89:552587b429a1 146 uint32_t FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot.
bogdanm 89:552587b429a1 147 This parameter must be a number between Min_Data = 0 and Max_Data = 24 */
bogdanm 89:552587b429a1 148
bogdanm 89:552587b429a1 149 uint32_t SlotSize; /*!< Specifies the Slot Size.
bogdanm 89:552587b429a1 150 This parameter can be a value of @ref SAI_Block_Slot_Size */
bogdanm 89:552587b429a1 151
bogdanm 89:552587b429a1 152 uint32_t SlotNumber; /*!< Specifies the number of slot in the audio frame.
bogdanm 89:552587b429a1 153 This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
bogdanm 89:552587b429a1 154
bogdanm 89:552587b429a1 155 uint32_t SlotActive; /*!< Specifies the slots in audio frame that will be activated.
bogdanm 89:552587b429a1 156 This parameter can be a value of @ref SAI_Block_Slot_Active */
bogdanm 89:552587b429a1 157 }SAI_SlotInitTypeDef;
bogdanm 89:552587b429a1 158
bogdanm 89:552587b429a1 159 /**
bogdanm 89:552587b429a1 160 * @brief HAL State structures definition
bogdanm 89:552587b429a1 161 */
bogdanm 89:552587b429a1 162 typedef enum
bogdanm 89:552587b429a1 163 {
bogdanm 89:552587b429a1 164 HAL_SAI_STATE_RESET = 0x00, /*!< SAI not yet initialized or disabled */
bogdanm 89:552587b429a1 165 HAL_SAI_STATE_READY = 0x01, /*!< SAI initialized and ready for use */
bogdanm 89:552587b429a1 166 HAL_SAI_STATE_BUSY = 0x02, /*!< SAI internal process is ongoing */
bogdanm 89:552587b429a1 167 HAL_SAI_STATE_BUSY_TX = 0x12, /*!< Data transmission process is ongoing */
bogdanm 89:552587b429a1 168 HAL_SAI_STATE_BUSY_RX = 0x22, /*!< Data reception process is ongoing */
bogdanm 89:552587b429a1 169 HAL_SAI_STATE_TIMEOUT = 0x03, /*!< SAI timeout state */
bogdanm 89:552587b429a1 170 HAL_SAI_STATE_ERROR = 0x04 /*!< SAI error state */
bogdanm 89:552587b429a1 171
bogdanm 89:552587b429a1 172 }HAL_SAI_StateTypeDef;
bogdanm 89:552587b429a1 173
bogdanm 89:552587b429a1 174 /**
bogdanm 89:552587b429a1 175 * @brief SAI handle Structure definition
bogdanm 89:552587b429a1 176 */
bogdanm 89:552587b429a1 177 typedef struct
bogdanm 89:552587b429a1 178 {
bogdanm 89:552587b429a1 179 SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */
bogdanm 89:552587b429a1 180
bogdanm 89:552587b429a1 181 SAI_InitTypeDef Init; /*!< SAI communication parameters */
bogdanm 89:552587b429a1 182
bogdanm 89:552587b429a1 183 SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters */
bogdanm 89:552587b429a1 184
bogdanm 89:552587b429a1 185 SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */
bogdanm 89:552587b429a1 186
bogdanm 89:552587b429a1 187 uint16_t *pTxBuffPtr; /*!< Pointer to SAI Tx transfer Buffer */
bogdanm 89:552587b429a1 188
bogdanm 89:552587b429a1 189 uint16_t TxXferSize; /*!< SAI Tx transfer size */
bogdanm 89:552587b429a1 190
bogdanm 89:552587b429a1 191 uint16_t TxXferCount; /*!< SAI Tx transfer counter */
bogdanm 89:552587b429a1 192
bogdanm 89:552587b429a1 193 uint16_t *pRxBuffPtr; /*!< Pointer to SAI Rx transfer buffer */
bogdanm 89:552587b429a1 194
bogdanm 89:552587b429a1 195 uint16_t RxXferSize; /*!< SAI Rx transfer size */
bogdanm 89:552587b429a1 196
bogdanm 89:552587b429a1 197 uint16_t RxXferCount; /*!< SAI Rx transfer counter */
bogdanm 89:552587b429a1 198
bogdanm 89:552587b429a1 199 DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */
bogdanm 89:552587b429a1 200
bogdanm 89:552587b429a1 201 DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */
bogdanm 89:552587b429a1 202
bogdanm 89:552587b429a1 203 HAL_LockTypeDef Lock; /*!< SAI locking object */
bogdanm 89:552587b429a1 204
bogdanm 89:552587b429a1 205 __IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */
bogdanm 89:552587b429a1 206
bogdanm 89:552587b429a1 207 __IO uint32_t ErrorCode; /*!< SAI Error code */
bogdanm 89:552587b429a1 208 }SAI_HandleTypeDef;
bogdanm 89:552587b429a1 209
bogdanm 89:552587b429a1 210 /* Exported constants --------------------------------------------------------*/
bogdanm 89:552587b429a1 211
bogdanm 89:552587b429a1 212 /** @defgroup SAI_Exported_Constants
bogdanm 89:552587b429a1 213 * @{
bogdanm 89:552587b429a1 214 */
bogdanm 89:552587b429a1 215 /** @defgroup SAI Error Code
bogdanm 89:552587b429a1 216 * @{
bogdanm 89:552587b429a1 217 */
bogdanm 89:552587b429a1 218 #define HAL_SAI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
bogdanm 89:552587b429a1 219 #define HAL_SAI_ERROR_OVR ((uint32_t)0x00000001) /*!< Overrun Error */
bogdanm 89:552587b429a1 220 #define HAL_SAI_ERROR_UDR ((uint32_t)0x00000002) /*!< Underrun error */
bogdanm 89:552587b429a1 221 #define HAL_SAI_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */
bogdanm 89:552587b429a1 222 /**
bogdanm 89:552587b429a1 223 * @}
bogdanm 89:552587b429a1 224 */
bogdanm 89:552587b429a1 225
bogdanm 89:552587b429a1 226 /** @defgroup SAI_Clock_Source
bogdanm 89:552587b429a1 227 * @{
bogdanm 89:552587b429a1 228 */
bogdanm 89:552587b429a1 229 #define SAI_CLKSOURCE_PLLSAI ((uint32_t)RCC_SAIACLKSOURCE_PLLSAI)
bogdanm 89:552587b429a1 230 #define SAI_CLKSOURCE_PLLI2S ((uint32_t)RCC_SAIACLKSOURCE_PLLI2S)
bogdanm 89:552587b429a1 231 #define SAI_CLKSOURCE_EXT ((uint32_t)RCC_SAIACLKSOURCE_EXT)
bogdanm 89:552587b429a1 232
bogdanm 89:552587b429a1 233 #define IS_SAI_CLK_SOURCE(SOURCE) (((SOURCE) == SAI_CLKSOURCE_PLLSAI) ||\
bogdanm 89:552587b429a1 234 ((SOURCE) == SAI_CLKSOURCE_PLLI2S) ||\
bogdanm 89:552587b429a1 235 ((SOURCE) == SAI_CLKSOURCE_EXT))
bogdanm 89:552587b429a1 236 /**
bogdanm 89:552587b429a1 237 * @}
bogdanm 89:552587b429a1 238 */
bogdanm 89:552587b429a1 239
bogdanm 89:552587b429a1 240 /** @defgroup SAI_Audio_Frequency
bogdanm 89:552587b429a1 241 * @{
bogdanm 89:552587b429a1 242 */
bogdanm 89:552587b429a1 243 #define SAI_AUDIO_FREQUENCY_192K ((uint32_t)192000)
bogdanm 89:552587b429a1 244 #define SAI_AUDIO_FREQUENCY_96K ((uint32_t)96000)
bogdanm 89:552587b429a1 245 #define SAI_AUDIO_FREQUENCY_48K ((uint32_t)48000)
bogdanm 89:552587b429a1 246 #define SAI_AUDIO_FREQUENCY_44K ((uint32_t)44100)
bogdanm 89:552587b429a1 247 #define SAI_AUDIO_FREQUENCY_32K ((uint32_t)32000)
bogdanm 89:552587b429a1 248 #define SAI_AUDIO_FREQUENCY_22K ((uint32_t)22050)
bogdanm 89:552587b429a1 249 #define SAI_AUDIO_FREQUENCY_16K ((uint32_t)16000)
bogdanm 89:552587b429a1 250 #define SAI_AUDIO_FREQUENCY_11K ((uint32_t)11025)
bogdanm 89:552587b429a1 251 #define SAI_AUDIO_FREQUENCY_8K ((uint32_t)8000)
bogdanm 89:552587b429a1 252
bogdanm 89:552587b429a1 253 #define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \
bogdanm 89:552587b429a1 254 ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \
bogdanm 89:552587b429a1 255 ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \
bogdanm 89:552587b429a1 256 ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \
bogdanm 89:552587b429a1 257 ((AUDIO) == SAI_AUDIO_FREQUENCY_8K))
bogdanm 89:552587b429a1 258 /**
bogdanm 89:552587b429a1 259 * @}
bogdanm 89:552587b429a1 260 */
bogdanm 89:552587b429a1 261
bogdanm 89:552587b429a1 262 /** @defgroup SAI_Block_Mode
bogdanm 89:552587b429a1 263 * @{
bogdanm 89:552587b429a1 264 */
bogdanm 89:552587b429a1 265 #define SAI_MODEMASTER_TX ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 266 #define SAI_MODEMASTER_RX ((uint32_t)0x00000001)
bogdanm 89:552587b429a1 267 #define SAI_MODESLAVE_TX ((uint32_t)0x00000002)
bogdanm 89:552587b429a1 268 #define SAI_MODESLAVE_RX ((uint32_t)0x00000003)
bogdanm 89:552587b429a1 269 #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \
bogdanm 89:552587b429a1 270 ((MODE) == SAI_MODEMASTER_RX) || \
bogdanm 89:552587b429a1 271 ((MODE) == SAI_MODESLAVE_TX) || \
bogdanm 89:552587b429a1 272 ((MODE) == SAI_MODESLAVE_RX))
bogdanm 89:552587b429a1 273 /**
bogdanm 89:552587b429a1 274 * @}
bogdanm 89:552587b429a1 275 */
bogdanm 89:552587b429a1 276
bogdanm 89:552587b429a1 277 /** @defgroup SAI_Block_Protocol
bogdanm 89:552587b429a1 278 * @{
bogdanm 89:552587b429a1 279 */
bogdanm 89:552587b429a1 280
bogdanm 89:552587b429a1 281 #define SAI_FREE_PROTOCOL ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 282 #define SAI_AC97_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_1)
bogdanm 89:552587b429a1 283
bogdanm 89:552587b429a1 284 #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \
bogdanm 89:552587b429a1 285 ((PROTOCOL) == SAI_AC97_PROTOCOL))
bogdanm 89:552587b429a1 286 /**
bogdanm 89:552587b429a1 287 * @}
bogdanm 89:552587b429a1 288 */
bogdanm 89:552587b429a1 289
bogdanm 89:552587b429a1 290 /** @defgroup SAI_Block_Data_Size
bogdanm 89:552587b429a1 291 * @{
bogdanm 89:552587b429a1 292 */
bogdanm 89:552587b429a1 293 #define SAI_DATASIZE_8 ((uint32_t)0x00000040)
bogdanm 89:552587b429a1 294 #define SAI_DATASIZE_10 ((uint32_t)0x00000060)
bogdanm 89:552587b429a1 295 #define SAI_DATASIZE_16 ((uint32_t)0x00000080)
bogdanm 89:552587b429a1 296 #define SAI_DATASIZE_20 ((uint32_t)0x000000A0)
bogdanm 89:552587b429a1 297 #define SAI_DATASIZE_24 ((uint32_t)0x000000C0)
bogdanm 89:552587b429a1 298 #define SAI_DATASIZE_32 ((uint32_t)0x000000E0)
bogdanm 89:552587b429a1 299
bogdanm 89:552587b429a1 300 #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \
bogdanm 89:552587b429a1 301 ((DATASIZE) == SAI_DATASIZE_10) || \
bogdanm 89:552587b429a1 302 ((DATASIZE) == SAI_DATASIZE_16) || \
bogdanm 89:552587b429a1 303 ((DATASIZE) == SAI_DATASIZE_20) || \
bogdanm 89:552587b429a1 304 ((DATASIZE) == SAI_DATASIZE_24) || \
bogdanm 89:552587b429a1 305 ((DATASIZE) == SAI_DATASIZE_32))
bogdanm 89:552587b429a1 306 /**
bogdanm 89:552587b429a1 307 * @}
bogdanm 89:552587b429a1 308 */
bogdanm 89:552587b429a1 309
bogdanm 89:552587b429a1 310 /** @defgroup SAI_Block_MSB_LSB_transmission
bogdanm 89:552587b429a1 311 * @{
bogdanm 89:552587b429a1 312 */
bogdanm 89:552587b429a1 313
bogdanm 89:552587b429a1 314 #define SAI_FIRSTBIT_MSB ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 315 #define SAI_FIRSTBIT_LSB ((uint32_t)SAI_xCR1_LSBFIRST)
bogdanm 89:552587b429a1 316
bogdanm 89:552587b429a1 317 #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \
bogdanm 89:552587b429a1 318 ((BIT) == SAI_FIRSTBIT_LSB))
bogdanm 89:552587b429a1 319 /**
bogdanm 89:552587b429a1 320 * @}
bogdanm 89:552587b429a1 321 */
bogdanm 89:552587b429a1 322
bogdanm 89:552587b429a1 323 /** @defgroup SAI_Block_Clock_Strobing
bogdanm 89:552587b429a1 324 * @{
bogdanm 89:552587b429a1 325 */
bogdanm 89:552587b429a1 326 #define SAI_CLOCKSTROBING_FALLINGEDGE ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 327 #define SAI_CLOCKSTROBING_RISINGEDGE ((uint32_t)SAI_xCR1_CKSTR)
bogdanm 89:552587b429a1 328
bogdanm 89:552587b429a1 329 #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \
bogdanm 89:552587b429a1 330 ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE))
bogdanm 89:552587b429a1 331 /**
bogdanm 89:552587b429a1 332 * @}
bogdanm 89:552587b429a1 333 */
bogdanm 89:552587b429a1 334
bogdanm 89:552587b429a1 335 /** @defgroup SAI_Block_Synchronization
bogdanm 89:552587b429a1 336 * @{
bogdanm 89:552587b429a1 337 */
bogdanm 89:552587b429a1 338 #define SAI_ASYNCHRONOUS ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 339 #define SAI_SYNCHRONOUS ((uint32_t)SAI_xCR1_SYNCEN_0)
bogdanm 89:552587b429a1 340
bogdanm 89:552587b429a1 341 #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \
bogdanm 89:552587b429a1 342 ((SYNCHRO) == SAI_SYNCHRONOUS))
bogdanm 89:552587b429a1 343 /**
bogdanm 89:552587b429a1 344 * @}
bogdanm 89:552587b429a1 345 */
bogdanm 89:552587b429a1 346
bogdanm 89:552587b429a1 347 /** @defgroup SAI_Block_Output_Drive
bogdanm 89:552587b429a1 348 * @{
bogdanm 89:552587b429a1 349 */
bogdanm 89:552587b429a1 350 #define SAI_OUTPUTDRIVE_DISABLED ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 351 #define SAI_OUTPUTDRIVE_ENABLED ((uint32_t)SAI_xCR1_OUTDRIV)
bogdanm 89:552587b429a1 352
bogdanm 89:552587b429a1 353 #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLED) || \
bogdanm 89:552587b429a1 354 ((DRIVE) == SAI_OUTPUTDRIVE_ENABLED))
bogdanm 89:552587b429a1 355 /**
bogdanm 89:552587b429a1 356 * @}
bogdanm 89:552587b429a1 357 */
bogdanm 89:552587b429a1 358
bogdanm 89:552587b429a1 359 /** @defgroup SAI_Block_NoDivider
bogdanm 89:552587b429a1 360 * @{
bogdanm 89:552587b429a1 361 */
bogdanm 89:552587b429a1 362 #define SAI_MASTERDIVIDER_ENABLED ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 363 #define SAI_MASTERDIVIDER_DISABLED ((uint32_t)SAI_xCR1_NODIV)
bogdanm 89:552587b429a1 364
bogdanm 89:552587b429a1 365 #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLED) || \
bogdanm 89:552587b429a1 366 ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLED))
bogdanm 89:552587b429a1 367 /**
bogdanm 89:552587b429a1 368 * @}
bogdanm 89:552587b429a1 369 */
bogdanm 89:552587b429a1 370
bogdanm 89:552587b429a1 371 /** @defgroup SAI_Block_Master_Divider
bogdanm 89:552587b429a1 372 * @{
bogdanm 89:552587b429a1 373 */
bogdanm 89:552587b429a1 374 #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15)
bogdanm 89:552587b429a1 375 /**
bogdanm 89:552587b429a1 376 * @}
bogdanm 89:552587b429a1 377 */
bogdanm 89:552587b429a1 378
bogdanm 89:552587b429a1 379 /** @defgroup SAI_Block_Frame_Length
bogdanm 89:552587b429a1 380 * @{
bogdanm 89:552587b429a1 381 */
bogdanm 89:552587b429a1 382 #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8 <= (LENGTH)) && ((LENGTH) <= 256))
bogdanm 89:552587b429a1 383 /**
bogdanm 89:552587b429a1 384 * @}
bogdanm 89:552587b429a1 385 */
bogdanm 89:552587b429a1 386
bogdanm 89:552587b429a1 387 /** @defgroup SAI_Block_Active_FrameLength
bogdanm 89:552587b429a1 388 * @{
bogdanm 89:552587b429a1 389 */
bogdanm 89:552587b429a1 390 #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1 <= (LENGTH)) && ((LENGTH) <= 128))
bogdanm 89:552587b429a1 391 /**
bogdanm 89:552587b429a1 392 * @}
bogdanm 89:552587b429a1 393 */
bogdanm 89:552587b429a1 394
bogdanm 89:552587b429a1 395 /** @defgroup SAI_Block_FS_Definition
bogdanm 89:552587b429a1 396 * @{
bogdanm 89:552587b429a1 397 */
bogdanm 89:552587b429a1 398 #define SAI_FS_STARTFRAME ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 399 #define SAI_FS_CHANNEL_IDENTIFICATION ((uint32_t)SAI_xFRCR_FSDEF)
bogdanm 89:552587b429a1 400
bogdanm 89:552587b429a1 401 #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \
bogdanm 89:552587b429a1 402 ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION))
bogdanm 89:552587b429a1 403 /**
bogdanm 89:552587b429a1 404 * @}
bogdanm 89:552587b429a1 405 */
bogdanm 89:552587b429a1 406
bogdanm 89:552587b429a1 407 /** @defgroup SAI_Block_FS_Polarity
bogdanm 89:552587b429a1 408 * @{
bogdanm 89:552587b429a1 409 */
bogdanm 89:552587b429a1 410 #define SAI_FS_ACTIVE_LOW ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 411 #define SAI_FS_ACTIVE_HIGH ((uint32_t)SAI_xFRCR_FSPO)
bogdanm 89:552587b429a1 412
bogdanm 89:552587b429a1 413 #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \
bogdanm 89:552587b429a1 414 ((POLARITY) == SAI_FS_ACTIVE_HIGH))
bogdanm 89:552587b429a1 415 /**
bogdanm 89:552587b429a1 416 * @}
bogdanm 89:552587b429a1 417 */
bogdanm 89:552587b429a1 418
bogdanm 89:552587b429a1 419 /** @defgroup SAI_Block_FS_Offset
bogdanm 89:552587b429a1 420 * @{
bogdanm 89:552587b429a1 421 */
bogdanm 89:552587b429a1 422 #define SAI_FS_FIRSTBIT ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 423 #define SAI_FS_BEFOREFIRSTBIT ((uint32_t)SAI_xFRCR_FSOFF)
bogdanm 89:552587b429a1 424
bogdanm 89:552587b429a1 425 #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \
bogdanm 89:552587b429a1 426 ((OFFSET) == SAI_FS_BEFOREFIRSTBIT))
bogdanm 89:552587b429a1 427 /**
bogdanm 89:552587b429a1 428 * @}
bogdanm 89:552587b429a1 429 */
bogdanm 89:552587b429a1 430
bogdanm 89:552587b429a1 431 /** @defgroup SAI_Block_Slot_FirstBit_Offset
bogdanm 89:552587b429a1 432 * @{
bogdanm 89:552587b429a1 433 */
bogdanm 89:552587b429a1 434 #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24)
bogdanm 89:552587b429a1 435 /**
bogdanm 89:552587b429a1 436 * @}
bogdanm 89:552587b429a1 437 */
bogdanm 89:552587b429a1 438
bogdanm 89:552587b429a1 439 /** @defgroup SAI_Block_Slot_Size
bogdanm 89:552587b429a1 440 * @{
bogdanm 89:552587b429a1 441 */
bogdanm 89:552587b429a1 442 #define SAI_SLOTSIZE_DATASIZE ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 443 #define SAI_SLOTSIZE_16B ((uint32_t)SAI_xSLOTR_SLOTSZ_0)
bogdanm 89:552587b429a1 444 #define SAI_SLOTSIZE_32B ((uint32_t)SAI_xSLOTR_SLOTSZ_1)
bogdanm 89:552587b429a1 445
bogdanm 89:552587b429a1 446 #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \
bogdanm 89:552587b429a1 447 ((SIZE) == SAI_SLOTSIZE_16B) || \
bogdanm 89:552587b429a1 448 ((SIZE) == SAI_SLOTSIZE_32B))
bogdanm 89:552587b429a1 449 /**
bogdanm 89:552587b429a1 450 * @}
bogdanm 89:552587b429a1 451 */
bogdanm 89:552587b429a1 452
bogdanm 89:552587b429a1 453 /** @defgroup SAI_Block_Slot_Number
bogdanm 89:552587b429a1 454 * @{
bogdanm 89:552587b429a1 455 */
bogdanm 89:552587b429a1 456 #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1 <= (NUMBER)) && ((NUMBER) <= 16))
bogdanm 89:552587b429a1 457 /**
bogdanm 89:552587b429a1 458 * @}
bogdanm 89:552587b429a1 459 */
bogdanm 89:552587b429a1 460
bogdanm 89:552587b429a1 461 /** @defgroup SAI_Block_Slot_Active
bogdanm 89:552587b429a1 462 * @{
bogdanm 89:552587b429a1 463 */
bogdanm 89:552587b429a1 464 #define SAI_SLOT_NOTACTIVE ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 465 #define SAI_SLOTACTIVE_0 ((uint32_t)0x00010000)
bogdanm 89:552587b429a1 466 #define SAI_SLOTACTIVE_1 ((uint32_t)0x00020000)
bogdanm 89:552587b429a1 467 #define SAI_SLOTACTIVE_2 ((uint32_t)0x00040000)
bogdanm 89:552587b429a1 468 #define SAI_SLOTACTIVE_3 ((uint32_t)0x00080000)
bogdanm 89:552587b429a1 469 #define SAI_SLOTACTIVE_4 ((uint32_t)0x00100000)
bogdanm 89:552587b429a1 470 #define SAI_SLOTACTIVE_5 ((uint32_t)0x00200000)
bogdanm 89:552587b429a1 471 #define SAI_SLOTACTIVE_6 ((uint32_t)0x00400000)
bogdanm 89:552587b429a1 472 #define SAI_SLOTACTIVE_7 ((uint32_t)0x00800000)
bogdanm 89:552587b429a1 473 #define SAI_SLOTACTIVE_8 ((uint32_t)0x01000000)
bogdanm 89:552587b429a1 474 #define SAI_SLOTACTIVE_9 ((uint32_t)0x02000000)
bogdanm 89:552587b429a1 475 #define SAI_SLOTACTIVE_10 ((uint32_t)0x04000000)
bogdanm 89:552587b429a1 476 #define SAI_SLOTACTIVE_11 ((uint32_t)0x08000000)
bogdanm 89:552587b429a1 477 #define SAI_SLOTACTIVE_12 ((uint32_t)0x10000000)
bogdanm 89:552587b429a1 478 #define SAI_SLOTACTIVE_13 ((uint32_t)0x20000000)
bogdanm 89:552587b429a1 479 #define SAI_SLOTACTIVE_14 ((uint32_t)0x40000000)
bogdanm 89:552587b429a1 480 #define SAI_SLOTACTIVE_15 ((uint32_t)0x80000000)
bogdanm 89:552587b429a1 481 #define SAI_SLOTACTIVE_ALL ((uint32_t)0xFFFF0000)
bogdanm 89:552587b429a1 482
bogdanm 89:552587b429a1 483 #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) != 0)
bogdanm 89:552587b429a1 484
bogdanm 89:552587b429a1 485 /**
bogdanm 89:552587b429a1 486 * @}
bogdanm 89:552587b429a1 487 */
bogdanm 89:552587b429a1 488
bogdanm 89:552587b429a1 489 /** @defgroup SAI_Mono_Stereo_Mode
bogdanm 89:552587b429a1 490 * @{
bogdanm 89:552587b429a1 491 */
bogdanm 89:552587b429a1 492 #define SAI_MONOMODE ((uint32_t)SAI_xCR1_MONO)
bogdanm 89:552587b429a1 493 #define SAI_STREOMODE ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 494
bogdanm 89:552587b429a1 495 #define IS_SAI_BLOCK_MONO_STREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\
bogdanm 89:552587b429a1 496 ((MODE) == SAI_STREOMODE))
bogdanm 89:552587b429a1 497 /**
bogdanm 89:552587b429a1 498 * @}
bogdanm 89:552587b429a1 499 */
bogdanm 89:552587b429a1 500
bogdanm 89:552587b429a1 501 /** @defgroup SAI_TRIState_Management
bogdanm 89:552587b429a1 502 * @{
bogdanm 89:552587b429a1 503 */
bogdanm 89:552587b429a1 504 #define SAI_OUTPUT_NOTRELEASED ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 505 #define SAI_OUTPUT_RELEASED ((uint32_t)SAI_xCR2_TRIS)
bogdanm 89:552587b429a1 506
bogdanm 89:552587b429a1 507 #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\
bogdanm 89:552587b429a1 508 ((STATE) == SAI_OUTPUT_RELEASED))
bogdanm 89:552587b429a1 509 /**
bogdanm 89:552587b429a1 510 * @}
bogdanm 89:552587b429a1 511 */
bogdanm 89:552587b429a1 512
bogdanm 89:552587b429a1 513 /** @defgroup SAI_Block_Fifo_Threshold
bogdanm 89:552587b429a1 514 * @{
bogdanm 89:552587b429a1 515 */
bogdanm 89:552587b429a1 516 #define SAI_FIFOTHRESHOLD_EMPTY ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 517 #define SAI_FIFOTHRESHOLD_1QF ((uint32_t)0x00000001)
bogdanm 89:552587b429a1 518 #define SAI_FIFOTHRESHOLD_HF ((uint32_t)0x00000002)
bogdanm 89:552587b429a1 519 #define SAI_FIFOTHRESHOLD_3QF ((uint32_t)0x00000003)
bogdanm 89:552587b429a1 520 #define SAI_FIFOTHRESHOLD_FULL ((uint32_t)0x00000004)
bogdanm 89:552587b429a1 521
bogdanm 89:552587b429a1 522 #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \
bogdanm 89:552587b429a1 523 ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \
bogdanm 89:552587b429a1 524 ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \
bogdanm 89:552587b429a1 525 ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \
bogdanm 89:552587b429a1 526 ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL))
bogdanm 89:552587b429a1 527 /**
bogdanm 89:552587b429a1 528 * @}
bogdanm 89:552587b429a1 529 */
bogdanm 89:552587b429a1 530
bogdanm 89:552587b429a1 531 /** @defgroup SAI_Block_Companding_Mode
bogdanm 89:552587b429a1 532 * @{
bogdanm 89:552587b429a1 533 */
bogdanm 89:552587b429a1 534 #define SAI_NOCOMPANDING ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 535 #define SAI_ULAW_1CPL_COMPANDING ((uint32_t)0x00008000)
bogdanm 89:552587b429a1 536 #define SAI_ALAW_1CPL_COMPANDING ((uint32_t)0x0000C000)
bogdanm 89:552587b429a1 537 #define SAI_ULAW_2CPL_COMPANDING ((uint32_t)0x0000A000)
bogdanm 89:552587b429a1 538 #define SAI_ALAW_2CPL_COMPANDING ((uint32_t)0x0000E000)
bogdanm 89:552587b429a1 539
bogdanm 89:552587b429a1 540 #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \
bogdanm 89:552587b429a1 541 ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \
bogdanm 89:552587b429a1 542 ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \
bogdanm 89:552587b429a1 543 ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \
bogdanm 89:552587b429a1 544 ((MODE) == SAI_ALAW_2CPL_COMPANDING))
bogdanm 89:552587b429a1 545 /**
bogdanm 89:552587b429a1 546 * @}
bogdanm 89:552587b429a1 547 */
bogdanm 89:552587b429a1 548
bogdanm 89:552587b429a1 549 /** @defgroup SAI_Block_Mute_Value
bogdanm 89:552587b429a1 550 * @{
bogdanm 89:552587b429a1 551 */
bogdanm 89:552587b429a1 552 #define SAI_ZERO_VALUE ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 553 #define SAI_LAST_SENT_VALUE ((uint32_t)SAI_xCR2_MUTEVAL)
bogdanm 89:552587b429a1 554
bogdanm 89:552587b429a1 555 #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \
bogdanm 89:552587b429a1 556 ((VALUE) == SAI_LAST_SENT_VALUE))
bogdanm 89:552587b429a1 557 /**
bogdanm 89:552587b429a1 558 * @}
bogdanm 89:552587b429a1 559 */
bogdanm 89:552587b429a1 560
bogdanm 89:552587b429a1 561 /** @defgroup SAI_Block_Mute_Frame_Counter
bogdanm 89:552587b429a1 562 * @{
bogdanm 89:552587b429a1 563 */
bogdanm 89:552587b429a1 564 #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63)
bogdanm 89:552587b429a1 565 /**
bogdanm 89:552587b429a1 566 * @}
bogdanm 89:552587b429a1 567 */
bogdanm 89:552587b429a1 568
bogdanm 89:552587b429a1 569 /** @defgroup SAI_Block_Interrupts_Definition
bogdanm 89:552587b429a1 570 * @{
bogdanm 89:552587b429a1 571 */
bogdanm 89:552587b429a1 572 #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE)
bogdanm 89:552587b429a1 573 #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE)
bogdanm 89:552587b429a1 574 #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE)
bogdanm 89:552587b429a1 575 #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE)
bogdanm 89:552587b429a1 576 #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE)
bogdanm 89:552587b429a1 577 #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE)
bogdanm 89:552587b429a1 578 #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE)
bogdanm 89:552587b429a1 579
bogdanm 89:552587b429a1 580 #define IS_SAI_BLOCK_CONFIG_IT(IT) (((IT) == SAI_IT_OVRUDR) || \
bogdanm 89:552587b429a1 581 ((IT) == SAI_IT_MUTEDET) || \
bogdanm 89:552587b429a1 582 ((IT) == SAI_IT_WCKCFG) || \
bogdanm 89:552587b429a1 583 ((IT) == SAI_IT_FREQ) || \
bogdanm 89:552587b429a1 584 ((IT) == SAI_IT_CNRDY) || \
bogdanm 89:552587b429a1 585 ((IT) == SAI_IT_AFSDET) || \
bogdanm 89:552587b429a1 586 ((IT) == SAI_IT_LFSDET))
bogdanm 89:552587b429a1 587 /**
bogdanm 89:552587b429a1 588 * @}
bogdanm 89:552587b429a1 589 */
bogdanm 89:552587b429a1 590
bogdanm 89:552587b429a1 591 /** @defgroup SAI_Block_Flags_Definition
bogdanm 89:552587b429a1 592 * @{
bogdanm 89:552587b429a1 593 */
bogdanm 89:552587b429a1 594 #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR)
bogdanm 89:552587b429a1 595 #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET)
bogdanm 89:552587b429a1 596 #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG)
bogdanm 89:552587b429a1 597 #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ)
bogdanm 89:552587b429a1 598 #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY)
bogdanm 89:552587b429a1 599 #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET)
bogdanm 89:552587b429a1 600 #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET)
bogdanm 89:552587b429a1 601
bogdanm 89:552587b429a1 602 #define IS_SAI_BLOCK_GET_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \
bogdanm 89:552587b429a1 603 ((FLAG) == SAI_FLAG_MUTEDET) || \
bogdanm 89:552587b429a1 604 ((FLAG) == SAI_FLAG_WCKCFG) || \
bogdanm 89:552587b429a1 605 ((FLAG) == SAI_FLAG_FREQ) || \
bogdanm 89:552587b429a1 606 ((FLAG) == SAI_FLAG_CNRDY) || \
bogdanm 89:552587b429a1 607 ((FLAG) == SAI_FLAG_AFSDET) || \
bogdanm 89:552587b429a1 608 ((FLAG) == SAI_FLAG_LFSDET))
bogdanm 89:552587b429a1 609
bogdanm 89:552587b429a1 610 #define IS_SAI_BLOCK_CLEAR_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \
bogdanm 89:552587b429a1 611 ((FLAG) == SAI_FLAG_MUTEDET) || \
bogdanm 89:552587b429a1 612 ((FLAG) == SAI_FLAG_WCKCFG) || \
bogdanm 89:552587b429a1 613 ((FLAG) == SAI_FLAG_FREQ) || \
bogdanm 89:552587b429a1 614 ((FLAG) == SAI_FLAG_CNRDY) || \
bogdanm 89:552587b429a1 615 ((FLAG) == SAI_FLAG_AFSDET) || \
bogdanm 89:552587b429a1 616 ((FLAG) == SAI_FLAG_LFSDET))
bogdanm 89:552587b429a1 617 /**
bogdanm 89:552587b429a1 618 * @}
bogdanm 89:552587b429a1 619 */
bogdanm 89:552587b429a1 620
bogdanm 89:552587b429a1 621 /** @defgroup SAI_Block_Fifo_Status_Level
bogdanm 89:552587b429a1 622 * @{
bogdanm 89:552587b429a1 623 */
bogdanm 89:552587b429a1 624 #define SAI_FIFOStatus_Empty ((uint32_t)0x00000000)
bogdanm 89:552587b429a1 625 #define SAI_FIFOStatus_Less1QuarterFull ((uint32_t)0x00010000)
bogdanm 89:552587b429a1 626 #define SAI_FIFOStatus_1QuarterFull ((uint32_t)0x00020000)
bogdanm 89:552587b429a1 627 #define SAI_FIFOStatus_HalfFull ((uint32_t)0x00030000)
bogdanm 89:552587b429a1 628 #define SAI_FIFOStatus_3QuartersFull ((uint32_t)0x00040000)
bogdanm 89:552587b429a1 629 #define SAI_FIFOStatus_Full ((uint32_t)0x00050000)
bogdanm 89:552587b429a1 630
bogdanm 89:552587b429a1 631 #define IS_SAI_BLOCK_FIFO_STATUS(STATUS) (((STATUS) == SAI_FIFOStatus_Less1QuarterFull ) || \
bogdanm 89:552587b429a1 632 ((STATUS) == SAI_FIFOStatus_HalfFull) || \
bogdanm 89:552587b429a1 633 ((STATUS) == SAI_FIFOStatus_1QuarterFull) || \
bogdanm 89:552587b429a1 634 ((STATUS) == SAI_FIFOStatus_3QuartersFull) || \
bogdanm 89:552587b429a1 635 ((STATUS) == SAI_FIFOStatus_Full) || \
bogdanm 89:552587b429a1 636 ((STATUS) == SAI_FIFOStatus_Empty))
bogdanm 89:552587b429a1 637 /**
bogdanm 89:552587b429a1 638 * @}
bogdanm 89:552587b429a1 639 */
bogdanm 89:552587b429a1 640
bogdanm 89:552587b429a1 641
bogdanm 89:552587b429a1 642 /**
bogdanm 89:552587b429a1 643 * @}
bogdanm 89:552587b429a1 644 */
bogdanm 89:552587b429a1 645
bogdanm 89:552587b429a1 646 /* Exported macro ------------------------------------------------------------*/
bogdanm 89:552587b429a1 647 /** @brief Reset SAI handle state
bogdanm 89:552587b429a1 648 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 89:552587b429a1 649 * @retval None
bogdanm 89:552587b429a1 650 */
bogdanm 89:552587b429a1 651 #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET)
bogdanm 89:552587b429a1 652
bogdanm 89:552587b429a1 653 /** @brief Enable or disable the specified SAI interrupts.
bogdanm 89:552587b429a1 654 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 89:552587b429a1 655 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
bogdanm 89:552587b429a1 656 * This parameter can be one of the following values:
bogdanm 89:552587b429a1 657 * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
bogdanm 89:552587b429a1 658 * @arg SAI_IT_MUTEDET: Mute detection interrupt enable
bogdanm 89:552587b429a1 659 * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
bogdanm 89:552587b429a1 660 * @arg SAI_IT_FREQ: FIFO request interrupt enable
bogdanm 89:552587b429a1 661 * @arg SAI_IT_CNRDY: Codec not ready interrupt enable
bogdanm 89:552587b429a1 662 * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
bogdanm 89:552587b429a1 663 * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enabl
bogdanm 89:552587b429a1 664 * @retval None
bogdanm 89:552587b429a1 665 */
bogdanm 89:552587b429a1 666
bogdanm 89:552587b429a1 667 #define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
bogdanm 89:552587b429a1 668 #define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__)))
bogdanm 89:552587b429a1 669
bogdanm 89:552587b429a1 670 /** @brief Check if the specified SAI interrupt source is enabled or disabled.
bogdanm 89:552587b429a1 671 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 89:552587b429a1 672 * This parameter can be SAI where x: 1, 2, or 3 to select the SAI peripheral.
bogdanm 89:552587b429a1 673 * @param __INTERRUPT__: specifies the SAI interrupt source to check.
bogdanm 89:552587b429a1 674 * This parameter can be one of the following values:
bogdanm 89:552587b429a1 675 * @arg SAI_IT_TXE: Tx buffer empty interrupt enable.
bogdanm 89:552587b429a1 676 * @arg SAI_IT_RXNE: Rx buffer not empty interrupt enable.
bogdanm 89:552587b429a1 677 * @arg SAI_IT_ERR: Error interrupt enable.
bogdanm 89:552587b429a1 678 * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
bogdanm 89:552587b429a1 679 */
bogdanm 89:552587b429a1 680 #define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
bogdanm 89:552587b429a1 681
bogdanm 89:552587b429a1 682 /** @brief Check whether the specified SAI flag is set or not.
bogdanm 89:552587b429a1 683 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 89:552587b429a1 684 * @param __FLAG__: specifies the flag to check.
bogdanm 89:552587b429a1 685 * This parameter can be one of the following values:
bogdanm 89:552587b429a1 686 * @arg SAI_FLAG_OVRUDR: Overrun underrun flag.
bogdanm 89:552587b429a1 687 * @arg SAI_FLAG_MUTEDET: Mute detection flag.
bogdanm 89:552587b429a1 688 * @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag.
bogdanm 89:552587b429a1 689 * @arg SAI_FLAG_FREQ: FIFO request flag.
bogdanm 89:552587b429a1 690 * @arg SAI_FLAG_CNRDY: Codec not ready flag.
bogdanm 89:552587b429a1 691 * @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag.
bogdanm 89:552587b429a1 692 * @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag.
bogdanm 89:552587b429a1 693 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 89:552587b429a1 694 */
bogdanm 89:552587b429a1 695 #define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
bogdanm 89:552587b429a1 696
bogdanm 89:552587b429a1 697 /** @brief Clears the specified SAI pending flag.
bogdanm 89:552587b429a1 698 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 89:552587b429a1 699 * @param __FLAG__: specifies the flag to check.
bogdanm 89:552587b429a1 700 * This parameter can be any combination of the following values:
bogdanm 89:552587b429a1 701 * @arg SAI_FLAG_OVRUDR: Clear Overrun underrun
bogdanm 89:552587b429a1 702 * @arg SAI_FLAG_MUTEDET: Clear Mute detection
bogdanm 89:552587b429a1 703 * @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration
bogdanm 89:552587b429a1 704 * @arg SAI_FLAG_FREQ: Clear FIFO request
bogdanm 89:552587b429a1 705 * @arg SAI_FLAG_CNRDY: Clear Codec not ready
bogdanm 89:552587b429a1 706 * @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection
bogdanm 89:552587b429a1 707 * @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection
bogdanm 89:552587b429a1 708 *
bogdanm 89:552587b429a1 709 * @retval None
bogdanm 89:552587b429a1 710 */
bogdanm 92:4fc01daae5a5 711 #define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__))
bogdanm 89:552587b429a1 712
bogdanm 89:552587b429a1 713 #define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN)
bogdanm 89:552587b429a1 714 #define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN)
bogdanm 89:552587b429a1 715
bogdanm 89:552587b429a1 716 /* Exported functions --------------------------------------------------------*/
bogdanm 89:552587b429a1 717
bogdanm 89:552587b429a1 718 /* Initialization/de-initialization functions **********************************/
bogdanm 89:552587b429a1 719 HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 720 HAL_StatusTypeDef HAL_SAI_DeInit (SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 721 void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 722 void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 723
bogdanm 89:552587b429a1 724 /* I/O operation functions *****************************************************/
bogdanm 89:552587b429a1 725 /* Blocking mode: Polling */
bogdanm 89:552587b429a1 726 HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 89:552587b429a1 727 HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 89:552587b429a1 728
bogdanm 89:552587b429a1 729 /* Non-Blocking mode: Interrupt */
bogdanm 89:552587b429a1 730 HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size);
bogdanm 89:552587b429a1 731 HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size);
bogdanm 89:552587b429a1 732
bogdanm 89:552587b429a1 733 /* Non-Blocking mode: DMA */
bogdanm 89:552587b429a1 734 HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size);
bogdanm 89:552587b429a1 735 HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size);
bogdanm 89:552587b429a1 736 HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 737 HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 738 HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 739
bogdanm 89:552587b429a1 740 /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
bogdanm 89:552587b429a1 741 void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 742 void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 743 void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 744 void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 745 void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 746 void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 747
bogdanm 89:552587b429a1 748 /* Peripheral State functions **************************************************/
bogdanm 89:552587b429a1 749 HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 750 uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai);
bogdanm 89:552587b429a1 751
bogdanm 89:552587b429a1 752 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
bogdanm 89:552587b429a1 753 /**
bogdanm 89:552587b429a1 754 * @}
bogdanm 89:552587b429a1 755 */
bogdanm 89:552587b429a1 756
bogdanm 89:552587b429a1 757 /**
bogdanm 89:552587b429a1 758 * @}
bogdanm 89:552587b429a1 759 */
bogdanm 89:552587b429a1 760
bogdanm 89:552587b429a1 761 #ifdef __cplusplus
bogdanm 89:552587b429a1 762 }
bogdanm 89:552587b429a1 763 #endif
bogdanm 89:552587b429a1 764
bogdanm 89:552587b429a1 765 #endif /* __STM32F4xx_HAL_SAI_H */
bogdanm 89:552587b429a1 766
bogdanm 89:552587b429a1 767 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/