Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

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