mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Feb 03 09:30:05 2014 +0000
Revision:
84:f54042cbc282
Parent:
70:c1fbde68b492
Synchronized with git revision bbbd8699601c42149ccf0c37bc42bb6856ccc4c6

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

[NUCLEO_L152RE/F030_R8] SPI, I2C, Ticker, PWM updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 52:a51c77007319 1 /**
mbed_official 52:a51c77007319 2 ******************************************************************************
mbed_official 52:a51c77007319 3 * @file stm32f10x_spi.h
mbed_official 52:a51c77007319 4 * @author MCD Application Team
mbed_official 84:f54042cbc282 5 * @version V3.6.1
mbed_official 84:f54042cbc282 6 * @date 05-March-2012
mbed_official 52:a51c77007319 7 * @brief This file contains all the functions prototypes for the SPI firmware
mbed_official 52:a51c77007319 8 * library.
mbed_official 70:c1fbde68b492 9 *******************************************************************************
mbed_official 70:c1fbde68b492 10 * Copyright (c) 2014, STMicroelectronics
mbed_official 70:c1fbde68b492 11 * All rights reserved.
mbed_official 70:c1fbde68b492 12 *
mbed_official 70:c1fbde68b492 13 * Redistribution and use in source and binary forms, with or without
mbed_official 70:c1fbde68b492 14 * modification, are permitted provided that the following conditions are met:
mbed_official 70:c1fbde68b492 15 *
mbed_official 70:c1fbde68b492 16 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 70:c1fbde68b492 17 * this list of conditions and the following disclaimer.
mbed_official 70:c1fbde68b492 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 70:c1fbde68b492 19 * this list of conditions and the following disclaimer in the documentation
mbed_official 70:c1fbde68b492 20 * and/or other materials provided with the distribution.
mbed_official 70:c1fbde68b492 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 70:c1fbde68b492 22 * may be used to endorse or promote products derived from this software
mbed_official 70:c1fbde68b492 23 * without specific prior written permission.
mbed_official 70:c1fbde68b492 24 *
mbed_official 70:c1fbde68b492 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 70:c1fbde68b492 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 70:c1fbde68b492 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 70:c1fbde68b492 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 70:c1fbde68b492 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 70:c1fbde68b492 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 70:c1fbde68b492 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 70:c1fbde68b492 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 70:c1fbde68b492 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 70:c1fbde68b492 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 70:c1fbde68b492 35 *******************************************************************************
mbed_official 70:c1fbde68b492 36 */
mbed_official 52:a51c77007319 37
mbed_official 52:a51c77007319 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 52:a51c77007319 39 #ifndef __STM32F10x_SPI_H
mbed_official 52:a51c77007319 40 #define __STM32F10x_SPI_H
mbed_official 52:a51c77007319 41
mbed_official 52:a51c77007319 42 #ifdef __cplusplus
mbed_official 52:a51c77007319 43 extern "C" {
mbed_official 52:a51c77007319 44 #endif
mbed_official 52:a51c77007319 45
mbed_official 52:a51c77007319 46 /* Includes ------------------------------------------------------------------*/
mbed_official 52:a51c77007319 47 #include "stm32f10x.h"
mbed_official 52:a51c77007319 48
mbed_official 52:a51c77007319 49 /** @addtogroup STM32F10x_StdPeriph_Driver
mbed_official 52:a51c77007319 50 * @{
mbed_official 52:a51c77007319 51 */
mbed_official 52:a51c77007319 52
mbed_official 52:a51c77007319 53 /** @addtogroup SPI
mbed_official 52:a51c77007319 54 * @{
mbed_official 52:a51c77007319 55 */
mbed_official 52:a51c77007319 56
mbed_official 52:a51c77007319 57 /** @defgroup SPI_Exported_Types
mbed_official 52:a51c77007319 58 * @{
mbed_official 52:a51c77007319 59 */
mbed_official 52:a51c77007319 60
mbed_official 52:a51c77007319 61 /**
mbed_official 52:a51c77007319 62 * @brief SPI Init structure definition
mbed_official 52:a51c77007319 63 */
mbed_official 52:a51c77007319 64
mbed_official 52:a51c77007319 65 typedef struct
mbed_official 52:a51c77007319 66 {
mbed_official 52:a51c77007319 67 uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.
mbed_official 52:a51c77007319 68 This parameter can be a value of @ref SPI_data_direction */
mbed_official 52:a51c77007319 69
mbed_official 52:a51c77007319 70 uint16_t SPI_Mode; /*!< Specifies the SPI operating mode.
mbed_official 52:a51c77007319 71 This parameter can be a value of @ref SPI_mode */
mbed_official 52:a51c77007319 72
mbed_official 52:a51c77007319 73 uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
mbed_official 52:a51c77007319 74 This parameter can be a value of @ref SPI_data_size */
mbed_official 52:a51c77007319 75
mbed_official 52:a51c77007319 76 uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
mbed_official 52:a51c77007319 77 This parameter can be a value of @ref SPI_Clock_Polarity */
mbed_official 52:a51c77007319 78
mbed_official 52:a51c77007319 79 uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
mbed_official 52:a51c77007319 80 This parameter can be a value of @ref SPI_Clock_Phase */
mbed_official 52:a51c77007319 81
mbed_official 52:a51c77007319 82 uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
mbed_official 52:a51c77007319 83 hardware (NSS pin) or by software using the SSI bit.
mbed_official 52:a51c77007319 84 This parameter can be a value of @ref SPI_Slave_Select_management */
mbed_official 52:a51c77007319 85
mbed_official 52:a51c77007319 86 uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
mbed_official 52:a51c77007319 87 used to configure the transmit and receive SCK clock.
mbed_official 52:a51c77007319 88 This parameter can be a value of @ref SPI_BaudRate_Prescaler.
mbed_official 52:a51c77007319 89 @note The communication clock is derived from the master
mbed_official 52:a51c77007319 90 clock. The slave clock does not need to be set. */
mbed_official 52:a51c77007319 91
mbed_official 52:a51c77007319 92 uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
mbed_official 52:a51c77007319 93 This parameter can be a value of @ref SPI_MSB_LSB_transmission */
mbed_official 52:a51c77007319 94
mbed_official 52:a51c77007319 95 uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
mbed_official 52:a51c77007319 96 }SPI_InitTypeDef;
mbed_official 52:a51c77007319 97
mbed_official 52:a51c77007319 98 /**
mbed_official 52:a51c77007319 99 * @brief I2S Init structure definition
mbed_official 52:a51c77007319 100 */
mbed_official 52:a51c77007319 101
mbed_official 52:a51c77007319 102 typedef struct
mbed_official 52:a51c77007319 103 {
mbed_official 52:a51c77007319 104
mbed_official 52:a51c77007319 105 uint16_t I2S_Mode; /*!< Specifies the I2S operating mode.
mbed_official 52:a51c77007319 106 This parameter can be a value of @ref I2S_Mode */
mbed_official 52:a51c77007319 107
mbed_official 52:a51c77007319 108 uint16_t I2S_Standard; /*!< Specifies the standard used for the I2S communication.
mbed_official 52:a51c77007319 109 This parameter can be a value of @ref I2S_Standard */
mbed_official 52:a51c77007319 110
mbed_official 52:a51c77007319 111 uint16_t I2S_DataFormat; /*!< Specifies the data format for the I2S communication.
mbed_official 52:a51c77007319 112 This parameter can be a value of @ref I2S_Data_Format */
mbed_official 52:a51c77007319 113
mbed_official 52:a51c77007319 114 uint16_t I2S_MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
mbed_official 52:a51c77007319 115 This parameter can be a value of @ref I2S_MCLK_Output */
mbed_official 52:a51c77007319 116
mbed_official 52:a51c77007319 117 uint32_t I2S_AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
mbed_official 52:a51c77007319 118 This parameter can be a value of @ref I2S_Audio_Frequency */
mbed_official 52:a51c77007319 119
mbed_official 52:a51c77007319 120 uint16_t I2S_CPOL; /*!< Specifies the idle state of the I2S clock.
mbed_official 52:a51c77007319 121 This parameter can be a value of @ref I2S_Clock_Polarity */
mbed_official 52:a51c77007319 122 }I2S_InitTypeDef;
mbed_official 52:a51c77007319 123
mbed_official 52:a51c77007319 124 /**
mbed_official 52:a51c77007319 125 * @}
mbed_official 52:a51c77007319 126 */
mbed_official 52:a51c77007319 127
mbed_official 52:a51c77007319 128 /** @defgroup SPI_Exported_Constants
mbed_official 52:a51c77007319 129 * @{
mbed_official 52:a51c77007319 130 */
mbed_official 52:a51c77007319 131
mbed_official 52:a51c77007319 132 #define IS_SPI_ALL_PERIPH(PERIPH) (((PERIPH) == SPI1) || \
mbed_official 52:a51c77007319 133 ((PERIPH) == SPI2) || \
mbed_official 52:a51c77007319 134 ((PERIPH) == SPI3))
mbed_official 52:a51c77007319 135
mbed_official 52:a51c77007319 136 #define IS_SPI_23_PERIPH(PERIPH) (((PERIPH) == SPI2) || \
mbed_official 52:a51c77007319 137 ((PERIPH) == SPI3))
mbed_official 52:a51c77007319 138
mbed_official 52:a51c77007319 139 /** @defgroup SPI_data_direction
mbed_official 52:a51c77007319 140 * @{
mbed_official 52:a51c77007319 141 */
mbed_official 52:a51c77007319 142
mbed_official 52:a51c77007319 143 #define SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000)
mbed_official 52:a51c77007319 144 #define SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400)
mbed_official 52:a51c77007319 145 #define SPI_Direction_1Line_Rx ((uint16_t)0x8000)
mbed_official 52:a51c77007319 146 #define SPI_Direction_1Line_Tx ((uint16_t)0xC000)
mbed_official 52:a51c77007319 147 #define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_Direction_2Lines_FullDuplex) || \
mbed_official 52:a51c77007319 148 ((MODE) == SPI_Direction_2Lines_RxOnly) || \
mbed_official 52:a51c77007319 149 ((MODE) == SPI_Direction_1Line_Rx) || \
mbed_official 52:a51c77007319 150 ((MODE) == SPI_Direction_1Line_Tx))
mbed_official 52:a51c77007319 151 /**
mbed_official 52:a51c77007319 152 * @}
mbed_official 52:a51c77007319 153 */
mbed_official 52:a51c77007319 154
mbed_official 52:a51c77007319 155 /** @defgroup SPI_mode
mbed_official 52:a51c77007319 156 * @{
mbed_official 52:a51c77007319 157 */
mbed_official 52:a51c77007319 158
mbed_official 52:a51c77007319 159 #define SPI_Mode_Master ((uint16_t)0x0104)
mbed_official 52:a51c77007319 160 #define SPI_Mode_Slave ((uint16_t)0x0000)
mbed_official 52:a51c77007319 161 #define IS_SPI_MODE(MODE) (((MODE) == SPI_Mode_Master) || \
mbed_official 52:a51c77007319 162 ((MODE) == SPI_Mode_Slave))
mbed_official 52:a51c77007319 163 /**
mbed_official 52:a51c77007319 164 * @}
mbed_official 52:a51c77007319 165 */
mbed_official 52:a51c77007319 166
mbed_official 52:a51c77007319 167 /** @defgroup SPI_data_size
mbed_official 52:a51c77007319 168 * @{
mbed_official 52:a51c77007319 169 */
mbed_official 52:a51c77007319 170
mbed_official 52:a51c77007319 171 #define SPI_DataSize_16b ((uint16_t)0x0800)
mbed_official 52:a51c77007319 172 #define SPI_DataSize_8b ((uint16_t)0x0000)
mbed_official 52:a51c77007319 173 #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DataSize_16b) || \
mbed_official 52:a51c77007319 174 ((DATASIZE) == SPI_DataSize_8b))
mbed_official 52:a51c77007319 175 /**
mbed_official 52:a51c77007319 176 * @}
mbed_official 52:a51c77007319 177 */
mbed_official 52:a51c77007319 178
mbed_official 52:a51c77007319 179 /** @defgroup SPI_Clock_Polarity
mbed_official 52:a51c77007319 180 * @{
mbed_official 52:a51c77007319 181 */
mbed_official 52:a51c77007319 182
mbed_official 52:a51c77007319 183 #define SPI_CPOL_Low ((uint16_t)0x0000)
mbed_official 52:a51c77007319 184 #define SPI_CPOL_High ((uint16_t)0x0002)
mbed_official 52:a51c77007319 185 #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_CPOL_Low) || \
mbed_official 52:a51c77007319 186 ((CPOL) == SPI_CPOL_High))
mbed_official 52:a51c77007319 187 /**
mbed_official 52:a51c77007319 188 * @}
mbed_official 52:a51c77007319 189 */
mbed_official 52:a51c77007319 190
mbed_official 52:a51c77007319 191 /** @defgroup SPI_Clock_Phase
mbed_official 52:a51c77007319 192 * @{
mbed_official 52:a51c77007319 193 */
mbed_official 52:a51c77007319 194
mbed_official 52:a51c77007319 195 #define SPI_CPHA_1Edge ((uint16_t)0x0000)
mbed_official 52:a51c77007319 196 #define SPI_CPHA_2Edge ((uint16_t)0x0001)
mbed_official 52:a51c77007319 197 #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_CPHA_1Edge) || \
mbed_official 52:a51c77007319 198 ((CPHA) == SPI_CPHA_2Edge))
mbed_official 52:a51c77007319 199 /**
mbed_official 52:a51c77007319 200 * @}
mbed_official 52:a51c77007319 201 */
mbed_official 52:a51c77007319 202
mbed_official 52:a51c77007319 203 /** @defgroup SPI_Slave_Select_management
mbed_official 52:a51c77007319 204 * @{
mbed_official 52:a51c77007319 205 */
mbed_official 52:a51c77007319 206
mbed_official 52:a51c77007319 207 #define SPI_NSS_Soft ((uint16_t)0x0200)
mbed_official 52:a51c77007319 208 #define SPI_NSS_Hard ((uint16_t)0x0000)
mbed_official 52:a51c77007319 209 #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_Soft) || \
mbed_official 52:a51c77007319 210 ((NSS) == SPI_NSS_Hard))
mbed_official 52:a51c77007319 211 /**
mbed_official 52:a51c77007319 212 * @}
mbed_official 52:a51c77007319 213 */
mbed_official 52:a51c77007319 214
mbed_official 52:a51c77007319 215 /** @defgroup SPI_BaudRate_Prescaler
mbed_official 52:a51c77007319 216 * @{
mbed_official 52:a51c77007319 217 */
mbed_official 52:a51c77007319 218
mbed_official 52:a51c77007319 219 #define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000)
mbed_official 52:a51c77007319 220 #define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008)
mbed_official 52:a51c77007319 221 #define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010)
mbed_official 52:a51c77007319 222 #define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018)
mbed_official 52:a51c77007319 223 #define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020)
mbed_official 52:a51c77007319 224 #define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028)
mbed_official 52:a51c77007319 225 #define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030)
mbed_official 52:a51c77007319 226 #define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038)
mbed_official 52:a51c77007319 227 #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BaudRatePrescaler_2) || \
mbed_official 52:a51c77007319 228 ((PRESCALER) == SPI_BaudRatePrescaler_4) || \
mbed_official 52:a51c77007319 229 ((PRESCALER) == SPI_BaudRatePrescaler_8) || \
mbed_official 52:a51c77007319 230 ((PRESCALER) == SPI_BaudRatePrescaler_16) || \
mbed_official 52:a51c77007319 231 ((PRESCALER) == SPI_BaudRatePrescaler_32) || \
mbed_official 52:a51c77007319 232 ((PRESCALER) == SPI_BaudRatePrescaler_64) || \
mbed_official 52:a51c77007319 233 ((PRESCALER) == SPI_BaudRatePrescaler_128) || \
mbed_official 52:a51c77007319 234 ((PRESCALER) == SPI_BaudRatePrescaler_256))
mbed_official 52:a51c77007319 235 /**
mbed_official 52:a51c77007319 236 * @}
mbed_official 52:a51c77007319 237 */
mbed_official 52:a51c77007319 238
mbed_official 52:a51c77007319 239 /** @defgroup SPI_MSB_LSB_transmission
mbed_official 52:a51c77007319 240 * @{
mbed_official 52:a51c77007319 241 */
mbed_official 52:a51c77007319 242
mbed_official 52:a51c77007319 243 #define SPI_FirstBit_MSB ((uint16_t)0x0000)
mbed_official 52:a51c77007319 244 #define SPI_FirstBit_LSB ((uint16_t)0x0080)
mbed_official 52:a51c77007319 245 #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FirstBit_MSB) || \
mbed_official 52:a51c77007319 246 ((BIT) == SPI_FirstBit_LSB))
mbed_official 52:a51c77007319 247 /**
mbed_official 52:a51c77007319 248 * @}
mbed_official 52:a51c77007319 249 */
mbed_official 52:a51c77007319 250
mbed_official 52:a51c77007319 251 /** @defgroup I2S_Mode
mbed_official 52:a51c77007319 252 * @{
mbed_official 52:a51c77007319 253 */
mbed_official 52:a51c77007319 254
mbed_official 52:a51c77007319 255 #define I2S_Mode_SlaveTx ((uint16_t)0x0000)
mbed_official 52:a51c77007319 256 #define I2S_Mode_SlaveRx ((uint16_t)0x0100)
mbed_official 52:a51c77007319 257 #define I2S_Mode_MasterTx ((uint16_t)0x0200)
mbed_official 52:a51c77007319 258 #define I2S_Mode_MasterRx ((uint16_t)0x0300)
mbed_official 52:a51c77007319 259 #define IS_I2S_MODE(MODE) (((MODE) == I2S_Mode_SlaveTx) || \
mbed_official 52:a51c77007319 260 ((MODE) == I2S_Mode_SlaveRx) || \
mbed_official 52:a51c77007319 261 ((MODE) == I2S_Mode_MasterTx) || \
mbed_official 52:a51c77007319 262 ((MODE) == I2S_Mode_MasterRx) )
mbed_official 52:a51c77007319 263 /**
mbed_official 52:a51c77007319 264 * @}
mbed_official 52:a51c77007319 265 */
mbed_official 52:a51c77007319 266
mbed_official 52:a51c77007319 267 /** @defgroup I2S_Standard
mbed_official 52:a51c77007319 268 * @{
mbed_official 52:a51c77007319 269 */
mbed_official 52:a51c77007319 270
mbed_official 52:a51c77007319 271 #define I2S_Standard_Phillips ((uint16_t)0x0000)
mbed_official 52:a51c77007319 272 #define I2S_Standard_MSB ((uint16_t)0x0010)
mbed_official 52:a51c77007319 273 #define I2S_Standard_LSB ((uint16_t)0x0020)
mbed_official 52:a51c77007319 274 #define I2S_Standard_PCMShort ((uint16_t)0x0030)
mbed_official 52:a51c77007319 275 #define I2S_Standard_PCMLong ((uint16_t)0x00B0)
mbed_official 52:a51c77007319 276 #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_Standard_Phillips) || \
mbed_official 52:a51c77007319 277 ((STANDARD) == I2S_Standard_MSB) || \
mbed_official 52:a51c77007319 278 ((STANDARD) == I2S_Standard_LSB) || \
mbed_official 52:a51c77007319 279 ((STANDARD) == I2S_Standard_PCMShort) || \
mbed_official 52:a51c77007319 280 ((STANDARD) == I2S_Standard_PCMLong))
mbed_official 52:a51c77007319 281 /**
mbed_official 52:a51c77007319 282 * @}
mbed_official 52:a51c77007319 283 */
mbed_official 52:a51c77007319 284
mbed_official 52:a51c77007319 285 /** @defgroup I2S_Data_Format
mbed_official 52:a51c77007319 286 * @{
mbed_official 52:a51c77007319 287 */
mbed_official 52:a51c77007319 288
mbed_official 52:a51c77007319 289 #define I2S_DataFormat_16b ((uint16_t)0x0000)
mbed_official 52:a51c77007319 290 #define I2S_DataFormat_16bextended ((uint16_t)0x0001)
mbed_official 52:a51c77007319 291 #define I2S_DataFormat_24b ((uint16_t)0x0003)
mbed_official 52:a51c77007319 292 #define I2S_DataFormat_32b ((uint16_t)0x0005)
mbed_official 52:a51c77007319 293 #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DataFormat_16b) || \
mbed_official 52:a51c77007319 294 ((FORMAT) == I2S_DataFormat_16bextended) || \
mbed_official 52:a51c77007319 295 ((FORMAT) == I2S_DataFormat_24b) || \
mbed_official 52:a51c77007319 296 ((FORMAT) == I2S_DataFormat_32b))
mbed_official 52:a51c77007319 297 /**
mbed_official 52:a51c77007319 298 * @}
mbed_official 52:a51c77007319 299 */
mbed_official 52:a51c77007319 300
mbed_official 52:a51c77007319 301 /** @defgroup I2S_MCLK_Output
mbed_official 52:a51c77007319 302 * @{
mbed_official 52:a51c77007319 303 */
mbed_official 52:a51c77007319 304
mbed_official 52:a51c77007319 305 #define I2S_MCLKOutput_Enable ((uint16_t)0x0200)
mbed_official 52:a51c77007319 306 #define I2S_MCLKOutput_Disable ((uint16_t)0x0000)
mbed_official 52:a51c77007319 307 #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOutput_Enable) || \
mbed_official 52:a51c77007319 308 ((OUTPUT) == I2S_MCLKOutput_Disable))
mbed_official 52:a51c77007319 309 /**
mbed_official 52:a51c77007319 310 * @}
mbed_official 52:a51c77007319 311 */
mbed_official 52:a51c77007319 312
mbed_official 52:a51c77007319 313 /** @defgroup I2S_Audio_Frequency
mbed_official 52:a51c77007319 314 * @{
mbed_official 52:a51c77007319 315 */
mbed_official 52:a51c77007319 316
mbed_official 52:a51c77007319 317 #define I2S_AudioFreq_192k ((uint32_t)192000)
mbed_official 52:a51c77007319 318 #define I2S_AudioFreq_96k ((uint32_t)96000)
mbed_official 52:a51c77007319 319 #define I2S_AudioFreq_48k ((uint32_t)48000)
mbed_official 52:a51c77007319 320 #define I2S_AudioFreq_44k ((uint32_t)44100)
mbed_official 52:a51c77007319 321 #define I2S_AudioFreq_32k ((uint32_t)32000)
mbed_official 52:a51c77007319 322 #define I2S_AudioFreq_22k ((uint32_t)22050)
mbed_official 52:a51c77007319 323 #define I2S_AudioFreq_16k ((uint32_t)16000)
mbed_official 52:a51c77007319 324 #define I2S_AudioFreq_11k ((uint32_t)11025)
mbed_official 52:a51c77007319 325 #define I2S_AudioFreq_8k ((uint32_t)8000)
mbed_official 52:a51c77007319 326 #define I2S_AudioFreq_Default ((uint32_t)2)
mbed_official 52:a51c77007319 327
mbed_official 52:a51c77007319 328 #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AudioFreq_8k) && \
mbed_official 52:a51c77007319 329 ((FREQ) <= I2S_AudioFreq_192k)) || \
mbed_official 52:a51c77007319 330 ((FREQ) == I2S_AudioFreq_Default))
mbed_official 52:a51c77007319 331 /**
mbed_official 52:a51c77007319 332 * @}
mbed_official 52:a51c77007319 333 */
mbed_official 52:a51c77007319 334
mbed_official 52:a51c77007319 335 /** @defgroup I2S_Clock_Polarity
mbed_official 52:a51c77007319 336 * @{
mbed_official 52:a51c77007319 337 */
mbed_official 52:a51c77007319 338
mbed_official 52:a51c77007319 339 #define I2S_CPOL_Low ((uint16_t)0x0000)
mbed_official 52:a51c77007319 340 #define I2S_CPOL_High ((uint16_t)0x0008)
mbed_official 52:a51c77007319 341 #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_Low) || \
mbed_official 52:a51c77007319 342 ((CPOL) == I2S_CPOL_High))
mbed_official 52:a51c77007319 343 /**
mbed_official 52:a51c77007319 344 * @}
mbed_official 52:a51c77007319 345 */
mbed_official 52:a51c77007319 346
mbed_official 52:a51c77007319 347 /** @defgroup SPI_I2S_DMA_transfer_requests
mbed_official 52:a51c77007319 348 * @{
mbed_official 52:a51c77007319 349 */
mbed_official 52:a51c77007319 350
mbed_official 52:a51c77007319 351 #define SPI_I2S_DMAReq_Tx ((uint16_t)0x0002)
mbed_official 52:a51c77007319 352 #define SPI_I2S_DMAReq_Rx ((uint16_t)0x0001)
mbed_official 52:a51c77007319 353 #define IS_SPI_I2S_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFFFC) == 0x00) && ((DMAREQ) != 0x00))
mbed_official 52:a51c77007319 354 /**
mbed_official 52:a51c77007319 355 * @}
mbed_official 52:a51c77007319 356 */
mbed_official 52:a51c77007319 357
mbed_official 52:a51c77007319 358 /** @defgroup SPI_NSS_internal_software_management
mbed_official 52:a51c77007319 359 * @{
mbed_official 52:a51c77007319 360 */
mbed_official 52:a51c77007319 361
mbed_official 52:a51c77007319 362 #define SPI_NSSInternalSoft_Set ((uint16_t)0x0100)
mbed_official 52:a51c77007319 363 #define SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF)
mbed_official 52:a51c77007319 364 #define IS_SPI_NSS_INTERNAL(INTERNAL) (((INTERNAL) == SPI_NSSInternalSoft_Set) || \
mbed_official 52:a51c77007319 365 ((INTERNAL) == SPI_NSSInternalSoft_Reset))
mbed_official 52:a51c77007319 366 /**
mbed_official 52:a51c77007319 367 * @}
mbed_official 52:a51c77007319 368 */
mbed_official 52:a51c77007319 369
mbed_official 52:a51c77007319 370 /** @defgroup SPI_CRC_Transmit_Receive
mbed_official 52:a51c77007319 371 * @{
mbed_official 52:a51c77007319 372 */
mbed_official 52:a51c77007319 373
mbed_official 52:a51c77007319 374 #define SPI_CRC_Tx ((uint8_t)0x00)
mbed_official 52:a51c77007319 375 #define SPI_CRC_Rx ((uint8_t)0x01)
mbed_official 52:a51c77007319 376 #define IS_SPI_CRC(CRC) (((CRC) == SPI_CRC_Tx) || ((CRC) == SPI_CRC_Rx))
mbed_official 52:a51c77007319 377 /**
mbed_official 52:a51c77007319 378 * @}
mbed_official 52:a51c77007319 379 */
mbed_official 52:a51c77007319 380
mbed_official 52:a51c77007319 381 /** @defgroup SPI_direction_transmit_receive
mbed_official 52:a51c77007319 382 * @{
mbed_official 52:a51c77007319 383 */
mbed_official 52:a51c77007319 384
mbed_official 52:a51c77007319 385 #define SPI_Direction_Rx ((uint16_t)0xBFFF)
mbed_official 52:a51c77007319 386 #define SPI_Direction_Tx ((uint16_t)0x4000)
mbed_official 52:a51c77007319 387 #define IS_SPI_DIRECTION(DIRECTION) (((DIRECTION) == SPI_Direction_Rx) || \
mbed_official 52:a51c77007319 388 ((DIRECTION) == SPI_Direction_Tx))
mbed_official 52:a51c77007319 389 /**
mbed_official 52:a51c77007319 390 * @}
mbed_official 52:a51c77007319 391 */
mbed_official 52:a51c77007319 392
mbed_official 52:a51c77007319 393 /** @defgroup SPI_I2S_interrupts_definition
mbed_official 52:a51c77007319 394 * @{
mbed_official 52:a51c77007319 395 */
mbed_official 52:a51c77007319 396
mbed_official 52:a51c77007319 397 #define SPI_I2S_IT_TXE ((uint8_t)0x71)
mbed_official 52:a51c77007319 398 #define SPI_I2S_IT_RXNE ((uint8_t)0x60)
mbed_official 52:a51c77007319 399 #define SPI_I2S_IT_ERR ((uint8_t)0x50)
mbed_official 52:a51c77007319 400 #define IS_SPI_I2S_CONFIG_IT(IT) (((IT) == SPI_I2S_IT_TXE) || \
mbed_official 52:a51c77007319 401 ((IT) == SPI_I2S_IT_RXNE) || \
mbed_official 52:a51c77007319 402 ((IT) == SPI_I2S_IT_ERR))
mbed_official 52:a51c77007319 403 #define SPI_I2S_IT_OVR ((uint8_t)0x56)
mbed_official 52:a51c77007319 404 #define SPI_IT_MODF ((uint8_t)0x55)
mbed_official 52:a51c77007319 405 #define SPI_IT_CRCERR ((uint8_t)0x54)
mbed_official 52:a51c77007319 406 #define I2S_IT_UDR ((uint8_t)0x53)
mbed_official 52:a51c77007319 407 #define IS_SPI_I2S_CLEAR_IT(IT) (((IT) == SPI_IT_CRCERR))
mbed_official 52:a51c77007319 408 #define IS_SPI_I2S_GET_IT(IT) (((IT) == SPI_I2S_IT_RXNE) || ((IT) == SPI_I2S_IT_TXE) || \
mbed_official 52:a51c77007319 409 ((IT) == I2S_IT_UDR) || ((IT) == SPI_IT_CRCERR) || \
mbed_official 52:a51c77007319 410 ((IT) == SPI_IT_MODF) || ((IT) == SPI_I2S_IT_OVR))
mbed_official 52:a51c77007319 411 /**
mbed_official 52:a51c77007319 412 * @}
mbed_official 52:a51c77007319 413 */
mbed_official 52:a51c77007319 414
mbed_official 52:a51c77007319 415 /** @defgroup SPI_I2S_flags_definition
mbed_official 52:a51c77007319 416 * @{
mbed_official 52:a51c77007319 417 */
mbed_official 52:a51c77007319 418
mbed_official 52:a51c77007319 419 #define SPI_I2S_FLAG_RXNE ((uint16_t)0x0001)
mbed_official 52:a51c77007319 420 #define SPI_I2S_FLAG_TXE ((uint16_t)0x0002)
mbed_official 52:a51c77007319 421 #define I2S_FLAG_CHSIDE ((uint16_t)0x0004)
mbed_official 52:a51c77007319 422 #define I2S_FLAG_UDR ((uint16_t)0x0008)
mbed_official 52:a51c77007319 423 #define SPI_FLAG_CRCERR ((uint16_t)0x0010)
mbed_official 52:a51c77007319 424 #define SPI_FLAG_MODF ((uint16_t)0x0020)
mbed_official 52:a51c77007319 425 #define SPI_I2S_FLAG_OVR ((uint16_t)0x0040)
mbed_official 52:a51c77007319 426 #define SPI_I2S_FLAG_BSY ((uint16_t)0x0080)
mbed_official 52:a51c77007319 427 #define IS_SPI_I2S_CLEAR_FLAG(FLAG) (((FLAG) == SPI_FLAG_CRCERR))
mbed_official 52:a51c77007319 428 #define IS_SPI_I2S_GET_FLAG(FLAG) (((FLAG) == SPI_I2S_FLAG_BSY) || ((FLAG) == SPI_I2S_FLAG_OVR) || \
mbed_official 52:a51c77007319 429 ((FLAG) == SPI_FLAG_MODF) || ((FLAG) == SPI_FLAG_CRCERR) || \
mbed_official 52:a51c77007319 430 ((FLAG) == I2S_FLAG_UDR) || ((FLAG) == I2S_FLAG_CHSIDE) || \
mbed_official 52:a51c77007319 431 ((FLAG) == SPI_I2S_FLAG_TXE) || ((FLAG) == SPI_I2S_FLAG_RXNE))
mbed_official 52:a51c77007319 432 /**
mbed_official 52:a51c77007319 433 * @}
mbed_official 52:a51c77007319 434 */
mbed_official 52:a51c77007319 435
mbed_official 52:a51c77007319 436 /** @defgroup SPI_CRC_polynomial
mbed_official 52:a51c77007319 437 * @{
mbed_official 52:a51c77007319 438 */
mbed_official 52:a51c77007319 439
mbed_official 52:a51c77007319 440 #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) ((POLYNOMIAL) >= 0x1)
mbed_official 52:a51c77007319 441 /**
mbed_official 52:a51c77007319 442 * @}
mbed_official 52:a51c77007319 443 */
mbed_official 52:a51c77007319 444
mbed_official 52:a51c77007319 445 /**
mbed_official 52:a51c77007319 446 * @}
mbed_official 52:a51c77007319 447 */
mbed_official 52:a51c77007319 448
mbed_official 52:a51c77007319 449 /** @defgroup SPI_Exported_Macros
mbed_official 52:a51c77007319 450 * @{
mbed_official 52:a51c77007319 451 */
mbed_official 52:a51c77007319 452
mbed_official 52:a51c77007319 453 /**
mbed_official 52:a51c77007319 454 * @}
mbed_official 52:a51c77007319 455 */
mbed_official 52:a51c77007319 456
mbed_official 52:a51c77007319 457 /** @defgroup SPI_Exported_Functions
mbed_official 52:a51c77007319 458 * @{
mbed_official 52:a51c77007319 459 */
mbed_official 52:a51c77007319 460
mbed_official 52:a51c77007319 461 void SPI_I2S_DeInit(SPI_TypeDef* SPIx);
mbed_official 52:a51c77007319 462 void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);
mbed_official 52:a51c77007319 463 void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct);
mbed_official 52:a51c77007319 464 void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct);
mbed_official 52:a51c77007319 465 void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct);
mbed_official 52:a51c77007319 466 void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 52:a51c77007319 467 void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 52:a51c77007319 468 void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
mbed_official 52:a51c77007319 469 void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);
mbed_official 52:a51c77007319 470 void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data);
mbed_official 52:a51c77007319 471 uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx);
mbed_official 52:a51c77007319 472 void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft);
mbed_official 52:a51c77007319 473 void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 52:a51c77007319 474 void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize);
mbed_official 52:a51c77007319 475 void SPI_TransmitCRC(SPI_TypeDef* SPIx);
mbed_official 52:a51c77007319 476 void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState);
mbed_official 52:a51c77007319 477 uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC);
mbed_official 52:a51c77007319 478 uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx);
mbed_official 52:a51c77007319 479 void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction);
mbed_official 52:a51c77007319 480 FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
mbed_official 52:a51c77007319 481 void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
mbed_official 52:a51c77007319 482 ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
mbed_official 52:a51c77007319 483 void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
mbed_official 52:a51c77007319 484
mbed_official 52:a51c77007319 485 #ifdef __cplusplus
mbed_official 52:a51c77007319 486 }
mbed_official 52:a51c77007319 487 #endif
mbed_official 52:a51c77007319 488
mbed_official 52:a51c77007319 489 #endif /*__STM32F10x_SPI_H */
mbed_official 52:a51c77007319 490 /**
mbed_official 52:a51c77007319 491 * @}
mbed_official 52:a51c77007319 492 */
mbed_official 52:a51c77007319 493
mbed_official 52:a51c77007319 494 /**
mbed_official 52:a51c77007319 495 * @}
mbed_official 52:a51c77007319 496 */
mbed_official 52:a51c77007319 497
mbed_official 52:a51c77007319 498 /**
mbed_official 52:a51c77007319 499 * @}
mbed_official 52:a51c77007319 500 */
mbed_official 52:a51c77007319 501
mbed_official 84:f54042cbc282 502 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/