mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Jan 27 14:30:07 2014 +0000
Revision:
76:aeb1df146756
Child:
80:66393a7b209d
Synchronized with git revision a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd

Full URL: https://github.com/mbedmicro/mbed/commit/a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd/

Add NUCLEO_L152RE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 76:aeb1df146756 1 /**
mbed_official 76:aeb1df146756 2 ******************************************************************************
mbed_official 76:aeb1df146756 3 * @file stm32l1xx_spi.h
mbed_official 76:aeb1df146756 4 * @author MCD Application Team
mbed_official 76:aeb1df146756 5 * @version V1.2.0
mbed_official 76:aeb1df146756 6 * @date 22-February-2013
mbed_official 76:aeb1df146756 7 * @brief This file contains all the functions prototypes for the SPI
mbed_official 76:aeb1df146756 8 * firmware library.
mbed_official 76:aeb1df146756 9 ******************************************************************************
mbed_official 76:aeb1df146756 10 * @attention
mbed_official 76:aeb1df146756 11 *
mbed_official 76:aeb1df146756 12 * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
mbed_official 76:aeb1df146756 13 *
mbed_official 76:aeb1df146756 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
mbed_official 76:aeb1df146756 15 * You may not use this file except in compliance with the License.
mbed_official 76:aeb1df146756 16 * You may obtain a copy of the License at:
mbed_official 76:aeb1df146756 17 *
mbed_official 76:aeb1df146756 18 * http://www.st.com/software_license_agreement_liberty_v2
mbed_official 76:aeb1df146756 19 *
mbed_official 76:aeb1df146756 20 * Unless required by applicable law or agreed to in writing, software
mbed_official 76:aeb1df146756 21 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 76:aeb1df146756 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 76:aeb1df146756 23 * See the License for the specific language governing permissions and
mbed_official 76:aeb1df146756 24 * limitations under the License.
mbed_official 76:aeb1df146756 25 *
mbed_official 76:aeb1df146756 26 ******************************************************************************
mbed_official 76:aeb1df146756 27 */
mbed_official 76:aeb1df146756 28
mbed_official 76:aeb1df146756 29 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 76:aeb1df146756 30 #ifndef __STM32L1xx_SPI_H
mbed_official 76:aeb1df146756 31 #define __STM32L1xx_SPI_H
mbed_official 76:aeb1df146756 32
mbed_official 76:aeb1df146756 33 #ifdef __cplusplus
mbed_official 76:aeb1df146756 34 extern "C" {
mbed_official 76:aeb1df146756 35 #endif
mbed_official 76:aeb1df146756 36
mbed_official 76:aeb1df146756 37 /* Includes ------------------------------------------------------------------*/
mbed_official 76:aeb1df146756 38 #include "stm32l1xx.h"
mbed_official 76:aeb1df146756 39
mbed_official 76:aeb1df146756 40 /** @addtogroup STM32L1xx_StdPeriph_Driver
mbed_official 76:aeb1df146756 41 * @{
mbed_official 76:aeb1df146756 42 */
mbed_official 76:aeb1df146756 43
mbed_official 76:aeb1df146756 44 /** @addtogroup SPI
mbed_official 76:aeb1df146756 45 * @{
mbed_official 76:aeb1df146756 46 */
mbed_official 76:aeb1df146756 47
mbed_official 76:aeb1df146756 48 /* Exported types ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 49
mbed_official 76:aeb1df146756 50 /**
mbed_official 76:aeb1df146756 51 * @brief SPI Init structure definition
mbed_official 76:aeb1df146756 52 */
mbed_official 76:aeb1df146756 53
mbed_official 76:aeb1df146756 54 typedef struct
mbed_official 76:aeb1df146756 55 {
mbed_official 76:aeb1df146756 56 uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.
mbed_official 76:aeb1df146756 57 This parameter can be a value of @ref SPI_data_direction */
mbed_official 76:aeb1df146756 58
mbed_official 76:aeb1df146756 59 uint16_t SPI_Mode; /*!< Specifies the SPI operating mode.
mbed_official 76:aeb1df146756 60 This parameter can be a value of @ref SPI_mode */
mbed_official 76:aeb1df146756 61
mbed_official 76:aeb1df146756 62 uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
mbed_official 76:aeb1df146756 63 This parameter can be a value of @ref SPI_data_size */
mbed_official 76:aeb1df146756 64
mbed_official 76:aeb1df146756 65 uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
mbed_official 76:aeb1df146756 66 This parameter can be a value of @ref SPI_Clock_Polarity */
mbed_official 76:aeb1df146756 67
mbed_official 76:aeb1df146756 68 uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
mbed_official 76:aeb1df146756 69 This parameter can be a value of @ref SPI_Clock_Phase */
mbed_official 76:aeb1df146756 70
mbed_official 76:aeb1df146756 71 uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
mbed_official 76:aeb1df146756 72 hardware (NSS pin) or by software using the SSI bit.
mbed_official 76:aeb1df146756 73 This parameter can be a value of @ref SPI_Slave_Select_management */
mbed_official 76:aeb1df146756 74
mbed_official 76:aeb1df146756 75 uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
mbed_official 76:aeb1df146756 76 used to configure the transmit and receive SCK clock.
mbed_official 76:aeb1df146756 77 This parameter can be a value of @ref SPI_BaudRate_Prescaler
mbed_official 76:aeb1df146756 78 @note The communication clock is derived from the master
mbed_official 76:aeb1df146756 79 clock. The slave clock does not need to be set. */
mbed_official 76:aeb1df146756 80
mbed_official 76:aeb1df146756 81 uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
mbed_official 76:aeb1df146756 82 This parameter can be a value of @ref SPI_MSB_LSB_transmission */
mbed_official 76:aeb1df146756 83
mbed_official 76:aeb1df146756 84 uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
mbed_official 76:aeb1df146756 85 }SPI_InitTypeDef;
mbed_official 76:aeb1df146756 86
mbed_official 76:aeb1df146756 87 /**
mbed_official 76:aeb1df146756 88 * @brief I2S Init structure definition
mbed_official 76:aeb1df146756 89 */
mbed_official 76:aeb1df146756 90
mbed_official 76:aeb1df146756 91 typedef struct
mbed_official 76:aeb1df146756 92 {
mbed_official 76:aeb1df146756 93
mbed_official 76:aeb1df146756 94 uint16_t I2S_Mode; /*!< Specifies the I2S operating mode.
mbed_official 76:aeb1df146756 95 This parameter can be a value of @ref SPI_I2S_Mode */
mbed_official 76:aeb1df146756 96
mbed_official 76:aeb1df146756 97 uint16_t I2S_Standard; /*!< Specifies the standard used for the I2S communication.
mbed_official 76:aeb1df146756 98 This parameter can be a value of @ref SPI_I2S_Standard */
mbed_official 76:aeb1df146756 99
mbed_official 76:aeb1df146756 100 uint16_t I2S_DataFormat; /*!< Specifies the data format for the I2S communication.
mbed_official 76:aeb1df146756 101 This parameter can be a value of @ref SPI_I2S_Data_Format */
mbed_official 76:aeb1df146756 102
mbed_official 76:aeb1df146756 103 uint16_t I2S_MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
mbed_official 76:aeb1df146756 104 This parameter can be a value of @ref SPI_I2S_MCLK_Output */
mbed_official 76:aeb1df146756 105
mbed_official 76:aeb1df146756 106 uint32_t I2S_AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
mbed_official 76:aeb1df146756 107 This parameter can be a value of @ref SPI_I2S_Audio_Frequency */
mbed_official 76:aeb1df146756 108
mbed_official 76:aeb1df146756 109 uint16_t I2S_CPOL; /*!< Specifies the idle state of the I2S clock.
mbed_official 76:aeb1df146756 110 This parameter can be a value of @ref SPI_I2S_Clock_Polarity */
mbed_official 76:aeb1df146756 111 }I2S_InitTypeDef;
mbed_official 76:aeb1df146756 112
mbed_official 76:aeb1df146756 113 /* Exported constants --------------------------------------------------------*/
mbed_official 76:aeb1df146756 114
mbed_official 76:aeb1df146756 115 /** @defgroup SPI_Exported_Constants
mbed_official 76:aeb1df146756 116 * @{
mbed_official 76:aeb1df146756 117 */
mbed_official 76:aeb1df146756 118
mbed_official 76:aeb1df146756 119 #define IS_SPI_ALL_PERIPH(PERIPH) (((PERIPH) == SPI1) || \
mbed_official 76:aeb1df146756 120 ((PERIPH) == SPI2) || \
mbed_official 76:aeb1df146756 121 ((PERIPH) == SPI3))
mbed_official 76:aeb1df146756 122 #define IS_SPI_23_PERIPH(PERIPH) (((PERIPH) == SPI2) || \
mbed_official 76:aeb1df146756 123 ((PERIPH) == SPI3))
mbed_official 76:aeb1df146756 124
mbed_official 76:aeb1df146756 125 /** @defgroup SPI_data_direction
mbed_official 76:aeb1df146756 126 * @{
mbed_official 76:aeb1df146756 127 */
mbed_official 76:aeb1df146756 128
mbed_official 76:aeb1df146756 129 #define SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 130 #define SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400)
mbed_official 76:aeb1df146756 131 #define SPI_Direction_1Line_Rx ((uint16_t)0x8000)
mbed_official 76:aeb1df146756 132 #define SPI_Direction_1Line_Tx ((uint16_t)0xC000)
mbed_official 76:aeb1df146756 133 #define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_Direction_2Lines_FullDuplex) || \
mbed_official 76:aeb1df146756 134 ((MODE) == SPI_Direction_2Lines_RxOnly) || \
mbed_official 76:aeb1df146756 135 ((MODE) == SPI_Direction_1Line_Rx) || \
mbed_official 76:aeb1df146756 136 ((MODE) == SPI_Direction_1Line_Tx))
mbed_official 76:aeb1df146756 137 /**
mbed_official 76:aeb1df146756 138 * @}
mbed_official 76:aeb1df146756 139 */
mbed_official 76:aeb1df146756 140
mbed_official 76:aeb1df146756 141 /** @defgroup SPI_mode
mbed_official 76:aeb1df146756 142 * @{
mbed_official 76:aeb1df146756 143 */
mbed_official 76:aeb1df146756 144
mbed_official 76:aeb1df146756 145 #define SPI_Mode_Master ((uint16_t)0x0104)
mbed_official 76:aeb1df146756 146 #define SPI_Mode_Slave ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 147 #define IS_SPI_MODE(MODE) (((MODE) == SPI_Mode_Master) || \
mbed_official 76:aeb1df146756 148 ((MODE) == SPI_Mode_Slave))
mbed_official 76:aeb1df146756 149 /**
mbed_official 76:aeb1df146756 150 * @}
mbed_official 76:aeb1df146756 151 */
mbed_official 76:aeb1df146756 152
mbed_official 76:aeb1df146756 153 /** @defgroup SPI_data_size
mbed_official 76:aeb1df146756 154 * @{
mbed_official 76:aeb1df146756 155 */
mbed_official 76:aeb1df146756 156
mbed_official 76:aeb1df146756 157 #define SPI_DataSize_16b ((uint16_t)0x0800)
mbed_official 76:aeb1df146756 158 #define SPI_DataSize_8b ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 159 #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DataSize_16b) || \
mbed_official 76:aeb1df146756 160 ((DATASIZE) == SPI_DataSize_8b))
mbed_official 76:aeb1df146756 161 /**
mbed_official 76:aeb1df146756 162 * @}
mbed_official 76:aeb1df146756 163 */
mbed_official 76:aeb1df146756 164
mbed_official 76:aeb1df146756 165 /** @defgroup SPI_Clock_Polarity
mbed_official 76:aeb1df146756 166 * @{
mbed_official 76:aeb1df146756 167 */
mbed_official 76:aeb1df146756 168
mbed_official 76:aeb1df146756 169 #define SPI_CPOL_Low ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 170 #define SPI_CPOL_High ((uint16_t)0x0002)
mbed_official 76:aeb1df146756 171 #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_CPOL_Low) || \
mbed_official 76:aeb1df146756 172 ((CPOL) == SPI_CPOL_High))
mbed_official 76:aeb1df146756 173 /**
mbed_official 76:aeb1df146756 174 * @}
mbed_official 76:aeb1df146756 175 */
mbed_official 76:aeb1df146756 176
mbed_official 76:aeb1df146756 177 /** @defgroup SPI_Clock_Phase
mbed_official 76:aeb1df146756 178 * @{
mbed_official 76:aeb1df146756 179 */
mbed_official 76:aeb1df146756 180
mbed_official 76:aeb1df146756 181 #define SPI_CPHA_1Edge ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 182 #define SPI_CPHA_2Edge ((uint16_t)0x0001)
mbed_official 76:aeb1df146756 183 #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_CPHA_1Edge) || \
mbed_official 76:aeb1df146756 184 ((CPHA) == SPI_CPHA_2Edge))
mbed_official 76:aeb1df146756 185 /**
mbed_official 76:aeb1df146756 186 * @}
mbed_official 76:aeb1df146756 187 */
mbed_official 76:aeb1df146756 188
mbed_official 76:aeb1df146756 189 /** @defgroup SPI_Slave_Select_management
mbed_official 76:aeb1df146756 190 * @{
mbed_official 76:aeb1df146756 191 */
mbed_official 76:aeb1df146756 192
mbed_official 76:aeb1df146756 193 #define SPI_NSS_Soft ((uint16_t)0x0200)
mbed_official 76:aeb1df146756 194 #define SPI_NSS_Hard ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 195 #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_Soft) || \
mbed_official 76:aeb1df146756 196 ((NSS) == SPI_NSS_Hard))
mbed_official 76:aeb1df146756 197 /**
mbed_official 76:aeb1df146756 198 * @}
mbed_official 76:aeb1df146756 199 */
mbed_official 76:aeb1df146756 200
mbed_official 76:aeb1df146756 201 /** @defgroup SPI_BaudRate_Prescaler
mbed_official 76:aeb1df146756 202 * @{
mbed_official 76:aeb1df146756 203 */
mbed_official 76:aeb1df146756 204
mbed_official 76:aeb1df146756 205 #define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 206 #define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008)
mbed_official 76:aeb1df146756 207 #define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010)
mbed_official 76:aeb1df146756 208 #define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018)
mbed_official 76:aeb1df146756 209 #define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020)
mbed_official 76:aeb1df146756 210 #define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028)
mbed_official 76:aeb1df146756 211 #define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030)
mbed_official 76:aeb1df146756 212 #define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038)
mbed_official 76:aeb1df146756 213 #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BaudRatePrescaler_2) || \
mbed_official 76:aeb1df146756 214 ((PRESCALER) == SPI_BaudRatePrescaler_4) || \
mbed_official 76:aeb1df146756 215 ((PRESCALER) == SPI_BaudRatePrescaler_8) || \
mbed_official 76:aeb1df146756 216 ((PRESCALER) == SPI_BaudRatePrescaler_16) || \
mbed_official 76:aeb1df146756 217 ((PRESCALER) == SPI_BaudRatePrescaler_32) || \
mbed_official 76:aeb1df146756 218 ((PRESCALER) == SPI_BaudRatePrescaler_64) || \
mbed_official 76:aeb1df146756 219 ((PRESCALER) == SPI_BaudRatePrescaler_128) || \
mbed_official 76:aeb1df146756 220 ((PRESCALER) == SPI_BaudRatePrescaler_256))
mbed_official 76:aeb1df146756 221 /**
mbed_official 76:aeb1df146756 222 * @}
mbed_official 76:aeb1df146756 223 */
mbed_official 76:aeb1df146756 224
mbed_official 76:aeb1df146756 225 /** @defgroup SPI_MSB_LSB_transmission
mbed_official 76:aeb1df146756 226 * @{
mbed_official 76:aeb1df146756 227 */
mbed_official 76:aeb1df146756 228
mbed_official 76:aeb1df146756 229 #define SPI_FirstBit_MSB ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 230 #define SPI_FirstBit_LSB ((uint16_t)0x0080)
mbed_official 76:aeb1df146756 231 #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FirstBit_MSB) || \
mbed_official 76:aeb1df146756 232 ((BIT) == SPI_FirstBit_LSB))
mbed_official 76:aeb1df146756 233 /**
mbed_official 76:aeb1df146756 234 * @}
mbed_official 76:aeb1df146756 235 */
mbed_official 76:aeb1df146756 236
mbed_official 76:aeb1df146756 237 /** @defgroup SPI_I2S_Mode
mbed_official 76:aeb1df146756 238 * @{
mbed_official 76:aeb1df146756 239 */
mbed_official 76:aeb1df146756 240
mbed_official 76:aeb1df146756 241 #define I2S_Mode_SlaveTx ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 242 #define I2S_Mode_SlaveRx ((uint16_t)0x0100)
mbed_official 76:aeb1df146756 243 #define I2S_Mode_MasterTx ((uint16_t)0x0200)
mbed_official 76:aeb1df146756 244 #define I2S_Mode_MasterRx ((uint16_t)0x0300)
mbed_official 76:aeb1df146756 245 #define IS_I2S_MODE(MODE) (((MODE) == I2S_Mode_SlaveTx) || \
mbed_official 76:aeb1df146756 246 ((MODE) == I2S_Mode_SlaveRx) || \
mbed_official 76:aeb1df146756 247 ((MODE) == I2S_Mode_MasterTx)|| \
mbed_official 76:aeb1df146756 248 ((MODE) == I2S_Mode_MasterRx))
mbed_official 76:aeb1df146756 249 /**
mbed_official 76:aeb1df146756 250 * @}
mbed_official 76:aeb1df146756 251 */
mbed_official 76:aeb1df146756 252
mbed_official 76:aeb1df146756 253
mbed_official 76:aeb1df146756 254 /** @defgroup SPI_I2S_Standard
mbed_official 76:aeb1df146756 255 * @{
mbed_official 76:aeb1df146756 256 */
mbed_official 76:aeb1df146756 257
mbed_official 76:aeb1df146756 258 #define I2S_Standard_Phillips ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 259 #define I2S_Standard_MSB ((uint16_t)0x0010)
mbed_official 76:aeb1df146756 260 #define I2S_Standard_LSB ((uint16_t)0x0020)
mbed_official 76:aeb1df146756 261 #define I2S_Standard_PCMShort ((uint16_t)0x0030)
mbed_official 76:aeb1df146756 262 #define I2S_Standard_PCMLong ((uint16_t)0x00B0)
mbed_official 76:aeb1df146756 263 #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_Standard_Phillips) || \
mbed_official 76:aeb1df146756 264 ((STANDARD) == I2S_Standard_MSB) || \
mbed_official 76:aeb1df146756 265 ((STANDARD) == I2S_Standard_LSB) || \
mbed_official 76:aeb1df146756 266 ((STANDARD) == I2S_Standard_PCMShort) || \
mbed_official 76:aeb1df146756 267 ((STANDARD) == I2S_Standard_PCMLong))
mbed_official 76:aeb1df146756 268 /**
mbed_official 76:aeb1df146756 269 * @}
mbed_official 76:aeb1df146756 270 */
mbed_official 76:aeb1df146756 271
mbed_official 76:aeb1df146756 272 /** @defgroup SPI_I2S_Data_Format
mbed_official 76:aeb1df146756 273 * @{
mbed_official 76:aeb1df146756 274 */
mbed_official 76:aeb1df146756 275
mbed_official 76:aeb1df146756 276 #define I2S_DataFormat_16b ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 277 #define I2S_DataFormat_16bextended ((uint16_t)0x0001)
mbed_official 76:aeb1df146756 278 #define I2S_DataFormat_24b ((uint16_t)0x0003)
mbed_official 76:aeb1df146756 279 #define I2S_DataFormat_32b ((uint16_t)0x0005)
mbed_official 76:aeb1df146756 280 #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DataFormat_16b) || \
mbed_official 76:aeb1df146756 281 ((FORMAT) == I2S_DataFormat_16bextended) || \
mbed_official 76:aeb1df146756 282 ((FORMAT) == I2S_DataFormat_24b) || \
mbed_official 76:aeb1df146756 283 ((FORMAT) == I2S_DataFormat_32b))
mbed_official 76:aeb1df146756 284 /**
mbed_official 76:aeb1df146756 285 * @}
mbed_official 76:aeb1df146756 286 */
mbed_official 76:aeb1df146756 287
mbed_official 76:aeb1df146756 288 /** @defgroup SPI_I2S_MCLK_Output
mbed_official 76:aeb1df146756 289 * @{
mbed_official 76:aeb1df146756 290 */
mbed_official 76:aeb1df146756 291
mbed_official 76:aeb1df146756 292 #define I2S_MCLKOutput_Enable ((uint16_t)0x0200)
mbed_official 76:aeb1df146756 293 #define I2S_MCLKOutput_Disable ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 294 #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOutput_Enable) || \
mbed_official 76:aeb1df146756 295 ((OUTPUT) == I2S_MCLKOutput_Disable))
mbed_official 76:aeb1df146756 296 /**
mbed_official 76:aeb1df146756 297 * @}
mbed_official 76:aeb1df146756 298 */
mbed_official 76:aeb1df146756 299
mbed_official 76:aeb1df146756 300 /** @defgroup SPI_I2S_Audio_Frequency
mbed_official 76:aeb1df146756 301 * @{
mbed_official 76:aeb1df146756 302 */
mbed_official 76:aeb1df146756 303
mbed_official 76:aeb1df146756 304 #define I2S_AudioFreq_192k ((uint32_t)192000)
mbed_official 76:aeb1df146756 305 #define I2S_AudioFreq_96k ((uint32_t)96000)
mbed_official 76:aeb1df146756 306 #define I2S_AudioFreq_48k ((uint32_t)48000)
mbed_official 76:aeb1df146756 307 #define I2S_AudioFreq_44k ((uint32_t)44100)
mbed_official 76:aeb1df146756 308 #define I2S_AudioFreq_32k ((uint32_t)32000)
mbed_official 76:aeb1df146756 309 #define I2S_AudioFreq_22k ((uint32_t)22050)
mbed_official 76:aeb1df146756 310 #define I2S_AudioFreq_16k ((uint32_t)16000)
mbed_official 76:aeb1df146756 311 #define I2S_AudioFreq_11k ((uint32_t)11025)
mbed_official 76:aeb1df146756 312 #define I2S_AudioFreq_8k ((uint32_t)8000)
mbed_official 76:aeb1df146756 313 #define I2S_AudioFreq_Default ((uint32_t)2)
mbed_official 76:aeb1df146756 314
mbed_official 76:aeb1df146756 315 #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AudioFreq_8k) && \
mbed_official 76:aeb1df146756 316 ((FREQ) <= I2S_AudioFreq_192k)) || \
mbed_official 76:aeb1df146756 317 ((FREQ) == I2S_AudioFreq_Default))
mbed_official 76:aeb1df146756 318 /**
mbed_official 76:aeb1df146756 319 * @}
mbed_official 76:aeb1df146756 320 */
mbed_official 76:aeb1df146756 321
mbed_official 76:aeb1df146756 322 /** @defgroup SPI_I2S_Clock_Polarity
mbed_official 76:aeb1df146756 323 * @{
mbed_official 76:aeb1df146756 324 */
mbed_official 76:aeb1df146756 325
mbed_official 76:aeb1df146756 326 #define I2S_CPOL_Low ((uint16_t)0x0000)
mbed_official 76:aeb1df146756 327 #define I2S_CPOL_High ((uint16_t)0x0008)
mbed_official 76:aeb1df146756 328 #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_Low) || \
mbed_official 76:aeb1df146756 329 ((CPOL) == I2S_CPOL_High))
mbed_official 76:aeb1df146756 330 /**
mbed_official 76:aeb1df146756 331 * @}
mbed_official 76:aeb1df146756 332 */
mbed_official 76:aeb1df146756 333
mbed_official 76:aeb1df146756 334 /** @defgroup SPI_I2S_DMA_transfer_requests
mbed_official 76:aeb1df146756 335 * @{
mbed_official 76:aeb1df146756 336 */
mbed_official 76:aeb1df146756 337
mbed_official 76:aeb1df146756 338 #define SPI_I2S_DMAReq_Tx ((uint16_t)0x0002)
mbed_official 76:aeb1df146756 339 #define SPI_I2S_DMAReq_Rx ((uint16_t)0x0001)
mbed_official 76:aeb1df146756 340 #define IS_SPI_I2S_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFFFC) == 0x00) && ((DMAREQ) != 0x00))
mbed_official 76:aeb1df146756 341 /**
mbed_official 76:aeb1df146756 342 * @}
mbed_official 76:aeb1df146756 343 */
mbed_official 76:aeb1df146756 344
mbed_official 76:aeb1df146756 345 /** @defgroup SPI_NSS_internal_software_management
mbed_official 76:aeb1df146756 346 * @{
mbed_official 76:aeb1df146756 347 */
mbed_official 76:aeb1df146756 348
mbed_official 76:aeb1df146756 349 #define SPI_NSSInternalSoft_Set ((uint16_t)0x0100)
mbed_official 76:aeb1df146756 350 #define SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF)
mbed_official 76:aeb1df146756 351 #define IS_SPI_NSS_INTERNAL(INTERNAL) (((INTERNAL) == SPI_NSSInternalSoft_Set) || \
mbed_official 76:aeb1df146756 352 ((INTERNAL) == SPI_NSSInternalSoft_Reset))
mbed_official 76:aeb1df146756 353 /**
mbed_official 76:aeb1df146756 354 * @}
mbed_official 76:aeb1df146756 355 */
mbed_official 76:aeb1df146756 356
mbed_official 76:aeb1df146756 357 /** @defgroup SPI_CRC_Transmit_Receive
mbed_official 76:aeb1df146756 358 * @{
mbed_official 76:aeb1df146756 359 */
mbed_official 76:aeb1df146756 360
mbed_official 76:aeb1df146756 361 #define SPI_CRC_Tx ((uint8_t)0x00)
mbed_official 76:aeb1df146756 362 #define SPI_CRC_Rx ((uint8_t)0x01)
mbed_official 76:aeb1df146756 363 #define IS_SPI_CRC(CRC) (((CRC) == SPI_CRC_Tx) || ((CRC) == SPI_CRC_Rx))
mbed_official 76:aeb1df146756 364 /**
mbed_official 76:aeb1df146756 365 * @}
mbed_official 76:aeb1df146756 366 */
mbed_official 76:aeb1df146756 367
mbed_official 76:aeb1df146756 368 /** @defgroup SPI_direction_transmit_receive
mbed_official 76:aeb1df146756 369 * @{
mbed_official 76:aeb1df146756 370 */
mbed_official 76:aeb1df146756 371
mbed_official 76:aeb1df146756 372 #define SPI_Direction_Rx ((uint16_t)0xBFFF)
mbed_official 76:aeb1df146756 373 #define SPI_Direction_Tx ((uint16_t)0x4000)
mbed_official 76:aeb1df146756 374 #define IS_SPI_DIRECTION(DIRECTION) (((DIRECTION) == SPI_Direction_Rx) || \
mbed_official 76:aeb1df146756 375 ((DIRECTION) == SPI_Direction_Tx))
mbed_official 76:aeb1df146756 376 /**
mbed_official 76:aeb1df146756 377 * @}
mbed_official 76:aeb1df146756 378 */
mbed_official 76:aeb1df146756 379
mbed_official 76:aeb1df146756 380 /** @defgroup SPI_I2S_interrupts_definition
mbed_official 76:aeb1df146756 381 * @{
mbed_official 76:aeb1df146756 382 */
mbed_official 76:aeb1df146756 383
mbed_official 76:aeb1df146756 384 #define SPI_I2S_IT_TXE ((uint8_t)0x71)
mbed_official 76:aeb1df146756 385 #define SPI_I2S_IT_RXNE ((uint8_t)0x60)
mbed_official 76:aeb1df146756 386 #define SPI_I2S_IT_ERR ((uint8_t)0x50)
mbed_official 76:aeb1df146756 387 #define I2S_IT_UDR ((uint8_t)0x53)
mbed_official 76:aeb1df146756 388 #define SPI_I2S_IT_FRE ((uint8_t)0x58)
mbed_official 76:aeb1df146756 389
mbed_official 76:aeb1df146756 390 #define IS_SPI_I2S_CONFIG_IT(IT) (((IT) == SPI_I2S_IT_TXE) || \
mbed_official 76:aeb1df146756 391 ((IT) == SPI_I2S_IT_RXNE) || \
mbed_official 76:aeb1df146756 392 ((IT) == SPI_I2S_IT_ERR))
mbed_official 76:aeb1df146756 393
mbed_official 76:aeb1df146756 394 #define SPI_I2S_IT_OVR ((uint8_t)0x56)
mbed_official 76:aeb1df146756 395 #define SPI_IT_MODF ((uint8_t)0x55)
mbed_official 76:aeb1df146756 396 #define SPI_IT_CRCERR ((uint8_t)0x54)
mbed_official 76:aeb1df146756 397
mbed_official 76:aeb1df146756 398 #define IS_SPI_I2S_CLEAR_IT(IT) (((IT) == SPI_IT_CRCERR))
mbed_official 76:aeb1df146756 399
mbed_official 76:aeb1df146756 400 #define IS_SPI_I2S_GET_IT(IT) (((IT) == SPI_I2S_IT_RXNE) || ((IT) == SPI_I2S_IT_TXE) || \
mbed_official 76:aeb1df146756 401 ((IT) == SPI_IT_CRCERR) || ((IT) == SPI_IT_MODF) || \
mbed_official 76:aeb1df146756 402 ((IT) == SPI_I2S_IT_OVR) || ((IT) == I2S_IT_UDR) ||\
mbed_official 76:aeb1df146756 403 ((IT) == SPI_I2S_IT_FRE))
mbed_official 76:aeb1df146756 404 /**
mbed_official 76:aeb1df146756 405 * @}
mbed_official 76:aeb1df146756 406 */
mbed_official 76:aeb1df146756 407
mbed_official 76:aeb1df146756 408 /** @defgroup SPI_I2S_flags_definition
mbed_official 76:aeb1df146756 409 * @{
mbed_official 76:aeb1df146756 410 */
mbed_official 76:aeb1df146756 411
mbed_official 76:aeb1df146756 412 #define SPI_I2S_FLAG_RXNE ((uint16_t)0x0001)
mbed_official 76:aeb1df146756 413 #define SPI_I2S_FLAG_TXE ((uint16_t)0x0002)
mbed_official 76:aeb1df146756 414 #define I2S_FLAG_CHSIDE ((uint16_t)0x0004)
mbed_official 76:aeb1df146756 415 #define I2S_FLAG_UDR ((uint16_t)0x0008)
mbed_official 76:aeb1df146756 416 #define SPI_FLAG_CRCERR ((uint16_t)0x0010)
mbed_official 76:aeb1df146756 417 #define SPI_FLAG_MODF ((uint16_t)0x0020)
mbed_official 76:aeb1df146756 418 #define SPI_I2S_FLAG_OVR ((uint16_t)0x0040)
mbed_official 76:aeb1df146756 419 #define SPI_I2S_FLAG_BSY ((uint16_t)0x0080)
mbed_official 76:aeb1df146756 420 #define SPI_I2S_FLAG_FRE ((uint16_t)0x0100)
mbed_official 76:aeb1df146756 421
mbed_official 76:aeb1df146756 422 #define IS_SPI_I2S_CLEAR_FLAG(FLAG) (((FLAG) == SPI_FLAG_CRCERR))
mbed_official 76:aeb1df146756 423 #define IS_SPI_I2S_GET_FLAG(FLAG) (((FLAG) == SPI_I2S_FLAG_BSY) || ((FLAG) == SPI_I2S_FLAG_OVR) || \
mbed_official 76:aeb1df146756 424 ((FLAG) == SPI_FLAG_MODF) || ((FLAG) == SPI_FLAG_CRCERR) || \
mbed_official 76:aeb1df146756 425 ((FLAG) == I2S_FLAG_UDR) || ((FLAG) == I2S_FLAG_CHSIDE) || \
mbed_official 76:aeb1df146756 426 ((FLAG) == SPI_I2S_FLAG_TXE) || ((FLAG) == SPI_I2S_FLAG_RXNE)|| \
mbed_official 76:aeb1df146756 427 ((FLAG) == SPI_I2S_FLAG_FRE))
mbed_official 76:aeb1df146756 428 /**
mbed_official 76:aeb1df146756 429 * @}
mbed_official 76:aeb1df146756 430 */
mbed_official 76:aeb1df146756 431
mbed_official 76:aeb1df146756 432 /** @defgroup SPI_CRC_polynomial
mbed_official 76:aeb1df146756 433 * @{
mbed_official 76:aeb1df146756 434 */
mbed_official 76:aeb1df146756 435
mbed_official 76:aeb1df146756 436 #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) ((POLYNOMIAL) >= 0x1)
mbed_official 76:aeb1df146756 437 /**
mbed_official 76:aeb1df146756 438 * @}
mbed_official 76:aeb1df146756 439 */
mbed_official 76:aeb1df146756 440
mbed_official 76:aeb1df146756 441 /** @defgroup SPI_I2S_Legacy
mbed_official 76:aeb1df146756 442 * @{
mbed_official 76:aeb1df146756 443 */
mbed_official 76:aeb1df146756 444
mbed_official 76:aeb1df146756 445 #define SPI_DMAReq_Tx SPI_I2S_DMAReq_Tx
mbed_official 76:aeb1df146756 446 #define SPI_DMAReq_Rx SPI_I2S_DMAReq_Rx
mbed_official 76:aeb1df146756 447 #define SPI_IT_TXE SPI_I2S_IT_TXE
mbed_official 76:aeb1df146756 448 #define SPI_IT_RXNE SPI_I2S_IT_RXNE
mbed_official 76:aeb1df146756 449 #define SPI_IT_ERR SPI_I2S_IT_ERR
mbed_official 76:aeb1df146756 450 #define SPI_IT_OVR SPI_I2S_IT_OVR
mbed_official 76:aeb1df146756 451 #define SPI_FLAG_RXNE SPI_I2S_FLAG_RXNE
mbed_official 76:aeb1df146756 452 #define SPI_FLAG_TXE SPI_I2S_FLAG_TXE
mbed_official 76:aeb1df146756 453 #define SPI_FLAG_OVR SPI_I2S_FLAG_OVR
mbed_official 76:aeb1df146756 454 #define SPI_FLAG_BSY SPI_I2S_FLAG_BSY
mbed_official 76:aeb1df146756 455 #define SPI_DeInit SPI_I2S_DeInit
mbed_official 76:aeb1df146756 456 #define SPI_ITConfig SPI_I2S_ITConfig
mbed_official 76:aeb1df146756 457 #define SPI_DMACmd SPI_I2S_DMACmd
mbed_official 76:aeb1df146756 458 #define SPI_SendData SPI_I2S_SendData
mbed_official 76:aeb1df146756 459 #define SPI_ReceiveData SPI_I2S_ReceiveData
mbed_official 76:aeb1df146756 460 #define SPI_GetFlagStatus SPI_I2S_GetFlagStatus
mbed_official 76:aeb1df146756 461 #define SPI_ClearFlag SPI_I2S_ClearFlag
mbed_official 76:aeb1df146756 462 #define SPI_GetITStatus SPI_I2S_GetITStatus
mbed_official 76:aeb1df146756 463 #define SPI_ClearITPendingBit SPI_I2S_ClearITPendingBit
mbed_official 76:aeb1df146756 464 /**
mbed_official 76:aeb1df146756 465 * @}
mbed_official 76:aeb1df146756 466 */
mbed_official 76:aeb1df146756 467
mbed_official 76:aeb1df146756 468 /**
mbed_official 76:aeb1df146756 469 * @}
mbed_official 76:aeb1df146756 470 */
mbed_official 76:aeb1df146756 471
mbed_official 76:aeb1df146756 472 /* Exported macro ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 473 /* Exported functions ------------------------------------------------------- */
mbed_official 76:aeb1df146756 474
mbed_official 76:aeb1df146756 475 /* Function used to set the SPI configuration to the default reset state *****/
mbed_official 76:aeb1df146756 476 void SPI_I2S_DeInit(SPI_TypeDef* SPIx);
mbed_official 76:aeb1df146756 477
mbed_official 76:aeb1df146756 478 /* Initialization and Configuration functions *********************************/
mbed_official 76:aeb1df146756 479 void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);
mbed_official 76:aeb1df146756 480 void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct);
mbed_official 76:aeb1df146756 481 void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct);
mbed_official 76:aeb1df146756 482 void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct);
mbed_official 76:aeb1df146756 483 void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 76:aeb1df146756 484 void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 76:aeb1df146756 485 void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize);
mbed_official 76:aeb1df146756 486 void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction);
mbed_official 76:aeb1df146756 487 void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft);
mbed_official 76:aeb1df146756 488 void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 76:aeb1df146756 489
mbed_official 76:aeb1df146756 490 /* Data transfers functions ***************************************************/
mbed_official 76:aeb1df146756 491 void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data);
mbed_official 76:aeb1df146756 492 uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx);
mbed_official 76:aeb1df146756 493
mbed_official 76:aeb1df146756 494 /* Hardware CRC Calculation functions *****************************************/
mbed_official 76:aeb1df146756 495 void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 76:aeb1df146756 496 void SPI_TransmitCRC(SPI_TypeDef* SPIx);
mbed_official 76:aeb1df146756 497 uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC);
mbed_official 76:aeb1df146756 498 uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx);
mbed_official 76:aeb1df146756 499
mbed_official 76:aeb1df146756 500 /* DMA transfers management functions *****************************************/
mbed_official 76:aeb1df146756 501 void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);
mbed_official 76:aeb1df146756 502
mbed_official 76:aeb1df146756 503 /* Interrupts and flags management functions **********************************/
mbed_official 76:aeb1df146756 504 void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
mbed_official 76:aeb1df146756 505 FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
mbed_official 76:aeb1df146756 506 void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
mbed_official 76:aeb1df146756 507 ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
mbed_official 76:aeb1df146756 508 void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
mbed_official 76:aeb1df146756 509
mbed_official 76:aeb1df146756 510 #ifdef __cplusplus
mbed_official 76:aeb1df146756 511 }
mbed_official 76:aeb1df146756 512 #endif
mbed_official 76:aeb1df146756 513
mbed_official 76:aeb1df146756 514 #endif /*__STM32L1xx_SPI_H */
mbed_official 76:aeb1df146756 515
mbed_official 76:aeb1df146756 516 /**
mbed_official 76:aeb1df146756 517 * @}
mbed_official 76:aeb1df146756 518 */
mbed_official 76:aeb1df146756 519
mbed_official 76:aeb1df146756 520 /**
mbed_official 76:aeb1df146756 521 * @}
mbed_official 76:aeb1df146756 522 */
mbed_official 76:aeb1df146756 523
mbed_official 76:aeb1df146756 524 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/