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

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
93:e188a91d3eaa
12

Who changed what in which revision?

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