DHT11

Committer:
jhon309
Date:
Thu Aug 13 00:21:57 2015 +0000
Revision:
0:c52df770855b
DHT11

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhon309 0:c52df770855b 1 /**
jhon309 0:c52df770855b 2 ******************************************************************************
jhon309 0:c52df770855b 3 * @file stm32f0xx_hal_i2s.h
jhon309 0:c52df770855b 4 * @author MCD Application Team
jhon309 0:c52df770855b 5 * @version V1.2.0
jhon309 0:c52df770855b 6 * @date 11-December-2014
jhon309 0:c52df770855b 7 * @brief Header file of I2S HAL module.
jhon309 0:c52df770855b 8 ******************************************************************************
jhon309 0:c52df770855b 9 * @attention
jhon309 0:c52df770855b 10 *
jhon309 0:c52df770855b 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
jhon309 0:c52df770855b 12 *
jhon309 0:c52df770855b 13 * Redistribution and use in source and binary forms, with or without modification,
jhon309 0:c52df770855b 14 * are permitted provided that the following conditions are met:
jhon309 0:c52df770855b 15 * 1. Redistributions of source code must retain the above copyright notice,
jhon309 0:c52df770855b 16 * this list of conditions and the following disclaimer.
jhon309 0:c52df770855b 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
jhon309 0:c52df770855b 18 * this list of conditions and the following disclaimer in the documentation
jhon309 0:c52df770855b 19 * and/or other materials provided with the distribution.
jhon309 0:c52df770855b 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
jhon309 0:c52df770855b 21 * may be used to endorse or promote products derived from this software
jhon309 0:c52df770855b 22 * without specific prior written permission.
jhon309 0:c52df770855b 23 *
jhon309 0:c52df770855b 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
jhon309 0:c52df770855b 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
jhon309 0:c52df770855b 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jhon309 0:c52df770855b 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
jhon309 0:c52df770855b 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
jhon309 0:c52df770855b 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
jhon309 0:c52df770855b 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
jhon309 0:c52df770855b 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jhon309 0:c52df770855b 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
jhon309 0:c52df770855b 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jhon309 0:c52df770855b 34 *
jhon309 0:c52df770855b 35 ******************************************************************************
jhon309 0:c52df770855b 36 */
jhon309 0:c52df770855b 37
jhon309 0:c52df770855b 38 /* Define to prevent recursive inclusion -------------------------------------*/
jhon309 0:c52df770855b 39 #ifndef __STM32F0xx_HAL_I2S_H
jhon309 0:c52df770855b 40 #define __STM32F0xx_HAL_I2S_H
jhon309 0:c52df770855b 41
jhon309 0:c52df770855b 42 #ifdef __cplusplus
jhon309 0:c52df770855b 43 extern "C" {
jhon309 0:c52df770855b 44 #endif
jhon309 0:c52df770855b 45
jhon309 0:c52df770855b 46 #if defined(STM32F031x6) || defined(STM32F038xx) || \
jhon309 0:c52df770855b 47 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:c52df770855b 48 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:c52df770855b 49 defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:c52df770855b 50 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:c52df770855b 51
jhon309 0:c52df770855b 52 /* Includes ------------------------------------------------------------------*/
jhon309 0:c52df770855b 53 #include "stm32f0xx_hal_def.h"
jhon309 0:c52df770855b 54
jhon309 0:c52df770855b 55 /** @addtogroup STM32F0xx_HAL_Driver
jhon309 0:c52df770855b 56 * @{
jhon309 0:c52df770855b 57 */
jhon309 0:c52df770855b 58
jhon309 0:c52df770855b 59 /** @addtogroup I2S
jhon309 0:c52df770855b 60 * @{
jhon309 0:c52df770855b 61 */
jhon309 0:c52df770855b 62
jhon309 0:c52df770855b 63 /* Exported types ------------------------------------------------------------*/
jhon309 0:c52df770855b 64 /** @defgroup I2S_Exported_Types I2S Exported Types
jhon309 0:c52df770855b 65 * @{
jhon309 0:c52df770855b 66 */
jhon309 0:c52df770855b 67
jhon309 0:c52df770855b 68 /**
jhon309 0:c52df770855b 69 * @brief I2S Init structure definition
jhon309 0:c52df770855b 70 */
jhon309 0:c52df770855b 71 typedef struct
jhon309 0:c52df770855b 72 {
jhon309 0:c52df770855b 73 uint32_t Mode; /*!< Specifies the I2S operating mode.
jhon309 0:c52df770855b 74 This parameter can be a value of @ref I2S_Mode */
jhon309 0:c52df770855b 75
jhon309 0:c52df770855b 76 uint32_t Standard; /*!< Specifies the standard used for the I2S communication.
jhon309 0:c52df770855b 77 This parameter can be a value of @ref I2S_Standard */
jhon309 0:c52df770855b 78
jhon309 0:c52df770855b 79 uint32_t DataFormat; /*!< Specifies the data format for the I2S communication.
jhon309 0:c52df770855b 80 This parameter can be a value of @ref I2S_Data_Format */
jhon309 0:c52df770855b 81
jhon309 0:c52df770855b 82 uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
jhon309 0:c52df770855b 83 This parameter can be a value of @ref I2S_MCLK_Output */
jhon309 0:c52df770855b 84
jhon309 0:c52df770855b 85 uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
jhon309 0:c52df770855b 86 This parameter can be a value of @ref I2S_Audio_Frequency */
jhon309 0:c52df770855b 87
jhon309 0:c52df770855b 88 uint32_t CPOL; /*!< Specifies the idle state of the I2S clock.
jhon309 0:c52df770855b 89 This parameter can be a value of @ref I2S_Clock_Polarity */
jhon309 0:c52df770855b 90 }I2S_InitTypeDef;
jhon309 0:c52df770855b 91
jhon309 0:c52df770855b 92 /**
jhon309 0:c52df770855b 93 * @brief HAL State structures definition
jhon309 0:c52df770855b 94 */
jhon309 0:c52df770855b 95 typedef enum
jhon309 0:c52df770855b 96 {
jhon309 0:c52df770855b 97 HAL_I2S_STATE_RESET = 0x00, /*!< I2S not yet initialized or disabled */
jhon309 0:c52df770855b 98 HAL_I2S_STATE_READY = 0x01, /*!< I2S initialized and ready for use */
jhon309 0:c52df770855b 99 HAL_I2S_STATE_BUSY = 0x02, /*!< I2S internal process is ongoing */
jhon309 0:c52df770855b 100 HAL_I2S_STATE_BUSY_TX = 0x03, /*!< Data Transmission process is ongoing */
jhon309 0:c52df770855b 101 HAL_I2S_STATE_BUSY_RX = 0x04, /*!< Data Reception process is ongoing */
jhon309 0:c52df770855b 102 HAL_I2S_STATE_PAUSE = 0x06, /*!< I2S pause state: used in case of DMA */
jhon309 0:c52df770855b 103 HAL_I2S_STATE_ERROR = 0x07 /*!< I2S error state */
jhon309 0:c52df770855b 104 }HAL_I2S_StateTypeDef;
jhon309 0:c52df770855b 105
jhon309 0:c52df770855b 106 /**
jhon309 0:c52df770855b 107 * @brief I2S handle Structure definition
jhon309 0:c52df770855b 108 */
jhon309 0:c52df770855b 109 typedef struct
jhon309 0:c52df770855b 110 {
jhon309 0:c52df770855b 111 SPI_TypeDef *Instance; /*!< I2S registers base address */
jhon309 0:c52df770855b 112
jhon309 0:c52df770855b 113 I2S_InitTypeDef Init; /*!< I2S communication parameters */
jhon309 0:c52df770855b 114
jhon309 0:c52df770855b 115 uint16_t *pTxBuffPtr; /*!< Pointer to I2S Tx transfer buffer */
jhon309 0:c52df770855b 116
jhon309 0:c52df770855b 117 __IO uint16_t TxXferSize; /*!< I2S Tx transfer size */
jhon309 0:c52df770855b 118
jhon309 0:c52df770855b 119 __IO uint16_t TxXferCount; /*!< I2S Tx transfer Counter */
jhon309 0:c52df770855b 120
jhon309 0:c52df770855b 121 uint16_t *pRxBuffPtr; /*!< Pointer to I2S Rx transfer buffer */
jhon309 0:c52df770855b 122
jhon309 0:c52df770855b 123 __IO uint16_t RxXferSize; /*!< I2S Rx transfer size */
jhon309 0:c52df770855b 124
jhon309 0:c52df770855b 125 __IO uint16_t RxXferCount; /*!< I2S Rx transfer counter
jhon309 0:c52df770855b 126 (This field is initialized at the
jhon309 0:c52df770855b 127 same value as transfer size at the
jhon309 0:c52df770855b 128 beginning of the transfer and
jhon309 0:c52df770855b 129 decremented when a sample is received.
jhon309 0:c52df770855b 130 NbSamplesReceived = RxBufferSize-RxBufferCount) */
jhon309 0:c52df770855b 131
jhon309 0:c52df770855b 132 DMA_HandleTypeDef *hdmatx; /*!< I2S Tx DMA handle parameters */
jhon309 0:c52df770855b 133
jhon309 0:c52df770855b 134 DMA_HandleTypeDef *hdmarx; /*!< I2S Rx DMA handle parameters */
jhon309 0:c52df770855b 135
jhon309 0:c52df770855b 136 __IO HAL_LockTypeDef Lock; /*!< I2S locking object */
jhon309 0:c52df770855b 137
jhon309 0:c52df770855b 138 __IO HAL_I2S_StateTypeDef State; /*!< I2S communication state */
jhon309 0:c52df770855b 139
jhon309 0:c52df770855b 140 __IO uint32_t ErrorCode; /*!< I2S Error code
jhon309 0:c52df770855b 141 This parameter can be a value of @ref I2S_Error */
jhon309 0:c52df770855b 142
jhon309 0:c52df770855b 143 }I2S_HandleTypeDef;
jhon309 0:c52df770855b 144 /**
jhon309 0:c52df770855b 145 * @}
jhon309 0:c52df770855b 146 */
jhon309 0:c52df770855b 147
jhon309 0:c52df770855b 148 /* Exported constants --------------------------------------------------------*/
jhon309 0:c52df770855b 149 /** @defgroup I2S_Exported_Constants I2S Exported Constants
jhon309 0:c52df770855b 150 * @{
jhon309 0:c52df770855b 151 */
jhon309 0:c52df770855b 152 /** @defgroup I2S_Error I2S Error
jhon309 0:c52df770855b 153 * @{
jhon309 0:c52df770855b 154 */
jhon309 0:c52df770855b 155 #define HAL_I2S_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
jhon309 0:c52df770855b 156 #define HAL_I2S_ERROR_TIMEOUT ((uint32_t)0x00000001) /*!< Timeout error */
jhon309 0:c52df770855b 157 #define HAL_I2S_ERROR_OVR ((uint32_t)0x00000002) /*!< OVR error */
jhon309 0:c52df770855b 158 #define HAL_I2S_ERROR_UDR ((uint32_t)0x00000004) /*!< UDR error */
jhon309 0:c52df770855b 159 #define HAL_I2S_ERROR_DMA ((uint32_t)0x00000008) /*!< DMA transfer error */
jhon309 0:c52df770855b 160 #define HAL_I2S_ERROR_UNKNOW ((uint32_t)0x00000010) /*!< Unknow Error error */
jhon309 0:c52df770855b 161 /**
jhon309 0:c52df770855b 162 * @}
jhon309 0:c52df770855b 163 */
jhon309 0:c52df770855b 164
jhon309 0:c52df770855b 165 /** @defgroup I2S_Mode I2S Mode
jhon309 0:c52df770855b 166 * @{
jhon309 0:c52df770855b 167 */
jhon309 0:c52df770855b 168 #define I2S_MODE_SLAVE_TX ((uint32_t)0x00000000)
jhon309 0:c52df770855b 169 #define I2S_MODE_SLAVE_RX ((uint32_t)0x00000100)
jhon309 0:c52df770855b 170 #define I2S_MODE_MASTER_TX ((uint32_t)0x00000200)
jhon309 0:c52df770855b 171 #define I2S_MODE_MASTER_RX ((uint32_t)0x00000300)
jhon309 0:c52df770855b 172
jhon309 0:c52df770855b 173 #define IS_I2S_MODE(MODE) (((MODE) == I2S_MODE_SLAVE_TX) || \
jhon309 0:c52df770855b 174 ((MODE) == I2S_MODE_SLAVE_RX) || \
jhon309 0:c52df770855b 175 ((MODE) == I2S_MODE_MASTER_TX)|| \
jhon309 0:c52df770855b 176 ((MODE) == I2S_MODE_MASTER_RX))
jhon309 0:c52df770855b 177 /**
jhon309 0:c52df770855b 178 * @}
jhon309 0:c52df770855b 179 */
jhon309 0:c52df770855b 180
jhon309 0:c52df770855b 181 /** @defgroup I2S_Standard I2S Standard
jhon309 0:c52df770855b 182 * @{
jhon309 0:c52df770855b 183 */
jhon309 0:c52df770855b 184 #define I2S_STANDARD_PHILIPS ((uint32_t)0x00000000)
jhon309 0:c52df770855b 185 #define I2S_STANDARD_MSB ((uint32_t)0x00000010)
jhon309 0:c52df770855b 186 #define I2S_STANDARD_LSB ((uint32_t)0x00000020)
jhon309 0:c52df770855b 187 #define I2S_STANDARD_PCM_SHORT ((uint32_t)0x00000030)
jhon309 0:c52df770855b 188 #define I2S_STANDARD_PCM_LONG ((uint32_t)0x000000B0)
jhon309 0:c52df770855b 189
jhon309 0:c52df770855b 190 #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_STANDARD_PHILIPS) || \
jhon309 0:c52df770855b 191 ((STANDARD) == I2S_STANDARD_MSB) || \
jhon309 0:c52df770855b 192 ((STANDARD) == I2S_STANDARD_LSB) || \
jhon309 0:c52df770855b 193 ((STANDARD) == I2S_STANDARD_PCM_SHORT) || \
jhon309 0:c52df770855b 194 ((STANDARD) == I2S_STANDARD_PCM_LONG))
jhon309 0:c52df770855b 195 /**
jhon309 0:c52df770855b 196 * @}
jhon309 0:c52df770855b 197 */
jhon309 0:c52df770855b 198
jhon309 0:c52df770855b 199 /** @defgroup I2S_Data_Format I2S Data Format
jhon309 0:c52df770855b 200 * @{
jhon309 0:c52df770855b 201 */
jhon309 0:c52df770855b 202 #define I2S_DATAFORMAT_16B ((uint32_t)0x00000000)
jhon309 0:c52df770855b 203 #define I2S_DATAFORMAT_16B_EXTENDED ((uint32_t)0x00000001)
jhon309 0:c52df770855b 204 #define I2S_DATAFORMAT_24B ((uint32_t)0x00000003)
jhon309 0:c52df770855b 205 #define I2S_DATAFORMAT_32B ((uint32_t)0x00000005)
jhon309 0:c52df770855b 206
jhon309 0:c52df770855b 207 #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DATAFORMAT_16B) || \
jhon309 0:c52df770855b 208 ((FORMAT) == I2S_DATAFORMAT_16B_EXTENDED) || \
jhon309 0:c52df770855b 209 ((FORMAT) == I2S_DATAFORMAT_24B) || \
jhon309 0:c52df770855b 210 ((FORMAT) == I2S_DATAFORMAT_32B))
jhon309 0:c52df770855b 211 /**
jhon309 0:c52df770855b 212 * @}
jhon309 0:c52df770855b 213 */
jhon309 0:c52df770855b 214
jhon309 0:c52df770855b 215 /** @defgroup I2S_MCLK_Output I2S MCLK Output
jhon309 0:c52df770855b 216 * @{
jhon309 0:c52df770855b 217 */
jhon309 0:c52df770855b 218 #define I2S_MCLKOUTPUT_ENABLE ((uint32_t)SPI_I2SPR_MCKOE)
jhon309 0:c52df770855b 219 #define I2S_MCLKOUTPUT_DISABLE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 220
jhon309 0:c52df770855b 221 #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOUTPUT_ENABLE) || \
jhon309 0:c52df770855b 222 ((OUTPUT) == I2S_MCLKOUTPUT_DISABLE))
jhon309 0:c52df770855b 223 /**
jhon309 0:c52df770855b 224 * @}
jhon309 0:c52df770855b 225 */
jhon309 0:c52df770855b 226
jhon309 0:c52df770855b 227 /** @defgroup I2S_Audio_Frequency I2S Audio Frequency
jhon309 0:c52df770855b 228 * @{
jhon309 0:c52df770855b 229 */
jhon309 0:c52df770855b 230 #define I2S_AUDIOFREQ_192K ((uint32_t)192000)
jhon309 0:c52df770855b 231 #define I2S_AUDIOFREQ_96K ((uint32_t)96000)
jhon309 0:c52df770855b 232 #define I2S_AUDIOFREQ_48K ((uint32_t)48000)
jhon309 0:c52df770855b 233 #define I2S_AUDIOFREQ_44K ((uint32_t)44100)
jhon309 0:c52df770855b 234 #define I2S_AUDIOFREQ_32K ((uint32_t)32000)
jhon309 0:c52df770855b 235 #define I2S_AUDIOFREQ_22K ((uint32_t)22050)
jhon309 0:c52df770855b 236 #define I2S_AUDIOFREQ_16K ((uint32_t)16000)
jhon309 0:c52df770855b 237 #define I2S_AUDIOFREQ_11K ((uint32_t)11025)
jhon309 0:c52df770855b 238 #define I2S_AUDIOFREQ_8K ((uint32_t)8000)
jhon309 0:c52df770855b 239 #define I2S_AUDIOFREQ_DEFAULT ((uint32_t)2)
jhon309 0:c52df770855b 240
jhon309 0:c52df770855b 241 #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AUDIOFREQ_8K) && \
jhon309 0:c52df770855b 242 ((FREQ) <= I2S_AUDIOFREQ_192K)) || \
jhon309 0:c52df770855b 243 ((FREQ) == I2S_AUDIOFREQ_DEFAULT))
jhon309 0:c52df770855b 244 /**
jhon309 0:c52df770855b 245 * @}
jhon309 0:c52df770855b 246 */
jhon309 0:c52df770855b 247
jhon309 0:c52df770855b 248 /** @defgroup I2S_Clock_Polarity I2S Clock Polarity
jhon309 0:c52df770855b 249 * @{
jhon309 0:c52df770855b 250 */
jhon309 0:c52df770855b 251 #define I2S_CPOL_LOW ((uint32_t)0x00000000)
jhon309 0:c52df770855b 252 #define I2S_CPOL_HIGH ((uint32_t)SPI_I2SCFGR_CKPOL)
jhon309 0:c52df770855b 253
jhon309 0:c52df770855b 254 #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_LOW) || \
jhon309 0:c52df770855b 255 ((CPOL) == I2S_CPOL_HIGH))
jhon309 0:c52df770855b 256 /**
jhon309 0:c52df770855b 257 * @}
jhon309 0:c52df770855b 258 */
jhon309 0:c52df770855b 259
jhon309 0:c52df770855b 260 /** @defgroup I2S_Interrupt_configuration_definition I2S Interrupt configuration definition
jhon309 0:c52df770855b 261 * @{
jhon309 0:c52df770855b 262 */
jhon309 0:c52df770855b 263 #define I2S_IT_TXE SPI_CR2_TXEIE
jhon309 0:c52df770855b 264 #define I2S_IT_RXNE SPI_CR2_RXNEIE
jhon309 0:c52df770855b 265 #define I2S_IT_ERR SPI_CR2_ERRIE
jhon309 0:c52df770855b 266 /**
jhon309 0:c52df770855b 267 * @}
jhon309 0:c52df770855b 268 */
jhon309 0:c52df770855b 269
jhon309 0:c52df770855b 270 /** @defgroup I2S_Flag_definition I2S Flag definition
jhon309 0:c52df770855b 271 * @{
jhon309 0:c52df770855b 272 */
jhon309 0:c52df770855b 273 #define I2S_FLAG_TXE SPI_SR_TXE
jhon309 0:c52df770855b 274 #define I2S_FLAG_RXNE SPI_SR_RXNE
jhon309 0:c52df770855b 275
jhon309 0:c52df770855b 276 #define I2S_FLAG_UDR SPI_SR_UDR
jhon309 0:c52df770855b 277 #define I2S_FLAG_OVR SPI_SR_OVR
jhon309 0:c52df770855b 278 #define I2S_FLAG_FRE SPI_SR_FRE
jhon309 0:c52df770855b 279
jhon309 0:c52df770855b 280 #define I2S_FLAG_CHSIDE SPI_SR_CHSIDE
jhon309 0:c52df770855b 281 #define I2S_FLAG_BSY SPI_SR_BSY
jhon309 0:c52df770855b 282 /**
jhon309 0:c52df770855b 283 * @}
jhon309 0:c52df770855b 284 */
jhon309 0:c52df770855b 285
jhon309 0:c52df770855b 286 /**
jhon309 0:c52df770855b 287 * @}
jhon309 0:c52df770855b 288 */
jhon309 0:c52df770855b 289
jhon309 0:c52df770855b 290 /* Exported macros -----------------------------------------------------------*/
jhon309 0:c52df770855b 291 /** @defgroup I2S_Exported_macros I2S Exported Macros
jhon309 0:c52df770855b 292 * @{
jhon309 0:c52df770855b 293 */
jhon309 0:c52df770855b 294
jhon309 0:c52df770855b 295 /** @brief Reset I2S handle state
jhon309 0:c52df770855b 296 * @param __HANDLE__: I2S handle.
jhon309 0:c52df770855b 297 * @retval None
jhon309 0:c52df770855b 298 */
jhon309 0:c52df770855b 299 #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET)
jhon309 0:c52df770855b 300
jhon309 0:c52df770855b 301 /** @brief Enable or disable the specified SPI peripheral (in I2S mode).
jhon309 0:c52df770855b 302 * @param __HANDLE__: specifies the I2S Handle.
jhon309 0:c52df770855b 303 * @retval None
jhon309 0:c52df770855b 304 */
jhon309 0:c52df770855b 305 #define __HAL_I2S_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR |= SPI_I2SCFGR_I2SE)
jhon309 0:c52df770855b 306 #define __HAL_I2S_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR &= (uint16_t)(~SPI_I2SCFGR_I2SE))
jhon309 0:c52df770855b 307
jhon309 0:c52df770855b 308 /** @brief Enable or disable the specified I2S interrupts.
jhon309 0:c52df770855b 309 * @param __HANDLE__: specifies the I2S Handle.
jhon309 0:c52df770855b 310 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
jhon309 0:c52df770855b 311 * This parameter can be one of the following values:
jhon309 0:c52df770855b 312 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
jhon309 0:c52df770855b 313 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
jhon309 0:c52df770855b 314 * @arg I2S_IT_ERR: Error interrupt enable
jhon309 0:c52df770855b 315 * @retval None
jhon309 0:c52df770855b 316 */
jhon309 0:c52df770855b 317 #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
jhon309 0:c52df770855b 318 #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (uint16_t)(~(__INTERRUPT__)))
jhon309 0:c52df770855b 319
jhon309 0:c52df770855b 320 /** @brief Checks if the specified I2S interrupt source is enabled or disabled.
jhon309 0:c52df770855b 321 * @param __HANDLE__: specifies the I2S Handle.
jhon309 0:c52df770855b 322 * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
jhon309 0:c52df770855b 323 * @param __INTERRUPT__: specifies the I2S interrupt source to check.
jhon309 0:c52df770855b 324 * This parameter can be one of the following values:
jhon309 0:c52df770855b 325 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
jhon309 0:c52df770855b 326 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
jhon309 0:c52df770855b 327 * @arg I2S_IT_ERR: Error interrupt enable
jhon309 0:c52df770855b 328 * @retval The new state of __IT__ (TRUE or FALSE).
jhon309 0:c52df770855b 329 */
jhon309 0:c52df770855b 330 #define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
jhon309 0:c52df770855b 331
jhon309 0:c52df770855b 332 /** @brief Checks whether the specified I2S flag is set or not.
jhon309 0:c52df770855b 333 * @param __HANDLE__: specifies the I2S Handle.
jhon309 0:c52df770855b 334 * @param __FLAG__: specifies the flag to check.
jhon309 0:c52df770855b 335 * This parameter can be one of the following values:
jhon309 0:c52df770855b 336 * @arg I2S_FLAG_RXNE: Receive buffer not empty flag
jhon309 0:c52df770855b 337 * @arg I2S_FLAG_TXE: Transmit buffer empty flag
jhon309 0:c52df770855b 338 * @arg I2S_FLAG_UDR: Underrun flag
jhon309 0:c52df770855b 339 * @arg I2S_FLAG_OVR: Overrun flag
jhon309 0:c52df770855b 340 * @arg I2S_FLAG_FRE: Frame error flag
jhon309 0:c52df770855b 341 * @arg I2S_FLAG_CHSIDE: Channel Side flag
jhon309 0:c52df770855b 342 * @arg I2S_FLAG_BSY: Busy flag
jhon309 0:c52df770855b 343 * @retval The new state of __FLAG__ (TRUE or FALSE).
jhon309 0:c52df770855b 344 */
jhon309 0:c52df770855b 345 #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
jhon309 0:c52df770855b 346
jhon309 0:c52df770855b 347 /** @brief Clears the I2S OVR pending flag.
jhon309 0:c52df770855b 348 * @param __HANDLE__: specifies the I2S Handle.
jhon309 0:c52df770855b 349 * @retval None
jhon309 0:c52df770855b 350 */
jhon309 0:c52df770855b 351 #define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) do{ \
jhon309 0:c52df770855b 352 __IO uint32_t tmpreg; \
jhon309 0:c52df770855b 353 tmpreg = (__HANDLE__)->Instance->DR; \
jhon309 0:c52df770855b 354 tmpreg = (__HANDLE__)->Instance->SR; \
jhon309 0:c52df770855b 355 UNUSED(tmpreg); \
jhon309 0:c52df770855b 356 }while(0)
jhon309 0:c52df770855b 357 /** @brief Clears the I2S UDR pending flag.
jhon309 0:c52df770855b 358 * @param __HANDLE__: specifies the I2S Handle.
jhon309 0:c52df770855b 359 * @retval None
jhon309 0:c52df770855b 360 */
jhon309 0:c52df770855b 361 #define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__) do{\
jhon309 0:c52df770855b 362 __IO uint32_t tmpreg;\
jhon309 0:c52df770855b 363 tmpreg = ((__HANDLE__)->Instance->SR);\
jhon309 0:c52df770855b 364 UNUSED(tmpreg); \
jhon309 0:c52df770855b 365 }while(0)
jhon309 0:c52df770855b 366 /**
jhon309 0:c52df770855b 367 * @}
jhon309 0:c52df770855b 368 */
jhon309 0:c52df770855b 369
jhon309 0:c52df770855b 370 /* Exported functions --------------------------------------------------------*/
jhon309 0:c52df770855b 371 /** @addtogroup I2S_Exported_Functions
jhon309 0:c52df770855b 372 * @{
jhon309 0:c52df770855b 373 */
jhon309 0:c52df770855b 374
jhon309 0:c52df770855b 375 /** @addtogroup I2S_Exported_Functions_Group1
jhon309 0:c52df770855b 376 * @{
jhon309 0:c52df770855b 377 */
jhon309 0:c52df770855b 378 /* Initialization/de-initialization functions **********************************/
jhon309 0:c52df770855b 379 HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 380 HAL_StatusTypeDef HAL_I2S_DeInit (I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 381 void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 382 void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 383 /**
jhon309 0:c52df770855b 384 * @}
jhon309 0:c52df770855b 385 */
jhon309 0:c52df770855b 386
jhon309 0:c52df770855b 387 /** @addtogroup I2S_Exported_Functions_Group2
jhon309 0:c52df770855b 388 * @{
jhon309 0:c52df770855b 389 */
jhon309 0:c52df770855b 390 /* I/O operation functions ***************************************************/
jhon309 0:c52df770855b 391 /* Blocking mode: Polling */
jhon309 0:c52df770855b 392 HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
jhon309 0:c52df770855b 393 HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
jhon309 0:c52df770855b 394
jhon309 0:c52df770855b 395 /* Non-Blocking mode: Interrupt */
jhon309 0:c52df770855b 396 HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
jhon309 0:c52df770855b 397 HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
jhon309 0:c52df770855b 398 void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 399
jhon309 0:c52df770855b 400 /* Non-Blocking mode: DMA */
jhon309 0:c52df770855b 401 HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
jhon309 0:c52df770855b 402 HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
jhon309 0:c52df770855b 403
jhon309 0:c52df770855b 404 HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 405 HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 406 HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 407
jhon309 0:c52df770855b 408 /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/
jhon309 0:c52df770855b 409 void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 410 void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 411 void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 412 void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 413 void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 414 /**
jhon309 0:c52df770855b 415 * @}
jhon309 0:c52df770855b 416 */
jhon309 0:c52df770855b 417
jhon309 0:c52df770855b 418 /** @addtogroup I2S_Exported_Functions_Group3
jhon309 0:c52df770855b 419 * @{
jhon309 0:c52df770855b 420 */
jhon309 0:c52df770855b 421 /* Peripheral Control and State functions ************************************/
jhon309 0:c52df770855b 422 HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 423 uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s);
jhon309 0:c52df770855b 424 /**
jhon309 0:c52df770855b 425 * @}
jhon309 0:c52df770855b 426 */
jhon309 0:c52df770855b 427
jhon309 0:c52df770855b 428 /**
jhon309 0:c52df770855b 429 * @}
jhon309 0:c52df770855b 430 */
jhon309 0:c52df770855b 431
jhon309 0:c52df770855b 432
jhon309 0:c52df770855b 433 /**
jhon309 0:c52df770855b 434 * @}
jhon309 0:c52df770855b 435 */
jhon309 0:c52df770855b 436
jhon309 0:c52df770855b 437 /**
jhon309 0:c52df770855b 438 * @}
jhon309 0:c52df770855b 439 */
jhon309 0:c52df770855b 440 #endif /* defined(STM32F031x6) || defined(STM32F038xx) || */
jhon309 0:c52df770855b 441 /* defined(STM32F051x8) || defined(STM32F058xx) || */
jhon309 0:c52df770855b 442 /* defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) ||*/
jhon309 0:c52df770855b 443 /* defined(STM32F042x6) || defined(STM32F048xx) || */
jhon309 0:c52df770855b 444 /* defined(STM32F091xC) || defined(STM32F098xx) */
jhon309 0:c52df770855b 445
jhon309 0:c52df770855b 446 #ifdef __cplusplus
jhon309 0:c52df770855b 447 }
jhon309 0:c52df770855b 448 #endif
jhon309 0:c52df770855b 449
jhon309 0:c52df770855b 450
jhon309 0:c52df770855b 451 #endif /* __STM32F0xx_HAL_I2S_H */
jhon309 0:c52df770855b 452
jhon309 0:c52df770855b 453 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/