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