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

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Wed Jul 02 13:22:23 2014 +0100
Revision:
86:04dd9b1680ae
Release 86 of the mbed library

Main changes:


- bug fixes in various backends
- mbed "error" replaced by assert logic (mbed_assert)
- new ST Nucleo targets

Who changed what in which revision?

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