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