mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
AnnaBridge
Date:
Wed Jun 21 17:31:38 2017 +0100
Revision:
145:64910690c574
Parent:
128:9bcdf88f62b0
Release 145 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 92:4fc01daae5a5 1 /**
bogdanm 92:4fc01daae5a5 2 ******************************************************************************
bogdanm 92:4fc01daae5a5 3 * @file stm32f4xx_hal_sai.h
bogdanm 92:4fc01daae5a5 4 * @author MCD Application Team
AnnaBridge 145:64910690c574 5 * @version V1.7.1
AnnaBridge 145:64910690c574 6 * @date 14-April-2017
bogdanm 92:4fc01daae5a5 7 * @brief Header file of SAI HAL module.
bogdanm 92:4fc01daae5a5 8 ******************************************************************************
bogdanm 92:4fc01daae5a5 9 * @attention
bogdanm 92:4fc01daae5a5 10 *
AnnaBridge 145:64910690c574 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
bogdanm 92:4fc01daae5a5 12 *
bogdanm 92:4fc01daae5a5 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 92:4fc01daae5a5 14 * are permitted provided that the following conditions are met:
bogdanm 92:4fc01daae5a5 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 92:4fc01daae5a5 16 * this list of conditions and the following disclaimer.
bogdanm 92:4fc01daae5a5 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 92:4fc01daae5a5 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 92:4fc01daae5a5 19 * and/or other materials provided with the distribution.
bogdanm 92:4fc01daae5a5 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 92:4fc01daae5a5 21 * may be used to endorse or promote products derived from this software
bogdanm 92:4fc01daae5a5 22 * without specific prior written permission.
bogdanm 92:4fc01daae5a5 23 *
bogdanm 92:4fc01daae5a5 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 92:4fc01daae5a5 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 92:4fc01daae5a5 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 92:4fc01daae5a5 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 92:4fc01daae5a5 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 92:4fc01daae5a5 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 92:4fc01daae5a5 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 92:4fc01daae5a5 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 92:4fc01daae5a5 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 92:4fc01daae5a5 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 92:4fc01daae5a5 34 *
bogdanm 92:4fc01daae5a5 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
bogdanm 92:4fc01daae5a5 37
bogdanm 92:4fc01daae5a5 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 92:4fc01daae5a5 39 #ifndef __STM32F4xx_HAL_SAI_H
bogdanm 92:4fc01daae5a5 40 #define __STM32F4xx_HAL_SAI_H
bogdanm 92:4fc01daae5a5 41
bogdanm 92:4fc01daae5a5 42 #ifdef __cplusplus
bogdanm 92:4fc01daae5a5 43 extern "C" {
bogdanm 92:4fc01daae5a5 44 #endif
bogdanm 92:4fc01daae5a5 45
bogdanm 92:4fc01daae5a5 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32f4xx_hal_def.h"
bogdanm 92:4fc01daae5a5 48
bogdanm 92:4fc01daae5a5 49 /** @addtogroup STM32F4xx_HAL_Driver
bogdanm 92:4fc01daae5a5 50 * @{
bogdanm 92:4fc01daae5a5 51 */
Kojto 122:f9eeca106725 52 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
AnnaBridge 145:64910690c574 53 defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || \
AnnaBridge 145:64910690c574 54 defined(STM32F423xx)
bogdanm 92:4fc01daae5a5 55
bogdanm 92:4fc01daae5a5 56 /** @addtogroup SAI
bogdanm 92:4fc01daae5a5 57 * @{
Kojto 122:f9eeca106725 58 */
Kojto 122:f9eeca106725 59
Kojto 122:f9eeca106725 60 /* Exported types ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 61 /** @defgroup SAI_Exported_Types SAI Exported Types
Kojto 99:dbbf35b96557 62 * @{
Kojto 99:dbbf35b96557 63 */
Kojto 122:f9eeca106725 64
Kojto 122:f9eeca106725 65 /**
Kojto 122:f9eeca106725 66 * @brief HAL State structures definition
Kojto 122:f9eeca106725 67 */
Kojto 99:dbbf35b96557 68 typedef enum
Kojto 99:dbbf35b96557 69 {
Kojto 122:f9eeca106725 70 HAL_SAI_STATE_RESET = 0x00U, /*!< SAI not yet initialized or disabled */
Kojto 122:f9eeca106725 71 HAL_SAI_STATE_READY = 0x01U, /*!< SAI initialized and ready for use */
Kojto 122:f9eeca106725 72 HAL_SAI_STATE_BUSY = 0x02U, /*!< SAI internal process is ongoing */
Kojto 122:f9eeca106725 73 HAL_SAI_STATE_BUSY_TX = 0x12U, /*!< Data transmission process is ongoing */
Kojto 122:f9eeca106725 74 HAL_SAI_STATE_BUSY_RX = 0x22U, /*!< Data reception process is ongoing */
Kojto 122:f9eeca106725 75 HAL_SAI_STATE_TIMEOUT = 0x03U, /*!< SAI timeout state */
Kojto 122:f9eeca106725 76 HAL_SAI_STATE_ERROR = 0x04U /*!< SAI error state */
Kojto 99:dbbf35b96557 77 }HAL_SAI_StateTypeDef;
bogdanm 92:4fc01daae5a5 78
Kojto 122:f9eeca106725 79 /**
Kojto 122:f9eeca106725 80 * @brief SAI Callback prototype
Kojto 99:dbbf35b96557 81 */
Kojto 99:dbbf35b96557 82 typedef void (*SAIcallback)(void);
bogdanm 92:4fc01daae5a5 83
Kojto 122:f9eeca106725 84 /** @defgroup SAI_Init_Structure_definition SAI Init Structure definition
Kojto 122:f9eeca106725 85 * @brief SAI Init Structure definition
Kojto 122:f9eeca106725 86 * @{
bogdanm 92:4fc01daae5a5 87 */
bogdanm 92:4fc01daae5a5 88 typedef struct
Kojto 122:f9eeca106725 89 {
Kojto 122:f9eeca106725 90 uint32_t AudioMode; /*!< Specifies the SAI Block audio Mode.
Kojto 122:f9eeca106725 91 This parameter can be a value of @ref SAI_Block_Mode */
Kojto 99:dbbf35b96557 92
Kojto 99:dbbf35b96557 93 uint32_t Synchro; /*!< Specifies SAI Block synchronization
Kojto 99:dbbf35b96557 94 This parameter can be a value of @ref SAI_Block_Synchronization */
Kojto 99:dbbf35b96557 95
Kojto 122:f9eeca106725 96 uint32_t SynchroExt; /*!< Specifies SAI external output synchronization, this setup is common
Kojto 122:f9eeca106725 97 for BlockA and BlockB
Kojto 122:f9eeca106725 98 This parameter can be a value of @ref SAI_Block_SyncExt
Kojto 122:f9eeca106725 99 @note: If both audio blocks of same SAI are used, this parameter has
Kojto 122:f9eeca106725 100 to be set to the same value for each audio block */
Kojto 99:dbbf35b96557 101
Kojto 99:dbbf35b96557 102 uint32_t OutputDrive; /*!< Specifies when SAI Block outputs are driven.
Kojto 99:dbbf35b96557 103 This parameter can be a value of @ref SAI_Block_Output_Drive
Kojto 122:f9eeca106725 104 @note this value has to be set before enabling the audio block
Kojto 99:dbbf35b96557 105 but after the audio block configuration. */
Kojto 99:dbbf35b96557 106
Kojto 99:dbbf35b96557 107 uint32_t NoDivider; /*!< Specifies whether master clock will be divided or not.
Kojto 99:dbbf35b96557 108 This parameter can be a value of @ref SAI_Block_NoDivider
Kojto 122:f9eeca106725 109 @note If bit NODIV in the SAI_xCR1 register is cleared, the frame length
Kojto 99:dbbf35b96557 110 should be aligned to a number equal to a power of 2, from 8 to 256.
Kojto 122:f9eeca106725 111 If bit NODIV in the SAI_xCR1 register is set, the frame length can
Kojto 122:f9eeca106725 112 take any of the values without constraint since the input clock of
Kojto 99:dbbf35b96557 113 the audio block should be equal to the bit clock.
Kojto 99:dbbf35b96557 114 There is no MCLK_x clock which can be output. */
Kojto 99:dbbf35b96557 115
Kojto 99:dbbf35b96557 116 uint32_t FIFOThreshold; /*!< Specifies SAI Block FIFO threshold.
Kojto 99:dbbf35b96557 117 This parameter can be a value of @ref SAI_Block_Fifo_Threshold */
Kojto 99:dbbf35b96557 118
Kojto 122:f9eeca106725 119 uint32_t ClockSource; /*!< Specifies the SAI Block x Clock source.
Kojto 99:dbbf35b96557 120 This parameter is not used for STM32F446xx devices. */
Kojto 99:dbbf35b96557 121
Kojto 122:f9eeca106725 122 uint32_t AudioFrequency; /*!< Specifies the audio frequency sampling.
Kojto 99:dbbf35b96557 123 This parameter can be a value of @ref SAI_Audio_Frequency */
Kojto 99:dbbf35b96557 124
Kojto 99:dbbf35b96557 125 uint32_t Mckdiv; /*!< Specifies the master clock divider, the parameter will be used if for
Kojto 122:f9eeca106725 126 AudioFrequency the user choice
Kojto 99:dbbf35b96557 127 This parameter must be a number between Min_Data = 0 and Max_Data = 15 */
Kojto 99:dbbf35b96557 128
Kojto 122:f9eeca106725 129 uint32_t MonoStereoMode; /*!< Specifies if the mono or stereo mode is selected.
Kojto 122:f9eeca106725 130 This parameter can be a value of @ref SAI_Mono_Stereo_Mode */
Kojto 122:f9eeca106725 131
Kojto 122:f9eeca106725 132 uint32_t CompandingMode; /*!< Specifies the companding mode type.
Kojto 99:dbbf35b96557 133 This parameter can be a value of @ref SAI_Block_Companding_Mode */
Kojto 122:f9eeca106725 134
Kojto 122:f9eeca106725 135 uint32_t TriState; /*!< Specifies the companding mode type.
Kojto 99:dbbf35b96557 136 This parameter can be a value of @ref SAI_TRIState_Management */
Kojto 122:f9eeca106725 137
Kojto 122:f9eeca106725 138 /* This part of the structure is automatically filled if your are using the high level intialisation
Kojto 99:dbbf35b96557 139 function HAL_SAI_InitProtocol */
Kojto 99:dbbf35b96557 140
bogdanm 92:4fc01daae5a5 141 uint32_t Protocol; /*!< Specifies the SAI Block protocol.
Kojto 99:dbbf35b96557 142 This parameter can be a value of @ref SAI_Block_Protocol */
Kojto 99:dbbf35b96557 143
bogdanm 92:4fc01daae5a5 144 uint32_t DataSize; /*!< Specifies the SAI Block data size.
Kojto 99:dbbf35b96557 145 This parameter can be a value of @ref SAI_Block_Data_Size */
bogdanm 92:4fc01daae5a5 146
bogdanm 92:4fc01daae5a5 147 uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
Kojto 99:dbbf35b96557 148 This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */
bogdanm 92:4fc01daae5a5 149
bogdanm 92:4fc01daae5a5 150 uint32_t ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity.
Kojto 122:f9eeca106725 151 This parameter can be a value of @ref SAI_Block_Clock_Strobing */
bogdanm 92:4fc01daae5a5 152 }SAI_InitTypeDef;
Kojto 122:f9eeca106725 153 /**
Kojto 122:f9eeca106725 154 * @}
Kojto 122:f9eeca106725 155 */
bogdanm 92:4fc01daae5a5 156
Kojto 122:f9eeca106725 157 /** @defgroup SAI_Frame_Structure_definition SAI Frame Structure definition
Kojto 122:f9eeca106725 158 * @brief SAI Frame Init structure definition
Kojto 122:f9eeca106725 159 * @{
bogdanm 92:4fc01daae5a5 160 */
bogdanm 92:4fc01daae5a5 161 typedef struct
bogdanm 92:4fc01daae5a5 162 {
bogdanm 92:4fc01daae5a5 163 uint32_t FrameLength; /*!< Specifies the Frame length, the number of SCK clocks for each audio frame.
bogdanm 92:4fc01daae5a5 164 This parameter must be a number between Min_Data = 8 and Max_Data = 256.
Kojto 122:f9eeca106725 165 @note If master clock MCLK_x pin is declared as an output, the frame length
bogdanm 92:4fc01daae5a5 166 should be aligned to a number equal to power of 2 in order to keep
Kojto 122:f9eeca106725 167 in an audio frame, an integer number of MCLK pulses by bit Clock. */
Kojto 122:f9eeca106725 168
bogdanm 92:4fc01daae5a5 169 uint32_t ActiveFrameLength; /*!< Specifies the Frame synchronization active level length.
Kojto 122:f9eeca106725 170 This Parameter specifies the length in number of bit clock (SCK + 1)
bogdanm 92:4fc01daae5a5 171 of the active level of FS signal in audio frame.
bogdanm 92:4fc01daae5a5 172 This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
Kojto 122:f9eeca106725 173
bogdanm 92:4fc01daae5a5 174 uint32_t FSDefinition; /*!< Specifies the Frame synchronization definition.
bogdanm 92:4fc01daae5a5 175 This parameter can be a value of @ref SAI_Block_FS_Definition */
Kojto 122:f9eeca106725 176
bogdanm 92:4fc01daae5a5 177 uint32_t FSPolarity; /*!< Specifies the Frame synchronization Polarity.
bogdanm 92:4fc01daae5a5 178 This parameter can be a value of @ref SAI_Block_FS_Polarity */
bogdanm 92:4fc01daae5a5 179
bogdanm 92:4fc01daae5a5 180 uint32_t FSOffset; /*!< Specifies the Frame synchronization Offset.
bogdanm 92:4fc01daae5a5 181 This parameter can be a value of @ref SAI_Block_FS_Offset */
bogdanm 92:4fc01daae5a5 182 }SAI_FrameInitTypeDef;
bogdanm 92:4fc01daae5a5 183 /**
Kojto 122:f9eeca106725 184 * @}
Kojto 122:f9eeca106725 185 */
Kojto 122:f9eeca106725 186
Kojto 122:f9eeca106725 187 /** @defgroup SAI_Slot_Structure_definition SAI Slot Structure definition
bogdanm 92:4fc01daae5a5 188 * @brief SAI Block Slot Init Structure definition
Kojto 122:f9eeca106725 189 * @{
Kojto 122:f9eeca106725 190 */
bogdanm 92:4fc01daae5a5 191 typedef struct
bogdanm 92:4fc01daae5a5 192 {
bogdanm 92:4fc01daae5a5 193 uint32_t FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot.
bogdanm 92:4fc01daae5a5 194 This parameter must be a number between Min_Data = 0 and Max_Data = 24 */
bogdanm 92:4fc01daae5a5 195
bogdanm 92:4fc01daae5a5 196 uint32_t SlotSize; /*!< Specifies the Slot Size.
bogdanm 92:4fc01daae5a5 197 This parameter can be a value of @ref SAI_Block_Slot_Size */
bogdanm 92:4fc01daae5a5 198
bogdanm 92:4fc01daae5a5 199 uint32_t SlotNumber; /*!< Specifies the number of slot in the audio frame.
bogdanm 92:4fc01daae5a5 200 This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
bogdanm 92:4fc01daae5a5 201
bogdanm 92:4fc01daae5a5 202 uint32_t SlotActive; /*!< Specifies the slots in audio frame that will be activated.
bogdanm 92:4fc01daae5a5 203 This parameter can be a value of @ref SAI_Block_Slot_Active */
bogdanm 92:4fc01daae5a5 204 }SAI_SlotInitTypeDef;
bogdanm 92:4fc01daae5a5 205
Kojto 122:f9eeca106725 206 /**
Kojto 122:f9eeca106725 207 * @}
Kojto 122:f9eeca106725 208 */
Kojto 122:f9eeca106725 209
Kojto 122:f9eeca106725 210 /** @defgroup SAI_Handle_Structure_definition SAI Handle Structure definition
Kojto 122:f9eeca106725 211 * @brief SAI handle Structure definition
Kojto 122:f9eeca106725 212 * @{
bogdanm 92:4fc01daae5a5 213 */
Kojto 99:dbbf35b96557 214 typedef struct __SAI_HandleTypeDef
bogdanm 92:4fc01daae5a5 215 {
bogdanm 92:4fc01daae5a5 216 SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */
bogdanm 92:4fc01daae5a5 217
bogdanm 92:4fc01daae5a5 218 SAI_InitTypeDef Init; /*!< SAI communication parameters */
bogdanm 92:4fc01daae5a5 219
bogdanm 92:4fc01daae5a5 220 SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters */
bogdanm 92:4fc01daae5a5 221
bogdanm 92:4fc01daae5a5 222 SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */
bogdanm 92:4fc01daae5a5 223
Kojto 99:dbbf35b96557 224 uint8_t *pBuffPtr; /*!< Pointer to SAI transfer Buffer */
bogdanm 92:4fc01daae5a5 225
Kojto 99:dbbf35b96557 226 uint16_t XferSize; /*!< SAI transfer size */
bogdanm 92:4fc01daae5a5 227
Kojto 99:dbbf35b96557 228 uint16_t XferCount; /*!< SAI transfer counter */
bogdanm 92:4fc01daae5a5 229
bogdanm 92:4fc01daae5a5 230 DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */
bogdanm 92:4fc01daae5a5 231
bogdanm 92:4fc01daae5a5 232 DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */
bogdanm 92:4fc01daae5a5 233
Kojto 122:f9eeca106725 234 SAIcallback mutecallback;/*!< SAI mute callback */
Kojto 122:f9eeca106725 235
Kojto 99:dbbf35b96557 236 void (*InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai); /* function pointer for IRQ handler */
Kojto 122:f9eeca106725 237
bogdanm 92:4fc01daae5a5 238 HAL_LockTypeDef Lock; /*!< SAI locking object */
bogdanm 92:4fc01daae5a5 239
bogdanm 92:4fc01daae5a5 240 __IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */
bogdanm 92:4fc01daae5a5 241
bogdanm 92:4fc01daae5a5 242 __IO uint32_t ErrorCode; /*!< SAI Error code */
bogdanm 92:4fc01daae5a5 243 }SAI_HandleTypeDef;
Kojto 99:dbbf35b96557 244 /**
Kojto 99:dbbf35b96557 245 * @}
Kojto 99:dbbf35b96557 246 */
Kojto 99:dbbf35b96557 247
AnnaBridge 145:64910690c574 248 /**
AnnaBridge 145:64910690c574 249 * @}
AnnaBridge 145:64910690c574 250 */
AnnaBridge 145:64910690c574 251
bogdanm 92:4fc01daae5a5 252 /* Exported constants --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 253
Kojto 99:dbbf35b96557 254 /** @defgroup SAI_Exported_Constants SAI Exported Constants
Kojto 99:dbbf35b96557 255 * @{
Kojto 99:dbbf35b96557 256 */
Kojto 99:dbbf35b96557 257
Kojto 99:dbbf35b96557 258 /** @defgroup SAI_Error_Code SAI Error Code
bogdanm 92:4fc01daae5a5 259 * @{
bogdanm 92:4fc01daae5a5 260 */
AnnaBridge 145:64910690c574 261 #define HAL_SAI_ERROR_NONE 0x00000000U /*!< No error */
AnnaBridge 145:64910690c574 262 #define HAL_SAI_ERROR_OVR 0x00000001U /*!< Overrun Error */
AnnaBridge 145:64910690c574 263 #define HAL_SAI_ERROR_UDR 0x00000002U /*!< Underrun error */
AnnaBridge 145:64910690c574 264 #define HAL_SAI_ERROR_AFSDET 0x00000004U /*!< Anticipated Frame synchronisation detection */
AnnaBridge 145:64910690c574 265 #define HAL_SAI_ERROR_LFSDET 0x00000008U /*!< Late Frame synchronisation detection */
AnnaBridge 145:64910690c574 266 #define HAL_SAI_ERROR_CNREADY 0x00000010U /*!< codec not ready */
AnnaBridge 145:64910690c574 267 #define HAL_SAI_ERROR_WCKCFG 0x00000020U /*!< Wrong clock configuration */
AnnaBridge 145:64910690c574 268 #define HAL_SAI_ERROR_TIMEOUT 0x00000040U /*!< Timeout error */
AnnaBridge 145:64910690c574 269 #define HAL_SAI_ERROR_DMA 0x00000080U /*!< DMA error */
Kojto 99:dbbf35b96557 270 /**
Kojto 99:dbbf35b96557 271 * @}
Kojto 99:dbbf35b96557 272 */
Kojto 99:dbbf35b96557 273
Kojto 99:dbbf35b96557 274 /** @defgroup SAI_Block_SyncExt SAI External synchronisation
bogdanm 92:4fc01daae5a5 275 * @{
Kojto 99:dbbf35b96557 276 */
Kojto 122:f9eeca106725 277 #define SAI_SYNCEXT_DISABLE 0U
Kojto 122:f9eeca106725 278 #define SAI_SYNCEXT_OUTBLOCKA_ENABLE 1U
Kojto 122:f9eeca106725 279 #define SAI_SYNCEXT_OUTBLOCKB_ENABLE 2U
bogdanm 92:4fc01daae5a5 280 /**
bogdanm 92:4fc01daae5a5 281 * @}
bogdanm 92:4fc01daae5a5 282 */
bogdanm 92:4fc01daae5a5 283
Kojto 99:dbbf35b96557 284 /** @defgroup SAI_Protocol SAI Supported protocol
bogdanm 92:4fc01daae5a5 285 * @{
bogdanm 92:4fc01daae5a5 286 */
Kojto 122:f9eeca106725 287 #define SAI_I2S_STANDARD 0U
Kojto 122:f9eeca106725 288 #define SAI_I2S_MSBJUSTIFIED 1U
Kojto 122:f9eeca106725 289 #define SAI_I2S_LSBJUSTIFIED 2U
Kojto 122:f9eeca106725 290 #define SAI_PCM_LONG 3U
Kojto 122:f9eeca106725 291 #define SAI_PCM_SHORT 4U
bogdanm 92:4fc01daae5a5 292 /**
bogdanm 92:4fc01daae5a5 293 * @}
bogdanm 92:4fc01daae5a5 294 */
bogdanm 92:4fc01daae5a5 295
Kojto 99:dbbf35b96557 296 /** @defgroup SAI_Protocol_DataSize SAI protocol data size
Kojto 99:dbbf35b96557 297 * @{
Kojto 99:dbbf35b96557 298 */
Kojto 122:f9eeca106725 299 #define SAI_PROTOCOL_DATASIZE_16BIT 0U
Kojto 122:f9eeca106725 300 #define SAI_PROTOCOL_DATASIZE_16BITEXTENDED 1U
Kojto 122:f9eeca106725 301 #define SAI_PROTOCOL_DATASIZE_24BIT 2U
Kojto 122:f9eeca106725 302 #define SAI_PROTOCOL_DATASIZE_32BIT 3U
Kojto 99:dbbf35b96557 303 /**
Kojto 99:dbbf35b96557 304 * @}
Kojto 99:dbbf35b96557 305 */
Kojto 99:dbbf35b96557 306
Kojto 99:dbbf35b96557 307 /** @defgroup SAI_Audio_Frequency SAI Audio Frequency
bogdanm 92:4fc01daae5a5 308 * @{
bogdanm 92:4fc01daae5a5 309 */
AnnaBridge 145:64910690c574 310 #define SAI_AUDIO_FREQUENCY_192K 192000U
AnnaBridge 145:64910690c574 311 #define SAI_AUDIO_FREQUENCY_96K 96000U
AnnaBridge 145:64910690c574 312 #define SAI_AUDIO_FREQUENCY_48K 48000U
AnnaBridge 145:64910690c574 313 #define SAI_AUDIO_FREQUENCY_44K 44100U
AnnaBridge 145:64910690c574 314 #define SAI_AUDIO_FREQUENCY_32K 32000U
AnnaBridge 145:64910690c574 315 #define SAI_AUDIO_FREQUENCY_22K 22050U
AnnaBridge 145:64910690c574 316 #define SAI_AUDIO_FREQUENCY_16K 16000U
AnnaBridge 145:64910690c574 317 #define SAI_AUDIO_FREQUENCY_11K 11025U
AnnaBridge 145:64910690c574 318 #define SAI_AUDIO_FREQUENCY_8K 8000U
AnnaBridge 145:64910690c574 319 #define SAI_AUDIO_FREQUENCY_MCKDIV 0U
bogdanm 92:4fc01daae5a5 320 /**
bogdanm 92:4fc01daae5a5 321 * @}
bogdanm 92:4fc01daae5a5 322 */
bogdanm 92:4fc01daae5a5 323
Kojto 99:dbbf35b96557 324 /** @defgroup SAI_Block_Mode SAI Block Mode
bogdanm 92:4fc01daae5a5 325 * @{
bogdanm 92:4fc01daae5a5 326 */
AnnaBridge 145:64910690c574 327 #define SAI_MODEMASTER_TX 0x00000000U
Kojto 99:dbbf35b96557 328 #define SAI_MODEMASTER_RX ((uint32_t)SAI_xCR1_MODE_0)
Kojto 99:dbbf35b96557 329 #define SAI_MODESLAVE_TX ((uint32_t)SAI_xCR1_MODE_1)
Kojto 99:dbbf35b96557 330 #define SAI_MODESLAVE_RX ((uint32_t)(SAI_xCR1_MODE_1 | SAI_xCR1_MODE_0))
bogdanm 92:4fc01daae5a5 331 /**
bogdanm 92:4fc01daae5a5 332 * @}
bogdanm 92:4fc01daae5a5 333 */
bogdanm 92:4fc01daae5a5 334
Kojto 99:dbbf35b96557 335 /** @defgroup SAI_Block_Protocol SAI Block Protocol
bogdanm 92:4fc01daae5a5 336 * @{
bogdanm 92:4fc01daae5a5 337 */
AnnaBridge 145:64910690c574 338 #define SAI_FREE_PROTOCOL 0x00000000U
Kojto 99:dbbf35b96557 339 #define SAI_SPDIF_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_0)
bogdanm 92:4fc01daae5a5 340 #define SAI_AC97_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_1)
bogdanm 92:4fc01daae5a5 341 /**
bogdanm 92:4fc01daae5a5 342 * @}
bogdanm 92:4fc01daae5a5 343 */
bogdanm 92:4fc01daae5a5 344
Kojto 99:dbbf35b96557 345 /** @defgroup SAI_Block_Data_Size SAI Block Data Size
bogdanm 92:4fc01daae5a5 346 * @{
bogdanm 92:4fc01daae5a5 347 */
Kojto 99:dbbf35b96557 348 #define SAI_DATASIZE_8 ((uint32_t)SAI_xCR1_DS_1)
Kojto 99:dbbf35b96557 349 #define SAI_DATASIZE_10 ((uint32_t)(SAI_xCR1_DS_1 | SAI_xCR1_DS_0))
Kojto 99:dbbf35b96557 350 #define SAI_DATASIZE_16 ((uint32_t)SAI_xCR1_DS_2)
Kojto 99:dbbf35b96557 351 #define SAI_DATASIZE_20 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_0))
Kojto 99:dbbf35b96557 352 #define SAI_DATASIZE_24 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_1))
Kojto 99:dbbf35b96557 353 #define SAI_DATASIZE_32 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_1 | SAI_xCR1_DS_0))
bogdanm 92:4fc01daae5a5 354 /**
bogdanm 92:4fc01daae5a5 355 * @}
Kojto 122:f9eeca106725 356 */
bogdanm 92:4fc01daae5a5 357
Kojto 122:f9eeca106725 358 /** @defgroup SAI_Block_MSB_LSB_transmission SAI Block MSB LSB transmission
bogdanm 92:4fc01daae5a5 359 * @{
bogdanm 92:4fc01daae5a5 360 */
AnnaBridge 145:64910690c574 361 #define SAI_FIRSTBIT_MSB 0x00000000U
bogdanm 92:4fc01daae5a5 362 #define SAI_FIRSTBIT_LSB ((uint32_t)SAI_xCR1_LSBFIRST)
bogdanm 92:4fc01daae5a5 363 /**
bogdanm 92:4fc01daae5a5 364 * @}
bogdanm 92:4fc01daae5a5 365 */
bogdanm 92:4fc01daae5a5 366
Kojto 99:dbbf35b96557 367 /** @defgroup SAI_Block_Clock_Strobing SAI Block Clock Strobing
bogdanm 92:4fc01daae5a5 368 * @{
bogdanm 92:4fc01daae5a5 369 */
Kojto 122:f9eeca106725 370 #define SAI_CLOCKSTROBING_FALLINGEDGE 0U
Kojto 122:f9eeca106725 371 #define SAI_CLOCKSTROBING_RISINGEDGE 1U
bogdanm 92:4fc01daae5a5 372 /**
bogdanm 92:4fc01daae5a5 373 * @}
bogdanm 92:4fc01daae5a5 374 */
bogdanm 92:4fc01daae5a5 375
Kojto 99:dbbf35b96557 376 /** @defgroup SAI_Block_Synchronization SAI Block Synchronization
bogdanm 92:4fc01daae5a5 377 * @{
bogdanm 92:4fc01daae5a5 378 */
Kojto 122:f9eeca106725 379 #define SAI_ASYNCHRONOUS 0U /*!< Asynchronous */
Kojto 122:f9eeca106725 380 #define SAI_SYNCHRONOUS 1U /*!< Synchronous with other block of same SAI */
Kojto 122:f9eeca106725 381 #define SAI_SYNCHRONOUS_EXT_SAI1 2U /*!< Synchronous with other SAI, SAI1 */
Kojto 122:f9eeca106725 382 #define SAI_SYNCHRONOUS_EXT_SAI2 3U /*!< Synchronous with other SAI, SAI2 */
bogdanm 92:4fc01daae5a5 383 /**
bogdanm 92:4fc01daae5a5 384 * @}
Kojto 122:f9eeca106725 385 */
bogdanm 92:4fc01daae5a5 386
Kojto 99:dbbf35b96557 387 /** @defgroup SAI_Block_Output_Drive SAI Block Output Drive
bogdanm 92:4fc01daae5a5 388 * @{
bogdanm 92:4fc01daae5a5 389 */
AnnaBridge 145:64910690c574 390 #define SAI_OUTPUTDRIVE_DISABLE 0x00000000U
Kojto 99:dbbf35b96557 391 #define SAI_OUTPUTDRIVE_ENABLE ((uint32_t)SAI_xCR1_OUTDRIV)
Kojto 99:dbbf35b96557 392 /**
Kojto 99:dbbf35b96557 393 * @}
Kojto 122:f9eeca106725 394 */
bogdanm 92:4fc01daae5a5 395
Kojto 99:dbbf35b96557 396 /** @defgroup SAI_Block_NoDivider SAI Block NoDivider
Kojto 99:dbbf35b96557 397 * @{
Kojto 99:dbbf35b96557 398 */
AnnaBridge 145:64910690c574 399 #define SAI_MASTERDIVIDER_ENABLE 0x00000000U
Kojto 99:dbbf35b96557 400 #define SAI_MASTERDIVIDER_DISABLE ((uint32_t)SAI_xCR1_NODIV)
bogdanm 92:4fc01daae5a5 401 /**
bogdanm 92:4fc01daae5a5 402 * @}
bogdanm 92:4fc01daae5a5 403 */
bogdanm 92:4fc01daae5a5 404
Kojto 99:dbbf35b96557 405 /** @defgroup SAI_Block_FS_Definition SAI Block FS Definition
bogdanm 92:4fc01daae5a5 406 * @{
bogdanm 92:4fc01daae5a5 407 */
AnnaBridge 145:64910690c574 408 #define SAI_FS_STARTFRAME 0x00000000U
bogdanm 92:4fc01daae5a5 409 #define SAI_FS_CHANNEL_IDENTIFICATION ((uint32_t)SAI_xFRCR_FSDEF)
bogdanm 92:4fc01daae5a5 410 /**
bogdanm 92:4fc01daae5a5 411 * @}
bogdanm 92:4fc01daae5a5 412 */
bogdanm 92:4fc01daae5a5 413
Kojto 99:dbbf35b96557 414 /** @defgroup SAI_Block_FS_Polarity SAI Block FS Polarity
bogdanm 92:4fc01daae5a5 415 * @{
bogdanm 92:4fc01daae5a5 416 */
AnnaBridge 145:64910690c574 417 #define SAI_FS_ACTIVE_LOW 0x00000000U
Kojto 122:f9eeca106725 418 #define SAI_FS_ACTIVE_HIGH ((uint32_t)SAI_xFRCR_FSPOL)
bogdanm 92:4fc01daae5a5 419 /**
bogdanm 92:4fc01daae5a5 420 * @}
bogdanm 92:4fc01daae5a5 421 */
Kojto 122:f9eeca106725 422
Kojto 99:dbbf35b96557 423 /** @defgroup SAI_Block_FS_Offset SAI Block FS Offset
bogdanm 92:4fc01daae5a5 424 * @{
bogdanm 92:4fc01daae5a5 425 */
AnnaBridge 145:64910690c574 426 #define SAI_FS_FIRSTBIT 0x00000000U
bogdanm 92:4fc01daae5a5 427 #define SAI_FS_BEFOREFIRSTBIT ((uint32_t)SAI_xFRCR_FSOFF)
bogdanm 92:4fc01daae5a5 428 /**
bogdanm 92:4fc01daae5a5 429 * @}
bogdanm 92:4fc01daae5a5 430 */
bogdanm 92:4fc01daae5a5 431
Kojto 122:f9eeca106725 432 /** @defgroup SAI_Block_Slot_Size SAI Block Slot Size
bogdanm 92:4fc01daae5a5 433 * @{
bogdanm 92:4fc01daae5a5 434 */
AnnaBridge 145:64910690c574 435 #define SAI_SLOTSIZE_DATASIZE 0x00000000U
bogdanm 92:4fc01daae5a5 436 #define SAI_SLOTSIZE_16B ((uint32_t)SAI_xSLOTR_SLOTSZ_0)
bogdanm 92:4fc01daae5a5 437 #define SAI_SLOTSIZE_32B ((uint32_t)SAI_xSLOTR_SLOTSZ_1)
bogdanm 92:4fc01daae5a5 438 /**
bogdanm 92:4fc01daae5a5 439 * @}
bogdanm 92:4fc01daae5a5 440 */
Kojto 122:f9eeca106725 441
Kojto 99:dbbf35b96557 442 /** @defgroup SAI_Block_Slot_Active SAI Block Slot Active
bogdanm 92:4fc01daae5a5 443 * @{
bogdanm 92:4fc01daae5a5 444 */
AnnaBridge 145:64910690c574 445 #define SAI_SLOT_NOTACTIVE 0x00000000U
AnnaBridge 145:64910690c574 446 #define SAI_SLOTACTIVE_0 0x00000001U
AnnaBridge 145:64910690c574 447 #define SAI_SLOTACTIVE_1 0x00000002U
AnnaBridge 145:64910690c574 448 #define SAI_SLOTACTIVE_2 0x00000004U
AnnaBridge 145:64910690c574 449 #define SAI_SLOTACTIVE_3 0x00000008U
AnnaBridge 145:64910690c574 450 #define SAI_SLOTACTIVE_4 0x00000010U
AnnaBridge 145:64910690c574 451 #define SAI_SLOTACTIVE_5 0x00000020U
AnnaBridge 145:64910690c574 452 #define SAI_SLOTACTIVE_6 0x00000040U
AnnaBridge 145:64910690c574 453 #define SAI_SLOTACTIVE_7 0x00000080U
AnnaBridge 145:64910690c574 454 #define SAI_SLOTACTIVE_8 0x00000100U
AnnaBridge 145:64910690c574 455 #define SAI_SLOTACTIVE_9 0x00000200U
AnnaBridge 145:64910690c574 456 #define SAI_SLOTACTIVE_10 0x00000400U
AnnaBridge 145:64910690c574 457 #define SAI_SLOTACTIVE_11 0x00000800U
AnnaBridge 145:64910690c574 458 #define SAI_SLOTACTIVE_12 0x00001000U
AnnaBridge 145:64910690c574 459 #define SAI_SLOTACTIVE_13 0x00002000U
AnnaBridge 145:64910690c574 460 #define SAI_SLOTACTIVE_14 0x00004000U
AnnaBridge 145:64910690c574 461 #define SAI_SLOTACTIVE_15 0x00008000U
AnnaBridge 145:64910690c574 462 #define SAI_SLOTACTIVE_ALL 0x0000FFFFU
Kojto 99:dbbf35b96557 463 /**
Kojto 99:dbbf35b96557 464 * @}
Kojto 99:dbbf35b96557 465 */
Kojto 99:dbbf35b96557 466
Kojto 99:dbbf35b96557 467 /** @defgroup SAI_Mono_Stereo_Mode SAI Mono Stereo Mode
Kojto 99:dbbf35b96557 468 * @{
Kojto 99:dbbf35b96557 469 */
AnnaBridge 145:64910690c574 470 #define SAI_STEREOMODE 0x00000000U
Kojto 99:dbbf35b96557 471 #define SAI_MONOMODE ((uint32_t)SAI_xCR1_MONO)
bogdanm 92:4fc01daae5a5 472 /**
bogdanm 92:4fc01daae5a5 473 * @}
bogdanm 92:4fc01daae5a5 474 */
bogdanm 92:4fc01daae5a5 475
Kojto 99:dbbf35b96557 476 /** @defgroup SAI_TRIState_Management SAI TRIState Management
bogdanm 92:4fc01daae5a5 477 * @{
bogdanm 92:4fc01daae5a5 478 */
AnnaBridge 145:64910690c574 479 #define SAI_OUTPUT_NOTRELEASED 0x00000000U
bogdanm 92:4fc01daae5a5 480 #define SAI_OUTPUT_RELEASED ((uint32_t)SAI_xCR2_TRIS)
bogdanm 92:4fc01daae5a5 481 /**
bogdanm 92:4fc01daae5a5 482 * @}
bogdanm 92:4fc01daae5a5 483 */
bogdanm 92:4fc01daae5a5 484
Kojto 122:f9eeca106725 485 /** @defgroup SAI_Block_Fifo_Threshold SAI Block Fifo Threshold
bogdanm 92:4fc01daae5a5 486 * @{
bogdanm 92:4fc01daae5a5 487 */
AnnaBridge 145:64910690c574 488 #define SAI_FIFOTHRESHOLD_EMPTY 0x00000000U
Kojto 122:f9eeca106725 489 #define SAI_FIFOTHRESHOLD_1QF ((uint32_t)(SAI_xCR2_FTH_0))
Kojto 122:f9eeca106725 490 #define SAI_FIFOTHRESHOLD_HF ((uint32_t)(SAI_xCR2_FTH_1))
Kojto 99:dbbf35b96557 491 #define SAI_FIFOTHRESHOLD_3QF ((uint32_t)(SAI_xCR2_FTH_1 | SAI_xCR2_FTH_0))
Kojto 122:f9eeca106725 492 #define SAI_FIFOTHRESHOLD_FULL ((uint32_t)(SAI_xCR2_FTH_2))
bogdanm 92:4fc01daae5a5 493 /**
bogdanm 92:4fc01daae5a5 494 * @}
bogdanm 92:4fc01daae5a5 495 */
Kojto 122:f9eeca106725 496
Kojto 99:dbbf35b96557 497 /** @defgroup SAI_Block_Companding_Mode SAI Block Companding Mode
bogdanm 92:4fc01daae5a5 498 * @{
bogdanm 92:4fc01daae5a5 499 */
AnnaBridge 145:64910690c574 500 #define SAI_NOCOMPANDING 0x00000000U
Kojto 122:f9eeca106725 501 #define SAI_ULAW_1CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1))
Kojto 122:f9eeca106725 502 #define SAI_ALAW_1CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0))
Kojto 122:f9eeca106725 503 #define SAI_ULAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_CPL))
Kojto 122:f9eeca106725 504 #define SAI_ALAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0 | SAI_xCR2_CPL))
bogdanm 92:4fc01daae5a5 505 /**
bogdanm 92:4fc01daae5a5 506 * @}
bogdanm 92:4fc01daae5a5 507 */
bogdanm 92:4fc01daae5a5 508
Kojto 99:dbbf35b96557 509 /** @defgroup SAI_Block_Mute_Value SAI Block Mute Value
bogdanm 92:4fc01daae5a5 510 * @{
bogdanm 92:4fc01daae5a5 511 */
AnnaBridge 145:64910690c574 512 #define SAI_ZERO_VALUE 0x00000000U
bogdanm 92:4fc01daae5a5 513 #define SAI_LAST_SENT_VALUE ((uint32_t)SAI_xCR2_MUTEVAL)
bogdanm 92:4fc01daae5a5 514 /**
bogdanm 92:4fc01daae5a5 515 * @}
bogdanm 92:4fc01daae5a5 516 */
bogdanm 92:4fc01daae5a5 517
Kojto 99:dbbf35b96557 518 /** @defgroup SAI_Block_Interrupts_Definition SAI Block Interrupts Definition
bogdanm 92:4fc01daae5a5 519 * @{
bogdanm 92:4fc01daae5a5 520 */
bogdanm 92:4fc01daae5a5 521 #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE)
bogdanm 92:4fc01daae5a5 522 #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE)
bogdanm 92:4fc01daae5a5 523 #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE)
bogdanm 92:4fc01daae5a5 524 #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE)
bogdanm 92:4fc01daae5a5 525 #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE)
bogdanm 92:4fc01daae5a5 526 #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE)
bogdanm 92:4fc01daae5a5 527 #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE)
bogdanm 92:4fc01daae5a5 528 /**
bogdanm 92:4fc01daae5a5 529 * @}
bogdanm 92:4fc01daae5a5 530 */
bogdanm 92:4fc01daae5a5 531
Kojto 99:dbbf35b96557 532 /** @defgroup SAI_Block_Flags_Definition SAI Block Flags Definition
bogdanm 92:4fc01daae5a5 533 * @{
bogdanm 92:4fc01daae5a5 534 */
bogdanm 92:4fc01daae5a5 535 #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR)
bogdanm 92:4fc01daae5a5 536 #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET)
bogdanm 92:4fc01daae5a5 537 #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG)
bogdanm 92:4fc01daae5a5 538 #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ)
bogdanm 92:4fc01daae5a5 539 #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY)
bogdanm 92:4fc01daae5a5 540 #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET)
bogdanm 92:4fc01daae5a5 541 #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET)
bogdanm 92:4fc01daae5a5 542 /**
bogdanm 92:4fc01daae5a5 543 * @}
bogdanm 92:4fc01daae5a5 544 */
Kojto 122:f9eeca106725 545
Kojto 99:dbbf35b96557 546 /** @defgroup SAI_Block_Fifo_Status_Level SAI Block Fifo Status Level
bogdanm 92:4fc01daae5a5 547 * @{
bogdanm 92:4fc01daae5a5 548 */
AnnaBridge 145:64910690c574 549 #define SAI_FIFOSTATUS_EMPTY 0x00000000U
AnnaBridge 145:64910690c574 550 #define SAI_FIFOSTATUS_LESS1QUARTERFULL 0x00010000U
AnnaBridge 145:64910690c574 551 #define SAI_FIFOSTATUS_1QUARTERFULL 0x00020000U
AnnaBridge 145:64910690c574 552 #define SAI_FIFOSTATUS_HALFFULL 0x00030000U
AnnaBridge 145:64910690c574 553 #define SAI_FIFOSTATUS_3QUARTERFULL 0x00040000U
AnnaBridge 145:64910690c574 554 #define SAI_FIFOSTATUS_FULL 0x00050000U
bogdanm 92:4fc01daae5a5 555 /**
bogdanm 92:4fc01daae5a5 556 * @}
bogdanm 92:4fc01daae5a5 557 */
bogdanm 92:4fc01daae5a5 558
bogdanm 92:4fc01daae5a5 559 /**
bogdanm 92:4fc01daae5a5 560 * @}
bogdanm 92:4fc01daae5a5 561 */
Kojto 122:f9eeca106725 562
bogdanm 92:4fc01daae5a5 563 /* Exported macro ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 564
Kojto 99:dbbf35b96557 565 /** @defgroup SAI_Exported_Macros SAI Exported Macros
Kojto 99:dbbf35b96557 566 * @brief macros to handle interrupts and specific configurations
Kojto 99:dbbf35b96557 567 * @{
Kojto 99:dbbf35b96557 568 */
Kojto 122:f9eeca106725 569
bogdanm 92:4fc01daae5a5 570 /** @brief Reset SAI handle state
bogdanm 92:4fc01daae5a5 571 * @param __HANDLE__: specifies the SAI Handle.
Kojto 122:f9eeca106725 572 * @retval NoneS
bogdanm 92:4fc01daae5a5 573 */
bogdanm 92:4fc01daae5a5 574 #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET)
bogdanm 92:4fc01daae5a5 575
bogdanm 92:4fc01daae5a5 576 /** @brief Enable or disable the specified SAI interrupts.
bogdanm 92:4fc01daae5a5 577 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 92:4fc01daae5a5 578 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
bogdanm 92:4fc01daae5a5 579 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 580 * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
Kojto 122:f9eeca106725 581 * @arg SAI_IT_MUTEDET: Mute detection interrupt enable
Kojto 122:f9eeca106725 582 * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
Kojto 122:f9eeca106725 583 * @arg SAI_IT_FREQ: FIFO request interrupt enable
Kojto 122:f9eeca106725 584 * @arg SAI_IT_CNRDY: Codec not ready interrupt enable
Kojto 122:f9eeca106725 585 * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
Kojto 122:f9eeca106725 586 * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable
bogdanm 92:4fc01daae5a5 587 * @retval None
bogdanm 92:4fc01daae5a5 588 */
bogdanm 92:4fc01daae5a5 589 #define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
bogdanm 92:4fc01daae5a5 590 #define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__)))
Kojto 122:f9eeca106725 591
bogdanm 92:4fc01daae5a5 592 /** @brief Check if the specified SAI interrupt source is enabled or disabled.
bogdanm 92:4fc01daae5a5 593 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 92:4fc01daae5a5 594 * This parameter can be SAI where x: 1, 2, or 3 to select the SAI peripheral.
bogdanm 92:4fc01daae5a5 595 * @param __INTERRUPT__: specifies the SAI interrupt source to check.
bogdanm 92:4fc01daae5a5 596 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 597 * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
Kojto 122:f9eeca106725 598 * @arg SAI_IT_MUTEDET: Mute detection interrupt enable
Kojto 122:f9eeca106725 599 * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
Kojto 122:f9eeca106725 600 * @arg SAI_IT_FREQ: FIFO request interrupt enable
Kojto 122:f9eeca106725 601 * @arg SAI_IT_CNRDY: Codec not ready interrupt enable
Kojto 122:f9eeca106725 602 * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
Kojto 122:f9eeca106725 603 * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable
bogdanm 92:4fc01daae5a5 604 * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
bogdanm 92:4fc01daae5a5 605 */
bogdanm 92:4fc01daae5a5 606 #define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
bogdanm 92:4fc01daae5a5 607
bogdanm 92:4fc01daae5a5 608 /** @brief Check whether the specified SAI flag is set or not.
bogdanm 92:4fc01daae5a5 609 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 92:4fc01daae5a5 610 * @param __FLAG__: specifies the flag to check.
bogdanm 92:4fc01daae5a5 611 * This parameter can be one of the following values:
bogdanm 92:4fc01daae5a5 612 * @arg SAI_FLAG_OVRUDR: Overrun underrun flag.
bogdanm 92:4fc01daae5a5 613 * @arg SAI_FLAG_MUTEDET: Mute detection flag.
bogdanm 92:4fc01daae5a5 614 * @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag.
bogdanm 92:4fc01daae5a5 615 * @arg SAI_FLAG_FREQ: FIFO request flag.
bogdanm 92:4fc01daae5a5 616 * @arg SAI_FLAG_CNRDY: Codec not ready flag.
bogdanm 92:4fc01daae5a5 617 * @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag.
bogdanm 92:4fc01daae5a5 618 * @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag.
bogdanm 92:4fc01daae5a5 619 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 92:4fc01daae5a5 620 */
bogdanm 92:4fc01daae5a5 621 #define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
bogdanm 92:4fc01daae5a5 622
Kojto 122:f9eeca106725 623 /** @brief Clear the specified SAI pending flag.
bogdanm 92:4fc01daae5a5 624 * @param __HANDLE__: specifies the SAI Handle.
bogdanm 92:4fc01daae5a5 625 * @param __FLAG__: specifies the flag to check.
bogdanm 92:4fc01daae5a5 626 * This parameter can be any combination of the following values:
bogdanm 92:4fc01daae5a5 627 * @arg SAI_FLAG_OVRUDR: Clear Overrun underrun
bogdanm 92:4fc01daae5a5 628 * @arg SAI_FLAG_MUTEDET: Clear Mute detection
bogdanm 92:4fc01daae5a5 629 * @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration
bogdanm 92:4fc01daae5a5 630 * @arg SAI_FLAG_FREQ: Clear FIFO request
bogdanm 92:4fc01daae5a5 631 * @arg SAI_FLAG_CNRDY: Clear Codec not ready
bogdanm 92:4fc01daae5a5 632 * @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection
bogdanm 92:4fc01daae5a5 633 * @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection
bogdanm 92:4fc01daae5a5 634 * @retval None
bogdanm 92:4fc01daae5a5 635 */
Kojto 122:f9eeca106725 636 #define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__))
bogdanm 92:4fc01daae5a5 637
Kojto 122:f9eeca106725 638 /** @brief Enable SAI
Kojto 122:f9eeca106725 639 * @param __HANDLE__: specifies the SAI Handle.
Kojto 122:f9eeca106725 640 * @retval None
Kojto 122:f9eeca106725 641 */
bogdanm 92:4fc01daae5a5 642 #define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN)
Kojto 122:f9eeca106725 643
Kojto 122:f9eeca106725 644 /** @brief Disable SAI
Kojto 122:f9eeca106725 645 * @param __HANDLE__: specifies the SAI Handle.
Kojto 122:f9eeca106725 646 * @retval None
Kojto 122:f9eeca106725 647 */
bogdanm 92:4fc01daae5a5 648 #define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN)
Kojto 99:dbbf35b96557 649
Kojto 99:dbbf35b96557 650 /**
Kojto 99:dbbf35b96557 651 * @}
Kojto 99:dbbf35b96557 652 */
Kojto 99:dbbf35b96557 653
Kojto 99:dbbf35b96557 654 /* Include RCC SAI Extension module */
Kojto 99:dbbf35b96557 655 #include "stm32f4xx_hal_sai_ex.h"
Kojto 99:dbbf35b96557 656
bogdanm 92:4fc01daae5a5 657 /* Exported functions --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 658
Kojto 99:dbbf35b96557 659 /** @addtogroup SAI_Exported_Functions
Kojto 99:dbbf35b96557 660 * @{
Kojto 99:dbbf35b96557 661 */
Kojto 99:dbbf35b96557 662
bogdanm 92:4fc01daae5a5 663 /* Initialization/de-initialization functions **********************************/
Kojto 99:dbbf35b96557 664 /** @addtogroup SAI_Exported_Functions_Group1
Kojto 99:dbbf35b96557 665 * @{
Kojto 99:dbbf35b96557 666 */
Kojto 110:165afa46840b 667 HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot);
bogdanm 92:4fc01daae5a5 668 HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 669 HAL_StatusTypeDef HAL_SAI_DeInit (SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 670 void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 671 void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 672
Kojto 99:dbbf35b96557 673 /**
Kojto 99:dbbf35b96557 674 * @}
Kojto 99:dbbf35b96557 675 */
Kojto 99:dbbf35b96557 676
bogdanm 92:4fc01daae5a5 677 /* I/O operation functions *****************************************************/
Kojto 99:dbbf35b96557 678 /** @addtogroup SAI_Exported_Functions_Group2
Kojto 99:dbbf35b96557 679 * @{
Kojto 99:dbbf35b96557 680 */
bogdanm 92:4fc01daae5a5 681 /* Blocking mode: Polling */
Kojto 99:dbbf35b96557 682 HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 99:dbbf35b96557 683 HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 92:4fc01daae5a5 684
bogdanm 92:4fc01daae5a5 685 /* Non-Blocking mode: Interrupt */
Kojto 99:dbbf35b96557 686 HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
Kojto 99:dbbf35b96557 687 HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
bogdanm 92:4fc01daae5a5 688
bogdanm 92:4fc01daae5a5 689 /* Non-Blocking mode: DMA */
Kojto 99:dbbf35b96557 690 HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
Kojto 99:dbbf35b96557 691 HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
bogdanm 92:4fc01daae5a5 692 HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 693 HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 694 HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 695
Kojto 99:dbbf35b96557 696 /* Abort function */
Kojto 99:dbbf35b96557 697 HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai);
Kojto 99:dbbf35b96557 698
Kojto 99:dbbf35b96557 699 /* Mute management */
Kojto 99:dbbf35b96557 700 HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val);
Kojto 99:dbbf35b96557 701 HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai);
Kojto 99:dbbf35b96557 702 HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter);
Kojto 99:dbbf35b96557 703 HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai);
Kojto 99:dbbf35b96557 704
bogdanm 92:4fc01daae5a5 705 /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
bogdanm 92:4fc01daae5a5 706 void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 707 void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 708 void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 709 void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 710 void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 711 void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai);
Kojto 99:dbbf35b96557 712 /**
Kojto 99:dbbf35b96557 713 * @}
Kojto 99:dbbf35b96557 714 */
bogdanm 92:4fc01daae5a5 715
Kojto 99:dbbf35b96557 716 /** @addtogroup SAI_Exported_Functions_Group3
Kojto 99:dbbf35b96557 717 * @{
Kojto 99:dbbf35b96557 718 */
Kojto 122:f9eeca106725 719 /* Peripheral State functions ************************************************/
bogdanm 92:4fc01daae5a5 720 HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai);
bogdanm 92:4fc01daae5a5 721 uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai);
Kojto 99:dbbf35b96557 722 /**
Kojto 99:dbbf35b96557 723 * @}
Kojto 99:dbbf35b96557 724 */
Kojto 99:dbbf35b96557 725
Kojto 99:dbbf35b96557 726 /**
Kojto 99:dbbf35b96557 727 * @}
Kojto 99:dbbf35b96557 728 */
Kojto 99:dbbf35b96557 729
Kojto 99:dbbf35b96557 730 /* Private macros ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 731 /** @addtogroup SAI_Private_Macros
Kojto 99:dbbf35b96557 732 * @{
Kojto 99:dbbf35b96557 733 */
Kojto 99:dbbf35b96557 734 #define IS_SAI_BLOCK_SYNCEXT(STATE) (((STATE) == SAI_SYNCEXT_DISABLE) ||\
Kojto 99:dbbf35b96557 735 ((STATE) == SAI_SYNCEXT_OUTBLOCKA_ENABLE) ||\
Kojto 99:dbbf35b96557 736 ((STATE) == SAI_SYNCEXT_OUTBLOCKB_ENABLE))
Kojto 99:dbbf35b96557 737
Kojto 99:dbbf35b96557 738 #define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_I2S_STANDARD) ||\
Kojto 99:dbbf35b96557 739 ((PROTOCOL) == SAI_I2S_MSBJUSTIFIED) ||\
Kojto 99:dbbf35b96557 740 ((PROTOCOL) == SAI_I2S_LSBJUSTIFIED) ||\
Kojto 99:dbbf35b96557 741 ((PROTOCOL) == SAI_PCM_LONG) ||\
Kojto 99:dbbf35b96557 742 ((PROTOCOL) == SAI_PCM_SHORT))
Kojto 99:dbbf35b96557 743
Kojto 99:dbbf35b96557 744 #define IS_SAI_PROTOCOL_DATASIZE(DATASIZE) (((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BIT) ||\
Kojto 99:dbbf35b96557 745 ((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BITEXTENDED) ||\
Kojto 99:dbbf35b96557 746 ((DATASIZE) == SAI_PROTOCOL_DATASIZE_24BIT) ||\
Kojto 99:dbbf35b96557 747 ((DATASIZE) == SAI_PROTOCOL_DATASIZE_32BIT))
Kojto 99:dbbf35b96557 748
Kojto 99:dbbf35b96557 749 #define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \
Kojto 99:dbbf35b96557 750 ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \
Kojto 99:dbbf35b96557 751 ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \
Kojto 99:dbbf35b96557 752 ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \
Kojto 99:dbbf35b96557 753 ((AUDIO) == SAI_AUDIO_FREQUENCY_8K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV))
Kojto 99:dbbf35b96557 754
Kojto 99:dbbf35b96557 755 #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \
Kojto 99:dbbf35b96557 756 ((MODE) == SAI_MODEMASTER_RX) || \
Kojto 99:dbbf35b96557 757 ((MODE) == SAI_MODESLAVE_TX) || \
Kojto 99:dbbf35b96557 758 ((MODE) == SAI_MODESLAVE_RX))
Kojto 99:dbbf35b96557 759
Kojto 99:dbbf35b96557 760 #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \
Kojto 99:dbbf35b96557 761 ((PROTOCOL) == SAI_AC97_PROTOCOL) || \
Kojto 99:dbbf35b96557 762 ((PROTOCOL) == SAI_SPDIF_PROTOCOL))
Kojto 99:dbbf35b96557 763
Kojto 99:dbbf35b96557 764 #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \
Kojto 99:dbbf35b96557 765 ((DATASIZE) == SAI_DATASIZE_10) || \
Kojto 99:dbbf35b96557 766 ((DATASIZE) == SAI_DATASIZE_16) || \
Kojto 99:dbbf35b96557 767 ((DATASIZE) == SAI_DATASIZE_20) || \
Kojto 99:dbbf35b96557 768 ((DATASIZE) == SAI_DATASIZE_24) || \
Kojto 99:dbbf35b96557 769 ((DATASIZE) == SAI_DATASIZE_32))
Kojto 99:dbbf35b96557 770
Kojto 99:dbbf35b96557 771 #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \
Kojto 99:dbbf35b96557 772 ((BIT) == SAI_FIRSTBIT_LSB))
Kojto 99:dbbf35b96557 773
Kojto 99:dbbf35b96557 774 #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \
Kojto 99:dbbf35b96557 775 ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE))
Kojto 99:dbbf35b96557 776
Kojto 122:f9eeca106725 777 #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \
Kojto 122:f9eeca106725 778 ((SYNCHRO) == SAI_SYNCHRONOUS) || \
Kojto 122:f9eeca106725 779 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1) ||\
Kojto 122:f9eeca106725 780 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI2))
Kojto 99:dbbf35b96557 781
Kojto 99:dbbf35b96557 782 #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLE) || \
Kojto 99:dbbf35b96557 783 ((DRIVE) == SAI_OUTPUTDRIVE_ENABLE))
Kojto 99:dbbf35b96557 784
Kojto 99:dbbf35b96557 785 #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLE) || \
Kojto 122:f9eeca106725 786 ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLE))
Kojto 99:dbbf35b96557 787
Kojto 122:f9eeca106725 788 #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63U)
Kojto 99:dbbf35b96557 789
Kojto 99:dbbf35b96557 790 #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \
Kojto 99:dbbf35b96557 791 ((VALUE) == SAI_LAST_SENT_VALUE))
Kojto 99:dbbf35b96557 792
Kojto 99:dbbf35b96557 793 #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \
Kojto 99:dbbf35b96557 794 ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \
Kojto 99:dbbf35b96557 795 ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \
Kojto 99:dbbf35b96557 796 ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \
Kojto 99:dbbf35b96557 797 ((MODE) == SAI_ALAW_2CPL_COMPANDING))
Kojto 99:dbbf35b96557 798
Kojto 99:dbbf35b96557 799 #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \
Kojto 99:dbbf35b96557 800 ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \
Kojto 99:dbbf35b96557 801 ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \
Kojto 99:dbbf35b96557 802 ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \
Kojto 99:dbbf35b96557 803 ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL))
Kojto 99:dbbf35b96557 804
Kojto 99:dbbf35b96557 805 #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\
Kojto 99:dbbf35b96557 806 ((STATE) == SAI_OUTPUT_RELEASED))
Kojto 99:dbbf35b96557 807
Kojto 99:dbbf35b96557 808 #define IS_SAI_MONO_STEREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\
Kojto 99:dbbf35b96557 809 ((MODE) == SAI_STEREOMODE))
Kojto 99:dbbf35b96557 810
Kojto 122:f9eeca106725 811 #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) <= SAI_SLOTACTIVE_ALL)
Kojto 99:dbbf35b96557 812
Kojto 122:f9eeca106725 813 #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1U <= (NUMBER)) && ((NUMBER) <= 16U))
Kojto 99:dbbf35b96557 814
Kojto 99:dbbf35b96557 815 #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \
Kojto 99:dbbf35b96557 816 ((SIZE) == SAI_SLOTSIZE_16B) || \
Kojto 99:dbbf35b96557 817 ((SIZE) == SAI_SLOTSIZE_32B))
Kojto 99:dbbf35b96557 818
Kojto 122:f9eeca106725 819 #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24U)
Kojto 99:dbbf35b96557 820
Kojto 99:dbbf35b96557 821 #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \
Kojto 99:dbbf35b96557 822 ((OFFSET) == SAI_FS_BEFOREFIRSTBIT))
Kojto 99:dbbf35b96557 823
Kojto 99:dbbf35b96557 824 #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \
Kojto 99:dbbf35b96557 825 ((POLARITY) == SAI_FS_ACTIVE_HIGH))
Kojto 99:dbbf35b96557 826
Kojto 99:dbbf35b96557 827 #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \
Kojto 122:f9eeca106725 828 ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION))
Kojto 122:f9eeca106725 829
Kojto 122:f9eeca106725 830 #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15U)
Kojto 99:dbbf35b96557 831
Kojto 122:f9eeca106725 832 #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8U <= (LENGTH)) && ((LENGTH) <= 256U))
Kojto 99:dbbf35b96557 833
Kojto 122:f9eeca106725 834 #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1U <= (LENGTH)) && ((LENGTH) <= 128U))
Kojto 122:f9eeca106725 835
Kojto 122:f9eeca106725 836
Kojto 99:dbbf35b96557 837 /**
Kojto 99:dbbf35b96557 838 * @}
Kojto 99:dbbf35b96557 839 */
Kojto 99:dbbf35b96557 840
Kojto 99:dbbf35b96557 841 /* Private functions ---------------------------------------------------------*/
Kojto 99:dbbf35b96557 842 /** @defgroup SAI_Private_Functions SAI Private Functions
Kojto 99:dbbf35b96557 843 * @{
Kojto 99:dbbf35b96557 844 */
Kojto 99:dbbf35b96557 845
Kojto 99:dbbf35b96557 846 /**
Kojto 99:dbbf35b96557 847 * @}
Kojto 99:dbbf35b96557 848 */
Kojto 110:165afa46840b 849
bogdanm 92:4fc01daae5a5 850 /**
bogdanm 92:4fc01daae5a5 851 * @}
AnnaBridge 145:64910690c574 852 */
AnnaBridge 145:64910690c574 853
AnnaBridge 145:64910690c574 854 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx || STM32F413xx || STM32F423xx */
bogdanm 92:4fc01daae5a5 855
bogdanm 92:4fc01daae5a5 856 /**
bogdanm 92:4fc01daae5a5 857 * @}
bogdanm 92:4fc01daae5a5 858 */
bogdanm 92:4fc01daae5a5 859
bogdanm 92:4fc01daae5a5 860 #ifdef __cplusplus
bogdanm 92:4fc01daae5a5 861 }
bogdanm 92:4fc01daae5a5 862 #endif
bogdanm 92:4fc01daae5a5 863
bogdanm 92:4fc01daae5a5 864 #endif /* __STM32F4xx_HAL_SAI_H */
bogdanm 92:4fc01daae5a5 865
bogdanm 92:4fc01daae5a5 866 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/