mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F303VC/stm32f30x_spi.h@310:6188e0254baa, 2014-09-16 (annotated)
- Committer:
- janekm
- Date:
- Tue Sep 16 22:42:01 2014 +0000
- Revision:
- 310:6188e0254baa
- Parent:
- 157:90e3acc479a2
N/A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 157:90e3acc479a2 | 1 | /** |
mbed_official | 157:90e3acc479a2 | 2 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 3 | * @file stm32f30x_spi.h |
mbed_official | 157:90e3acc479a2 | 4 | * @author MCD Application Team |
mbed_official | 157:90e3acc479a2 | 5 | * @version V1.1.0 |
mbed_official | 157:90e3acc479a2 | 6 | * @date 27-February-2014 |
mbed_official | 157:90e3acc479a2 | 7 | * @brief This file contains all the functions prototypes for the SPI |
mbed_official | 157:90e3acc479a2 | 8 | * firmware library. |
mbed_official | 157:90e3acc479a2 | 9 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 10 | * @attention |
mbed_official | 157:90e3acc479a2 | 11 | * |
mbed_official | 157:90e3acc479a2 | 12 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 157:90e3acc479a2 | 13 | * |
mbed_official | 157:90e3acc479a2 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 157:90e3acc479a2 | 15 | * are permitted provided that the following conditions are met: |
mbed_official | 157:90e3acc479a2 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 157:90e3acc479a2 | 17 | * this list of conditions and the following disclaimer. |
mbed_official | 157:90e3acc479a2 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 157:90e3acc479a2 | 19 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 157:90e3acc479a2 | 20 | * and/or other materials provided with the distribution. |
mbed_official | 157:90e3acc479a2 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 157:90e3acc479a2 | 22 | * may be used to endorse or promote products derived from this software |
mbed_official | 157:90e3acc479a2 | 23 | * without specific prior written permission. |
mbed_official | 157:90e3acc479a2 | 24 | * |
mbed_official | 157:90e3acc479a2 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 157:90e3acc479a2 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 157:90e3acc479a2 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 157:90e3acc479a2 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 157:90e3acc479a2 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 157:90e3acc479a2 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 157:90e3acc479a2 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 157:90e3acc479a2 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 157:90e3acc479a2 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 157:90e3acc479a2 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 157:90e3acc479a2 | 35 | * |
mbed_official | 157:90e3acc479a2 | 36 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 37 | */ |
mbed_official | 157:90e3acc479a2 | 38 | |
mbed_official | 157:90e3acc479a2 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 40 | #ifndef __STM32F30x_SPI_H |
mbed_official | 157:90e3acc479a2 | 41 | #define __STM32F30x_SPI_H |
mbed_official | 157:90e3acc479a2 | 42 | |
mbed_official | 157:90e3acc479a2 | 43 | #ifdef __cplusplus |
mbed_official | 157:90e3acc479a2 | 44 | extern "C" { |
mbed_official | 157:90e3acc479a2 | 45 | #endif |
mbed_official | 157:90e3acc479a2 | 46 | |
mbed_official | 157:90e3acc479a2 | 47 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 48 | #include "stm32f30x.h" |
mbed_official | 157:90e3acc479a2 | 49 | |
mbed_official | 157:90e3acc479a2 | 50 | /** @addtogroup STM32F30x_StdPeriph_Driver |
mbed_official | 157:90e3acc479a2 | 51 | * @{ |
mbed_official | 157:90e3acc479a2 | 52 | */ |
mbed_official | 157:90e3acc479a2 | 53 | |
mbed_official | 157:90e3acc479a2 | 54 | /** @addtogroup SPI |
mbed_official | 157:90e3acc479a2 | 55 | * @{ |
mbed_official | 157:90e3acc479a2 | 56 | */ |
mbed_official | 157:90e3acc479a2 | 57 | |
mbed_official | 157:90e3acc479a2 | 58 | /* Exported types ------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 59 | |
mbed_official | 157:90e3acc479a2 | 60 | /** |
mbed_official | 157:90e3acc479a2 | 61 | * @brief SPI Init structure definition |
mbed_official | 157:90e3acc479a2 | 62 | */ |
mbed_official | 157:90e3acc479a2 | 63 | |
mbed_official | 157:90e3acc479a2 | 64 | typedef struct |
mbed_official | 157:90e3acc479a2 | 65 | { |
mbed_official | 157:90e3acc479a2 | 66 | uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode. |
mbed_official | 157:90e3acc479a2 | 67 | This parameter can be a value of @ref SPI_data_direction */ |
mbed_official | 157:90e3acc479a2 | 68 | |
mbed_official | 157:90e3acc479a2 | 69 | uint16_t SPI_Mode; /*!< Specifies the SPI mode (Master/Slave). |
mbed_official | 157:90e3acc479a2 | 70 | This parameter can be a value of @ref SPI_mode */ |
mbed_official | 157:90e3acc479a2 | 71 | |
mbed_official | 157:90e3acc479a2 | 72 | uint16_t SPI_DataSize; /*!< Specifies the SPI data size. |
mbed_official | 157:90e3acc479a2 | 73 | This parameter can be a value of @ref SPI_data_size */ |
mbed_official | 157:90e3acc479a2 | 74 | |
mbed_official | 157:90e3acc479a2 | 75 | uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state. |
mbed_official | 157:90e3acc479a2 | 76 | This parameter can be a value of @ref SPI_Clock_Polarity */ |
mbed_official | 157:90e3acc479a2 | 77 | |
mbed_official | 157:90e3acc479a2 | 78 | uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture. |
mbed_official | 157:90e3acc479a2 | 79 | This parameter can be a value of @ref SPI_Clock_Phase */ |
mbed_official | 157:90e3acc479a2 | 80 | |
mbed_official | 157:90e3acc479a2 | 81 | uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by |
mbed_official | 157:90e3acc479a2 | 82 | hardware (NSS pin) or by software using the SSI bit. |
mbed_official | 157:90e3acc479a2 | 83 | This parameter can be a value of @ref SPI_Slave_Select_management */ |
mbed_official | 157:90e3acc479a2 | 84 | |
mbed_official | 157:90e3acc479a2 | 85 | uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be |
mbed_official | 157:90e3acc479a2 | 86 | used to configure the transmit and receive SCK clock. |
mbed_official | 157:90e3acc479a2 | 87 | This parameter can be a value of @ref SPI_BaudRate_Prescaler. |
mbed_official | 157:90e3acc479a2 | 88 | @note The communication clock is derived from the master |
mbed_official | 157:90e3acc479a2 | 89 | clock. The slave clock does not need to be set. */ |
mbed_official | 157:90e3acc479a2 | 90 | |
mbed_official | 157:90e3acc479a2 | 91 | uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. |
mbed_official | 157:90e3acc479a2 | 92 | This parameter can be a value of @ref SPI_MSB_LSB_transmission */ |
mbed_official | 157:90e3acc479a2 | 93 | |
mbed_official | 157:90e3acc479a2 | 94 | uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */ |
mbed_official | 157:90e3acc479a2 | 95 | }SPI_InitTypeDef; |
mbed_official | 157:90e3acc479a2 | 96 | |
mbed_official | 157:90e3acc479a2 | 97 | |
mbed_official | 157:90e3acc479a2 | 98 | /** |
mbed_official | 157:90e3acc479a2 | 99 | * @brief I2S Init structure definition |
mbed_official | 157:90e3acc479a2 | 100 | */ |
mbed_official | 157:90e3acc479a2 | 101 | |
mbed_official | 157:90e3acc479a2 | 102 | typedef struct |
mbed_official | 157:90e3acc479a2 | 103 | { |
mbed_official | 157:90e3acc479a2 | 104 | uint16_t I2S_Mode; /*!< Specifies the I2S operating mode. |
mbed_official | 157:90e3acc479a2 | 105 | This parameter can be a value of @ref I2S_Mode */ |
mbed_official | 157:90e3acc479a2 | 106 | |
mbed_official | 157:90e3acc479a2 | 107 | uint16_t I2S_Standard; /*!< Specifies the standard used for the I2S communication. |
mbed_official | 157:90e3acc479a2 | 108 | This parameter can be a value of @ref I2S_Standard */ |
mbed_official | 157:90e3acc479a2 | 109 | |
mbed_official | 157:90e3acc479a2 | 110 | uint16_t I2S_DataFormat; /*!< Specifies the data format for the I2S communication. |
mbed_official | 157:90e3acc479a2 | 111 | This parameter can be a value of @ref I2S_Data_Format */ |
mbed_official | 157:90e3acc479a2 | 112 | |
mbed_official | 157:90e3acc479a2 | 113 | uint16_t I2S_MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not. |
mbed_official | 157:90e3acc479a2 | 114 | This parameter can be a value of @ref I2S_MCLK_Output */ |
mbed_official | 157:90e3acc479a2 | 115 | |
mbed_official | 157:90e3acc479a2 | 116 | uint32_t I2S_AudioFreq; /*!< Specifies the frequency selected for the I2S communication. |
mbed_official | 157:90e3acc479a2 | 117 | This parameter can be a value of @ref I2S_Audio_Frequency */ |
mbed_official | 157:90e3acc479a2 | 118 | |
mbed_official | 157:90e3acc479a2 | 119 | uint16_t I2S_CPOL; /*!< Specifies the idle state of the I2S clock. |
mbed_official | 157:90e3acc479a2 | 120 | This parameter can be a value of @ref I2S_Clock_Polarity */ |
mbed_official | 157:90e3acc479a2 | 121 | }I2S_InitTypeDef; |
mbed_official | 157:90e3acc479a2 | 122 | |
mbed_official | 157:90e3acc479a2 | 123 | /* Exported constants --------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 124 | |
mbed_official | 157:90e3acc479a2 | 125 | /** @defgroup SPI_Exported_Constants |
mbed_official | 157:90e3acc479a2 | 126 | * @{ |
mbed_official | 157:90e3acc479a2 | 127 | */ |
mbed_official | 157:90e3acc479a2 | 128 | |
mbed_official | 157:90e3acc479a2 | 129 | #define IS_SPI_ALL_PERIPH(PERIPH) (((PERIPH) == SPI1) || \ |
mbed_official | 157:90e3acc479a2 | 130 | ((PERIPH) == SPI2) || \ |
mbed_official | 157:90e3acc479a2 | 131 | ((PERIPH) == SPI3)) |
mbed_official | 157:90e3acc479a2 | 132 | |
mbed_official | 157:90e3acc479a2 | 133 | #define IS_SPI_ALL_PERIPH_EXT(PERIPH) (((PERIPH) == SPI1) || \ |
mbed_official | 157:90e3acc479a2 | 134 | ((PERIPH) == SPI2) || \ |
mbed_official | 157:90e3acc479a2 | 135 | ((PERIPH) == SPI3) || \ |
mbed_official | 157:90e3acc479a2 | 136 | ((PERIPH) == I2S2ext) || \ |
mbed_official | 157:90e3acc479a2 | 137 | ((PERIPH) == I2S3ext)) |
mbed_official | 157:90e3acc479a2 | 138 | |
mbed_official | 157:90e3acc479a2 | 139 | #define IS_SPI_23_PERIPH(PERIPH) (((PERIPH) == SPI2) || \ |
mbed_official | 157:90e3acc479a2 | 140 | ((PERIPH) == SPI3)) |
mbed_official | 157:90e3acc479a2 | 141 | |
mbed_official | 157:90e3acc479a2 | 142 | #define IS_SPI_23_PERIPH_EXT(PERIPH) (((PERIPH) == SPI2) || \ |
mbed_official | 157:90e3acc479a2 | 143 | ((PERIPH) == SPI3) || \ |
mbed_official | 157:90e3acc479a2 | 144 | ((PERIPH) == I2S2ext) || \ |
mbed_official | 157:90e3acc479a2 | 145 | ((PERIPH) == I2S3ext)) |
mbed_official | 157:90e3acc479a2 | 146 | |
mbed_official | 157:90e3acc479a2 | 147 | #define IS_I2S_EXT_PERIPH(PERIPH) (((PERIPH) == I2S2ext) || \ |
mbed_official | 157:90e3acc479a2 | 148 | ((PERIPH) == I2S3ext)) |
mbed_official | 157:90e3acc479a2 | 149 | |
mbed_official | 157:90e3acc479a2 | 150 | /** @defgroup SPI_data_direction |
mbed_official | 157:90e3acc479a2 | 151 | * @{ |
mbed_official | 157:90e3acc479a2 | 152 | */ |
mbed_official | 157:90e3acc479a2 | 153 | |
mbed_official | 157:90e3acc479a2 | 154 | #define SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 155 | #define SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400) |
mbed_official | 157:90e3acc479a2 | 156 | #define SPI_Direction_1Line_Rx ((uint16_t)0x8000) |
mbed_official | 157:90e3acc479a2 | 157 | #define SPI_Direction_1Line_Tx ((uint16_t)0xC000) |
mbed_official | 157:90e3acc479a2 | 158 | #define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_Direction_2Lines_FullDuplex) || \ |
mbed_official | 157:90e3acc479a2 | 159 | ((MODE) == SPI_Direction_2Lines_RxOnly) || \ |
mbed_official | 157:90e3acc479a2 | 160 | ((MODE) == SPI_Direction_1Line_Rx) || \ |
mbed_official | 157:90e3acc479a2 | 161 | ((MODE) == SPI_Direction_1Line_Tx)) |
mbed_official | 157:90e3acc479a2 | 162 | /** |
mbed_official | 157:90e3acc479a2 | 163 | * @} |
mbed_official | 157:90e3acc479a2 | 164 | */ |
mbed_official | 157:90e3acc479a2 | 165 | |
mbed_official | 157:90e3acc479a2 | 166 | /** @defgroup SPI_mode |
mbed_official | 157:90e3acc479a2 | 167 | * @{ |
mbed_official | 157:90e3acc479a2 | 168 | */ |
mbed_official | 157:90e3acc479a2 | 169 | |
mbed_official | 157:90e3acc479a2 | 170 | #define SPI_Mode_Master ((uint16_t)0x0104) |
mbed_official | 157:90e3acc479a2 | 171 | #define SPI_Mode_Slave ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 172 | #define IS_SPI_MODE(MODE) (((MODE) == SPI_Mode_Master) || \ |
mbed_official | 157:90e3acc479a2 | 173 | ((MODE) == SPI_Mode_Slave)) |
mbed_official | 157:90e3acc479a2 | 174 | /** |
mbed_official | 157:90e3acc479a2 | 175 | * @} |
mbed_official | 157:90e3acc479a2 | 176 | */ |
mbed_official | 157:90e3acc479a2 | 177 | |
mbed_official | 157:90e3acc479a2 | 178 | /** @defgroup SPI_data_size |
mbed_official | 157:90e3acc479a2 | 179 | * @{ |
mbed_official | 157:90e3acc479a2 | 180 | */ |
mbed_official | 157:90e3acc479a2 | 181 | |
mbed_official | 157:90e3acc479a2 | 182 | #define SPI_DataSize_4b ((uint16_t)0x0300) |
mbed_official | 157:90e3acc479a2 | 183 | #define SPI_DataSize_5b ((uint16_t)0x0400) |
mbed_official | 157:90e3acc479a2 | 184 | #define SPI_DataSize_6b ((uint16_t)0x0500) |
mbed_official | 157:90e3acc479a2 | 185 | #define SPI_DataSize_7b ((uint16_t)0x0600) |
mbed_official | 157:90e3acc479a2 | 186 | #define SPI_DataSize_8b ((uint16_t)0x0700) |
mbed_official | 157:90e3acc479a2 | 187 | #define SPI_DataSize_9b ((uint16_t)0x0800) |
mbed_official | 157:90e3acc479a2 | 188 | #define SPI_DataSize_10b ((uint16_t)0x0900) |
mbed_official | 157:90e3acc479a2 | 189 | #define SPI_DataSize_11b ((uint16_t)0x0A00) |
mbed_official | 157:90e3acc479a2 | 190 | #define SPI_DataSize_12b ((uint16_t)0x0B00) |
mbed_official | 157:90e3acc479a2 | 191 | #define SPI_DataSize_13b ((uint16_t)0x0C00) |
mbed_official | 157:90e3acc479a2 | 192 | #define SPI_DataSize_14b ((uint16_t)0x0D00) |
mbed_official | 157:90e3acc479a2 | 193 | #define SPI_DataSize_15b ((uint16_t)0x0E00) |
mbed_official | 157:90e3acc479a2 | 194 | #define SPI_DataSize_16b ((uint16_t)0x0F00) |
mbed_official | 157:90e3acc479a2 | 195 | #define IS_SPI_DATA_SIZE(SIZE) (((SIZE) == SPI_DataSize_4b) || \ |
mbed_official | 157:90e3acc479a2 | 196 | ((SIZE) == SPI_DataSize_5b) || \ |
mbed_official | 157:90e3acc479a2 | 197 | ((SIZE) == SPI_DataSize_6b) || \ |
mbed_official | 157:90e3acc479a2 | 198 | ((SIZE) == SPI_DataSize_7b) || \ |
mbed_official | 157:90e3acc479a2 | 199 | ((SIZE) == SPI_DataSize_8b) || \ |
mbed_official | 157:90e3acc479a2 | 200 | ((SIZE) == SPI_DataSize_9b) || \ |
mbed_official | 157:90e3acc479a2 | 201 | ((SIZE) == SPI_DataSize_10b) || \ |
mbed_official | 157:90e3acc479a2 | 202 | ((SIZE) == SPI_DataSize_11b) || \ |
mbed_official | 157:90e3acc479a2 | 203 | ((SIZE) == SPI_DataSize_12b) || \ |
mbed_official | 157:90e3acc479a2 | 204 | ((SIZE) == SPI_DataSize_13b) || \ |
mbed_official | 157:90e3acc479a2 | 205 | ((SIZE) == SPI_DataSize_14b) || \ |
mbed_official | 157:90e3acc479a2 | 206 | ((SIZE) == SPI_DataSize_15b) || \ |
mbed_official | 157:90e3acc479a2 | 207 | ((SIZE) == SPI_DataSize_16b)) |
mbed_official | 157:90e3acc479a2 | 208 | /** |
mbed_official | 157:90e3acc479a2 | 209 | * @} |
mbed_official | 157:90e3acc479a2 | 210 | */ |
mbed_official | 157:90e3acc479a2 | 211 | |
mbed_official | 157:90e3acc479a2 | 212 | /** @defgroup SPI_CRC_length |
mbed_official | 157:90e3acc479a2 | 213 | * @{ |
mbed_official | 157:90e3acc479a2 | 214 | */ |
mbed_official | 157:90e3acc479a2 | 215 | |
mbed_official | 157:90e3acc479a2 | 216 | #define SPI_CRCLength_8b ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 217 | #define SPI_CRCLength_16b ((uint16_t)0x0800) |
mbed_official | 157:90e3acc479a2 | 218 | #define IS_SPI_CRC_LENGTH(LENGTH) (((LENGTH) == SPI_CRCLength_8b) || \ |
mbed_official | 157:90e3acc479a2 | 219 | ((LENGTH) == SPI_CRCLength_16b)) |
mbed_official | 157:90e3acc479a2 | 220 | /** |
mbed_official | 157:90e3acc479a2 | 221 | * @} |
mbed_official | 157:90e3acc479a2 | 222 | */ |
mbed_official | 157:90e3acc479a2 | 223 | |
mbed_official | 157:90e3acc479a2 | 224 | /** @defgroup SPI_Clock_Polarity |
mbed_official | 157:90e3acc479a2 | 225 | * @{ |
mbed_official | 157:90e3acc479a2 | 226 | */ |
mbed_official | 157:90e3acc479a2 | 227 | |
mbed_official | 157:90e3acc479a2 | 228 | #define SPI_CPOL_Low ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 229 | #define SPI_CPOL_High ((uint16_t)0x0002) |
mbed_official | 157:90e3acc479a2 | 230 | #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_CPOL_Low) || \ |
mbed_official | 157:90e3acc479a2 | 231 | ((CPOL) == SPI_CPOL_High)) |
mbed_official | 157:90e3acc479a2 | 232 | /** |
mbed_official | 157:90e3acc479a2 | 233 | * @} |
mbed_official | 157:90e3acc479a2 | 234 | */ |
mbed_official | 157:90e3acc479a2 | 235 | |
mbed_official | 157:90e3acc479a2 | 236 | /** @defgroup SPI_Clock_Phase |
mbed_official | 157:90e3acc479a2 | 237 | * @{ |
mbed_official | 157:90e3acc479a2 | 238 | */ |
mbed_official | 157:90e3acc479a2 | 239 | |
mbed_official | 157:90e3acc479a2 | 240 | #define SPI_CPHA_1Edge ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 241 | #define SPI_CPHA_2Edge ((uint16_t)0x0001) |
mbed_official | 157:90e3acc479a2 | 242 | #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_CPHA_1Edge) || \ |
mbed_official | 157:90e3acc479a2 | 243 | ((CPHA) == SPI_CPHA_2Edge)) |
mbed_official | 157:90e3acc479a2 | 244 | /** |
mbed_official | 157:90e3acc479a2 | 245 | * @} |
mbed_official | 157:90e3acc479a2 | 246 | */ |
mbed_official | 157:90e3acc479a2 | 247 | |
mbed_official | 157:90e3acc479a2 | 248 | /** @defgroup SPI_Slave_Select_management |
mbed_official | 157:90e3acc479a2 | 249 | * @{ |
mbed_official | 157:90e3acc479a2 | 250 | */ |
mbed_official | 157:90e3acc479a2 | 251 | |
mbed_official | 157:90e3acc479a2 | 252 | #define SPI_NSS_Soft ((uint16_t)0x0200) |
mbed_official | 157:90e3acc479a2 | 253 | #define SPI_NSS_Hard ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 254 | #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_Soft) || \ |
mbed_official | 157:90e3acc479a2 | 255 | ((NSS) == SPI_NSS_Hard)) |
mbed_official | 157:90e3acc479a2 | 256 | /** |
mbed_official | 157:90e3acc479a2 | 257 | * @} |
mbed_official | 157:90e3acc479a2 | 258 | */ |
mbed_official | 157:90e3acc479a2 | 259 | |
mbed_official | 157:90e3acc479a2 | 260 | /** @defgroup SPI_BaudRate_Prescaler |
mbed_official | 157:90e3acc479a2 | 261 | * @{ |
mbed_official | 157:90e3acc479a2 | 262 | */ |
mbed_official | 157:90e3acc479a2 | 263 | |
mbed_official | 157:90e3acc479a2 | 264 | #define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 265 | #define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) |
mbed_official | 157:90e3acc479a2 | 266 | #define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010) |
mbed_official | 157:90e3acc479a2 | 267 | #define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018) |
mbed_official | 157:90e3acc479a2 | 268 | #define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020) |
mbed_official | 157:90e3acc479a2 | 269 | #define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028) |
mbed_official | 157:90e3acc479a2 | 270 | #define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030) |
mbed_official | 157:90e3acc479a2 | 271 | #define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) |
mbed_official | 157:90e3acc479a2 | 272 | #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BaudRatePrescaler_2) || \ |
mbed_official | 157:90e3acc479a2 | 273 | ((PRESCALER) == SPI_BaudRatePrescaler_4) || \ |
mbed_official | 157:90e3acc479a2 | 274 | ((PRESCALER) == SPI_BaudRatePrescaler_8) || \ |
mbed_official | 157:90e3acc479a2 | 275 | ((PRESCALER) == SPI_BaudRatePrescaler_16) || \ |
mbed_official | 157:90e3acc479a2 | 276 | ((PRESCALER) == SPI_BaudRatePrescaler_32) || \ |
mbed_official | 157:90e3acc479a2 | 277 | ((PRESCALER) == SPI_BaudRatePrescaler_64) || \ |
mbed_official | 157:90e3acc479a2 | 278 | ((PRESCALER) == SPI_BaudRatePrescaler_128) || \ |
mbed_official | 157:90e3acc479a2 | 279 | ((PRESCALER) == SPI_BaudRatePrescaler_256)) |
mbed_official | 157:90e3acc479a2 | 280 | /** |
mbed_official | 157:90e3acc479a2 | 281 | * @} |
mbed_official | 157:90e3acc479a2 | 282 | */ |
mbed_official | 157:90e3acc479a2 | 283 | |
mbed_official | 157:90e3acc479a2 | 284 | /** @defgroup SPI_MSB_LSB_transmission |
mbed_official | 157:90e3acc479a2 | 285 | * @{ |
mbed_official | 157:90e3acc479a2 | 286 | */ |
mbed_official | 157:90e3acc479a2 | 287 | |
mbed_official | 157:90e3acc479a2 | 288 | #define SPI_FirstBit_MSB ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 289 | #define SPI_FirstBit_LSB ((uint16_t)0x0080) |
mbed_official | 157:90e3acc479a2 | 290 | #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FirstBit_MSB) || \ |
mbed_official | 157:90e3acc479a2 | 291 | ((BIT) == SPI_FirstBit_LSB)) |
mbed_official | 157:90e3acc479a2 | 292 | /** |
mbed_official | 157:90e3acc479a2 | 293 | * @} |
mbed_official | 157:90e3acc479a2 | 294 | */ |
mbed_official | 157:90e3acc479a2 | 295 | |
mbed_official | 157:90e3acc479a2 | 296 | /** @defgroup I2S_Mode |
mbed_official | 157:90e3acc479a2 | 297 | * @{ |
mbed_official | 157:90e3acc479a2 | 298 | */ |
mbed_official | 157:90e3acc479a2 | 299 | |
mbed_official | 157:90e3acc479a2 | 300 | #define I2S_Mode_SlaveTx ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 301 | #define I2S_Mode_SlaveRx ((uint16_t)0x0100) |
mbed_official | 157:90e3acc479a2 | 302 | #define I2S_Mode_MasterTx ((uint16_t)0x0200) |
mbed_official | 157:90e3acc479a2 | 303 | #define I2S_Mode_MasterRx ((uint16_t)0x0300) |
mbed_official | 157:90e3acc479a2 | 304 | #define IS_I2S_MODE(MODE) (((MODE) == I2S_Mode_SlaveTx) || \ |
mbed_official | 157:90e3acc479a2 | 305 | ((MODE) == I2S_Mode_SlaveRx) || \ |
mbed_official | 157:90e3acc479a2 | 306 | ((MODE) == I2S_Mode_MasterTx)|| \ |
mbed_official | 157:90e3acc479a2 | 307 | ((MODE) == I2S_Mode_MasterRx)) |
mbed_official | 157:90e3acc479a2 | 308 | /** |
mbed_official | 157:90e3acc479a2 | 309 | * @} |
mbed_official | 157:90e3acc479a2 | 310 | */ |
mbed_official | 157:90e3acc479a2 | 311 | |
mbed_official | 157:90e3acc479a2 | 312 | /** @defgroup I2S_Standard |
mbed_official | 157:90e3acc479a2 | 313 | * @{ |
mbed_official | 157:90e3acc479a2 | 314 | */ |
mbed_official | 157:90e3acc479a2 | 315 | |
mbed_official | 157:90e3acc479a2 | 316 | #define I2S_Standard_Phillips ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 317 | #define I2S_Standard_MSB ((uint16_t)0x0010) |
mbed_official | 157:90e3acc479a2 | 318 | #define I2S_Standard_LSB ((uint16_t)0x0020) |
mbed_official | 157:90e3acc479a2 | 319 | #define I2S_Standard_PCMShort ((uint16_t)0x0030) |
mbed_official | 157:90e3acc479a2 | 320 | #define I2S_Standard_PCMLong ((uint16_t)0x00B0) |
mbed_official | 157:90e3acc479a2 | 321 | #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_Standard_Phillips) || \ |
mbed_official | 157:90e3acc479a2 | 322 | ((STANDARD) == I2S_Standard_MSB) || \ |
mbed_official | 157:90e3acc479a2 | 323 | ((STANDARD) == I2S_Standard_LSB) || \ |
mbed_official | 157:90e3acc479a2 | 324 | ((STANDARD) == I2S_Standard_PCMShort) || \ |
mbed_official | 157:90e3acc479a2 | 325 | ((STANDARD) == I2S_Standard_PCMLong)) |
mbed_official | 157:90e3acc479a2 | 326 | /** |
mbed_official | 157:90e3acc479a2 | 327 | * @} |
mbed_official | 157:90e3acc479a2 | 328 | */ |
mbed_official | 157:90e3acc479a2 | 329 | |
mbed_official | 157:90e3acc479a2 | 330 | /** @defgroup I2S_Data_Format |
mbed_official | 157:90e3acc479a2 | 331 | * @{ |
mbed_official | 157:90e3acc479a2 | 332 | */ |
mbed_official | 157:90e3acc479a2 | 333 | |
mbed_official | 157:90e3acc479a2 | 334 | #define I2S_DataFormat_16b ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 335 | #define I2S_DataFormat_16bextended ((uint16_t)0x0001) |
mbed_official | 157:90e3acc479a2 | 336 | #define I2S_DataFormat_24b ((uint16_t)0x0003) |
mbed_official | 157:90e3acc479a2 | 337 | #define I2S_DataFormat_32b ((uint16_t)0x0005) |
mbed_official | 157:90e3acc479a2 | 338 | #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DataFormat_16b) || \ |
mbed_official | 157:90e3acc479a2 | 339 | ((FORMAT) == I2S_DataFormat_16bextended) || \ |
mbed_official | 157:90e3acc479a2 | 340 | ((FORMAT) == I2S_DataFormat_24b) || \ |
mbed_official | 157:90e3acc479a2 | 341 | ((FORMAT) == I2S_DataFormat_32b)) |
mbed_official | 157:90e3acc479a2 | 342 | /** |
mbed_official | 157:90e3acc479a2 | 343 | * @} |
mbed_official | 157:90e3acc479a2 | 344 | */ |
mbed_official | 157:90e3acc479a2 | 345 | |
mbed_official | 157:90e3acc479a2 | 346 | /** @defgroup I2S_MCLK_Output |
mbed_official | 157:90e3acc479a2 | 347 | * @{ |
mbed_official | 157:90e3acc479a2 | 348 | */ |
mbed_official | 157:90e3acc479a2 | 349 | |
mbed_official | 157:90e3acc479a2 | 350 | #define I2S_MCLKOutput_Enable ((uint16_t)0x0200) |
mbed_official | 157:90e3acc479a2 | 351 | #define I2S_MCLKOutput_Disable ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 352 | #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOutput_Enable) || \ |
mbed_official | 157:90e3acc479a2 | 353 | ((OUTPUT) == I2S_MCLKOutput_Disable)) |
mbed_official | 157:90e3acc479a2 | 354 | /** |
mbed_official | 157:90e3acc479a2 | 355 | * @} |
mbed_official | 157:90e3acc479a2 | 356 | */ |
mbed_official | 157:90e3acc479a2 | 357 | |
mbed_official | 157:90e3acc479a2 | 358 | /** @defgroup I2S_Audio_Frequency |
mbed_official | 157:90e3acc479a2 | 359 | * @{ |
mbed_official | 157:90e3acc479a2 | 360 | */ |
mbed_official | 157:90e3acc479a2 | 361 | |
mbed_official | 157:90e3acc479a2 | 362 | #define I2S_AudioFreq_192k ((uint32_t)192000) |
mbed_official | 157:90e3acc479a2 | 363 | #define I2S_AudioFreq_96k ((uint32_t)96000) |
mbed_official | 157:90e3acc479a2 | 364 | #define I2S_AudioFreq_48k ((uint32_t)48000) |
mbed_official | 157:90e3acc479a2 | 365 | #define I2S_AudioFreq_44k ((uint32_t)44100) |
mbed_official | 157:90e3acc479a2 | 366 | #define I2S_AudioFreq_32k ((uint32_t)32000) |
mbed_official | 157:90e3acc479a2 | 367 | #define I2S_AudioFreq_22k ((uint32_t)22050) |
mbed_official | 157:90e3acc479a2 | 368 | #define I2S_AudioFreq_16k ((uint32_t)16000) |
mbed_official | 157:90e3acc479a2 | 369 | #define I2S_AudioFreq_11k ((uint32_t)11025) |
mbed_official | 157:90e3acc479a2 | 370 | #define I2S_AudioFreq_8k ((uint32_t)8000) |
mbed_official | 157:90e3acc479a2 | 371 | #define I2S_AudioFreq_Default ((uint32_t)2) |
mbed_official | 157:90e3acc479a2 | 372 | |
mbed_official | 157:90e3acc479a2 | 373 | #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AudioFreq_8k) && \ |
mbed_official | 157:90e3acc479a2 | 374 | ((FREQ) <= I2S_AudioFreq_192k)) || \ |
mbed_official | 157:90e3acc479a2 | 375 | ((FREQ) == I2S_AudioFreq_Default)) |
mbed_official | 157:90e3acc479a2 | 376 | /** |
mbed_official | 157:90e3acc479a2 | 377 | * @} |
mbed_official | 157:90e3acc479a2 | 378 | */ |
mbed_official | 157:90e3acc479a2 | 379 | |
mbed_official | 157:90e3acc479a2 | 380 | /** @defgroup I2S_Clock_Polarity |
mbed_official | 157:90e3acc479a2 | 381 | * @{ |
mbed_official | 157:90e3acc479a2 | 382 | */ |
mbed_official | 157:90e3acc479a2 | 383 | |
mbed_official | 157:90e3acc479a2 | 384 | #define I2S_CPOL_Low ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 385 | #define I2S_CPOL_High ((uint16_t)0x0008) |
mbed_official | 157:90e3acc479a2 | 386 | #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_Low) || \ |
mbed_official | 157:90e3acc479a2 | 387 | ((CPOL) == I2S_CPOL_High)) |
mbed_official | 157:90e3acc479a2 | 388 | /** |
mbed_official | 157:90e3acc479a2 | 389 | * @} |
mbed_official | 157:90e3acc479a2 | 390 | */ |
mbed_official | 157:90e3acc479a2 | 391 | |
mbed_official | 157:90e3acc479a2 | 392 | /** @defgroup SPI_FIFO_reception_threshold |
mbed_official | 157:90e3acc479a2 | 393 | * @{ |
mbed_official | 157:90e3acc479a2 | 394 | */ |
mbed_official | 157:90e3acc479a2 | 395 | |
mbed_official | 157:90e3acc479a2 | 396 | #define SPI_RxFIFOThreshold_HF ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 397 | #define SPI_RxFIFOThreshold_QF ((uint16_t)0x1000) |
mbed_official | 157:90e3acc479a2 | 398 | #define IS_SPI_RX_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SPI_RxFIFOThreshold_HF) || \ |
mbed_official | 157:90e3acc479a2 | 399 | ((THRESHOLD) == SPI_RxFIFOThreshold_QF)) |
mbed_official | 157:90e3acc479a2 | 400 | /** |
mbed_official | 157:90e3acc479a2 | 401 | * @} |
mbed_official | 157:90e3acc479a2 | 402 | */ |
mbed_official | 157:90e3acc479a2 | 403 | |
mbed_official | 157:90e3acc479a2 | 404 | /** @defgroup SPI_I2S_DMA_transfer_requests |
mbed_official | 157:90e3acc479a2 | 405 | * @{ |
mbed_official | 157:90e3acc479a2 | 406 | */ |
mbed_official | 157:90e3acc479a2 | 407 | |
mbed_official | 157:90e3acc479a2 | 408 | #define SPI_I2S_DMAReq_Tx ((uint16_t)0x0002) |
mbed_official | 157:90e3acc479a2 | 409 | #define SPI_I2S_DMAReq_Rx ((uint16_t)0x0001) |
mbed_official | 157:90e3acc479a2 | 410 | #define IS_SPI_I2S_DMA_REQ(REQ) ((((REQ) & (uint16_t)0xFFFC) == 0x00) && ((REQ) != 0x00)) |
mbed_official | 157:90e3acc479a2 | 411 | /** |
mbed_official | 157:90e3acc479a2 | 412 | * @} |
mbed_official | 157:90e3acc479a2 | 413 | */ |
mbed_official | 157:90e3acc479a2 | 414 | |
mbed_official | 157:90e3acc479a2 | 415 | /** @defgroup SPI_last_DMA_transfers |
mbed_official | 157:90e3acc479a2 | 416 | * @{ |
mbed_official | 157:90e3acc479a2 | 417 | */ |
mbed_official | 157:90e3acc479a2 | 418 | |
mbed_official | 157:90e3acc479a2 | 419 | #define SPI_LastDMATransfer_TxEvenRxEven ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 420 | #define SPI_LastDMATransfer_TxOddRxEven ((uint16_t)0x4000) |
mbed_official | 157:90e3acc479a2 | 421 | #define SPI_LastDMATransfer_TxEvenRxOdd ((uint16_t)0x2000) |
mbed_official | 157:90e3acc479a2 | 422 | #define SPI_LastDMATransfer_TxOddRxOdd ((uint16_t)0x6000) |
mbed_official | 157:90e3acc479a2 | 423 | #define IS_SPI_LAST_DMA_TRANSFER(TRANSFER) (((TRANSFER) == SPI_LastDMATransfer_TxEvenRxEven) || \ |
mbed_official | 157:90e3acc479a2 | 424 | ((TRANSFER) == SPI_LastDMATransfer_TxOddRxEven) || \ |
mbed_official | 157:90e3acc479a2 | 425 | ((TRANSFER) == SPI_LastDMATransfer_TxEvenRxOdd) || \ |
mbed_official | 157:90e3acc479a2 | 426 | ((TRANSFER) == SPI_LastDMATransfer_TxOddRxOdd)) |
mbed_official | 157:90e3acc479a2 | 427 | /** |
mbed_official | 157:90e3acc479a2 | 428 | * @} |
mbed_official | 157:90e3acc479a2 | 429 | */ |
mbed_official | 157:90e3acc479a2 | 430 | /** @defgroup SPI_NSS_internal_software_management |
mbed_official | 157:90e3acc479a2 | 431 | * @{ |
mbed_official | 157:90e3acc479a2 | 432 | */ |
mbed_official | 157:90e3acc479a2 | 433 | |
mbed_official | 157:90e3acc479a2 | 434 | #define SPI_NSSInternalSoft_Set ((uint16_t)0x0100) |
mbed_official | 157:90e3acc479a2 | 435 | #define SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF) |
mbed_official | 157:90e3acc479a2 | 436 | #define IS_SPI_NSS_INTERNAL(INTERNAL) (((INTERNAL) == SPI_NSSInternalSoft_Set) || \ |
mbed_official | 157:90e3acc479a2 | 437 | ((INTERNAL) == SPI_NSSInternalSoft_Reset)) |
mbed_official | 157:90e3acc479a2 | 438 | /** |
mbed_official | 157:90e3acc479a2 | 439 | * @} |
mbed_official | 157:90e3acc479a2 | 440 | */ |
mbed_official | 157:90e3acc479a2 | 441 | |
mbed_official | 157:90e3acc479a2 | 442 | /** @defgroup SPI_CRC_Transmit_Receive |
mbed_official | 157:90e3acc479a2 | 443 | * @{ |
mbed_official | 157:90e3acc479a2 | 444 | */ |
mbed_official | 157:90e3acc479a2 | 445 | |
mbed_official | 157:90e3acc479a2 | 446 | #define SPI_CRC_Tx ((uint8_t)0x00) |
mbed_official | 157:90e3acc479a2 | 447 | #define SPI_CRC_Rx ((uint8_t)0x01) |
mbed_official | 157:90e3acc479a2 | 448 | #define IS_SPI_CRC(CRC) (((CRC) == SPI_CRC_Tx) || ((CRC) == SPI_CRC_Rx)) |
mbed_official | 157:90e3acc479a2 | 449 | /** |
mbed_official | 157:90e3acc479a2 | 450 | * @} |
mbed_official | 157:90e3acc479a2 | 451 | */ |
mbed_official | 157:90e3acc479a2 | 452 | |
mbed_official | 157:90e3acc479a2 | 453 | /** @defgroup SPI_direction_transmit_receive |
mbed_official | 157:90e3acc479a2 | 454 | * @{ |
mbed_official | 157:90e3acc479a2 | 455 | */ |
mbed_official | 157:90e3acc479a2 | 456 | |
mbed_official | 157:90e3acc479a2 | 457 | #define SPI_Direction_Rx ((uint16_t)0xBFFF) |
mbed_official | 157:90e3acc479a2 | 458 | #define SPI_Direction_Tx ((uint16_t)0x4000) |
mbed_official | 157:90e3acc479a2 | 459 | #define IS_SPI_DIRECTION(DIRECTION) (((DIRECTION) == SPI_Direction_Rx) || \ |
mbed_official | 157:90e3acc479a2 | 460 | ((DIRECTION) == SPI_Direction_Tx)) |
mbed_official | 157:90e3acc479a2 | 461 | /** |
mbed_official | 157:90e3acc479a2 | 462 | * @} |
mbed_official | 157:90e3acc479a2 | 463 | */ |
mbed_official | 157:90e3acc479a2 | 464 | |
mbed_official | 157:90e3acc479a2 | 465 | /** @defgroup SPI_I2S_interrupts_definition |
mbed_official | 157:90e3acc479a2 | 466 | * @{ |
mbed_official | 157:90e3acc479a2 | 467 | */ |
mbed_official | 157:90e3acc479a2 | 468 | |
mbed_official | 157:90e3acc479a2 | 469 | #define SPI_I2S_IT_TXE ((uint8_t)0x71) |
mbed_official | 157:90e3acc479a2 | 470 | #define SPI_I2S_IT_RXNE ((uint8_t)0x60) |
mbed_official | 157:90e3acc479a2 | 471 | #define SPI_I2S_IT_ERR ((uint8_t)0x50) |
mbed_official | 157:90e3acc479a2 | 472 | |
mbed_official | 157:90e3acc479a2 | 473 | #define IS_SPI_I2S_CONFIG_IT(IT) (((IT) == SPI_I2S_IT_TXE) || \ |
mbed_official | 157:90e3acc479a2 | 474 | ((IT) == SPI_I2S_IT_RXNE) || \ |
mbed_official | 157:90e3acc479a2 | 475 | ((IT) == SPI_I2S_IT_ERR)) |
mbed_official | 157:90e3acc479a2 | 476 | |
mbed_official | 157:90e3acc479a2 | 477 | #define I2S_IT_UDR ((uint8_t)0x53) |
mbed_official | 157:90e3acc479a2 | 478 | #define SPI_IT_MODF ((uint8_t)0x55) |
mbed_official | 157:90e3acc479a2 | 479 | #define SPI_I2S_IT_OVR ((uint8_t)0x56) |
mbed_official | 157:90e3acc479a2 | 480 | #define SPI_I2S_IT_FRE ((uint8_t)0x58) |
mbed_official | 157:90e3acc479a2 | 481 | |
mbed_official | 157:90e3acc479a2 | 482 | #define IS_SPI_I2S_GET_IT(IT) (((IT) == SPI_I2S_IT_RXNE) || ((IT) == SPI_I2S_IT_TXE) || \ |
mbed_official | 157:90e3acc479a2 | 483 | ((IT) == SPI_I2S_IT_OVR) || ((IT) == SPI_IT_MODF) || \ |
mbed_official | 157:90e3acc479a2 | 484 | ((IT) == SPI_I2S_IT_FRE)|| ((IT) == I2S_IT_UDR)) |
mbed_official | 157:90e3acc479a2 | 485 | /** |
mbed_official | 157:90e3acc479a2 | 486 | * @} |
mbed_official | 157:90e3acc479a2 | 487 | */ |
mbed_official | 157:90e3acc479a2 | 488 | |
mbed_official | 157:90e3acc479a2 | 489 | |
mbed_official | 157:90e3acc479a2 | 490 | /** @defgroup SPI_transmission_fifo_status_level |
mbed_official | 157:90e3acc479a2 | 491 | * @{ |
mbed_official | 157:90e3acc479a2 | 492 | */ |
mbed_official | 157:90e3acc479a2 | 493 | |
mbed_official | 157:90e3acc479a2 | 494 | #define SPI_TransmissionFIFOStatus_Empty ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 495 | #define SPI_TransmissionFIFOStatus_1QuarterFull ((uint16_t)0x0800) |
mbed_official | 157:90e3acc479a2 | 496 | #define SPI_TransmissionFIFOStatus_HalfFull ((uint16_t)0x1000) |
mbed_official | 157:90e3acc479a2 | 497 | #define SPI_TransmissionFIFOStatus_Full ((uint16_t)0x1800) |
mbed_official | 157:90e3acc479a2 | 498 | |
mbed_official | 157:90e3acc479a2 | 499 | /** |
mbed_official | 157:90e3acc479a2 | 500 | * @} |
mbed_official | 157:90e3acc479a2 | 501 | */ |
mbed_official | 157:90e3acc479a2 | 502 | |
mbed_official | 157:90e3acc479a2 | 503 | /** @defgroup SPI_reception_fifo_status_level |
mbed_official | 157:90e3acc479a2 | 504 | * @{ |
mbed_official | 157:90e3acc479a2 | 505 | */ |
mbed_official | 157:90e3acc479a2 | 506 | #define SPI_ReceptionFIFOStatus_Empty ((uint16_t)0x0000) |
mbed_official | 157:90e3acc479a2 | 507 | #define SPI_ReceptionFIFOStatus_1QuarterFull ((uint16_t)0x0200) |
mbed_official | 157:90e3acc479a2 | 508 | #define SPI_ReceptionFIFOStatus_HalfFull ((uint16_t)0x0400) |
mbed_official | 157:90e3acc479a2 | 509 | #define SPI_ReceptionFIFOStatus_Full ((uint16_t)0x0600) |
mbed_official | 157:90e3acc479a2 | 510 | |
mbed_official | 157:90e3acc479a2 | 511 | /** |
mbed_official | 157:90e3acc479a2 | 512 | * @} |
mbed_official | 157:90e3acc479a2 | 513 | */ |
mbed_official | 157:90e3acc479a2 | 514 | |
mbed_official | 157:90e3acc479a2 | 515 | |
mbed_official | 157:90e3acc479a2 | 516 | /** @defgroup SPI_I2S_flags_definition |
mbed_official | 157:90e3acc479a2 | 517 | * @{ |
mbed_official | 157:90e3acc479a2 | 518 | */ |
mbed_official | 157:90e3acc479a2 | 519 | |
mbed_official | 157:90e3acc479a2 | 520 | #define SPI_I2S_FLAG_RXNE ((uint16_t)0x0001) |
mbed_official | 157:90e3acc479a2 | 521 | #define SPI_I2S_FLAG_TXE ((uint16_t)0x0002) |
mbed_official | 157:90e3acc479a2 | 522 | #define I2S_FLAG_CHSIDE ((uint16_t)0x0004) |
mbed_official | 157:90e3acc479a2 | 523 | #define I2S_FLAG_UDR ((uint16_t)0x0008) |
mbed_official | 157:90e3acc479a2 | 524 | #define SPI_FLAG_CRCERR ((uint16_t)0x0010) |
mbed_official | 157:90e3acc479a2 | 525 | #define SPI_FLAG_MODF ((uint16_t)0x0020) |
mbed_official | 157:90e3acc479a2 | 526 | #define SPI_I2S_FLAG_OVR ((uint16_t)0x0040) |
mbed_official | 157:90e3acc479a2 | 527 | #define SPI_I2S_FLAG_BSY ((uint16_t)0x0080) |
mbed_official | 157:90e3acc479a2 | 528 | #define SPI_I2S_FLAG_FRE ((uint16_t)0x0100) |
mbed_official | 157:90e3acc479a2 | 529 | |
mbed_official | 157:90e3acc479a2 | 530 | |
mbed_official | 157:90e3acc479a2 | 531 | |
mbed_official | 157:90e3acc479a2 | 532 | #define IS_SPI_CLEAR_FLAG(FLAG) (((FLAG) == SPI_FLAG_CRCERR)) |
mbed_official | 157:90e3acc479a2 | 533 | #define IS_SPI_I2S_GET_FLAG(FLAG) (((FLAG) == SPI_I2S_FLAG_BSY) || ((FLAG) == SPI_I2S_FLAG_OVR) || \ |
mbed_official | 157:90e3acc479a2 | 534 | ((FLAG) == SPI_FLAG_MODF) || ((FLAG) == SPI_FLAG_CRCERR) || \ |
mbed_official | 157:90e3acc479a2 | 535 | ((FLAG) == SPI_I2S_FLAG_TXE) || ((FLAG) == SPI_I2S_FLAG_RXNE)|| \ |
mbed_official | 157:90e3acc479a2 | 536 | ((FLAG) == SPI_I2S_FLAG_FRE)|| ((FLAG) == I2S_FLAG_CHSIDE)|| \ |
mbed_official | 157:90e3acc479a2 | 537 | ((FLAG) == I2S_FLAG_UDR)) |
mbed_official | 157:90e3acc479a2 | 538 | /** |
mbed_official | 157:90e3acc479a2 | 539 | * @} |
mbed_official | 157:90e3acc479a2 | 540 | */ |
mbed_official | 157:90e3acc479a2 | 541 | |
mbed_official | 157:90e3acc479a2 | 542 | /** @defgroup SPI_CRC_polynomial |
mbed_official | 157:90e3acc479a2 | 543 | * @{ |
mbed_official | 157:90e3acc479a2 | 544 | */ |
mbed_official | 157:90e3acc479a2 | 545 | |
mbed_official | 157:90e3acc479a2 | 546 | #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) ((POLYNOMIAL) >= 0x1) |
mbed_official | 157:90e3acc479a2 | 547 | /** |
mbed_official | 157:90e3acc479a2 | 548 | * @} |
mbed_official | 157:90e3acc479a2 | 549 | */ |
mbed_official | 157:90e3acc479a2 | 550 | |
mbed_official | 157:90e3acc479a2 | 551 | /** |
mbed_official | 157:90e3acc479a2 | 552 | * @} |
mbed_official | 157:90e3acc479a2 | 553 | */ |
mbed_official | 157:90e3acc479a2 | 554 | |
mbed_official | 157:90e3acc479a2 | 555 | /* Exported macro ------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 556 | /* Exported functions ------------------------------------------------------- */ |
mbed_official | 157:90e3acc479a2 | 557 | |
mbed_official | 157:90e3acc479a2 | 558 | /* Function used to set the SPI configuration to the default reset state*******/ |
mbed_official | 157:90e3acc479a2 | 559 | void SPI_I2S_DeInit(SPI_TypeDef* SPIx); |
mbed_official | 157:90e3acc479a2 | 560 | |
mbed_official | 157:90e3acc479a2 | 561 | /* Initialization and Configuration functions *********************************/ |
mbed_official | 157:90e3acc479a2 | 562 | void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct); |
mbed_official | 157:90e3acc479a2 | 563 | void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct); |
mbed_official | 157:90e3acc479a2 | 564 | void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct); |
mbed_official | 157:90e3acc479a2 | 565 | void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct); |
mbed_official | 157:90e3acc479a2 | 566 | void SPI_TIModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 567 | void SPI_NSSPulseModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 568 | void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 569 | void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 570 | void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize); |
mbed_official | 157:90e3acc479a2 | 571 | void SPI_RxFIFOThresholdConfig(SPI_TypeDef* SPIx, uint16_t SPI_RxFIFOThreshold); |
mbed_official | 157:90e3acc479a2 | 572 | void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction); |
mbed_official | 157:90e3acc479a2 | 573 | void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft); |
mbed_official | 157:90e3acc479a2 | 574 | void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 575 | void I2S_FullDuplexConfig(SPI_TypeDef* I2Sxext, I2S_InitTypeDef* I2S_InitStruct); |
mbed_official | 157:90e3acc479a2 | 576 | |
mbed_official | 157:90e3acc479a2 | 577 | /* Data transfers functions ***************************************************/ |
mbed_official | 157:90e3acc479a2 | 578 | void SPI_SendData8(SPI_TypeDef* SPIx, uint8_t Data); |
mbed_official | 157:90e3acc479a2 | 579 | void SPI_I2S_SendData16(SPI_TypeDef* SPIx, uint16_t Data); |
mbed_official | 157:90e3acc479a2 | 580 | uint8_t SPI_ReceiveData8(SPI_TypeDef* SPIx); |
mbed_official | 157:90e3acc479a2 | 581 | uint16_t SPI_I2S_ReceiveData16(SPI_TypeDef* SPIx); |
mbed_official | 157:90e3acc479a2 | 582 | |
mbed_official | 157:90e3acc479a2 | 583 | /* Hardware CRC Calculation functions *****************************************/ |
mbed_official | 157:90e3acc479a2 | 584 | void SPI_CRCLengthConfig(SPI_TypeDef* SPIx, uint16_t SPI_CRCLength); |
mbed_official | 157:90e3acc479a2 | 585 | void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 586 | void SPI_TransmitCRC(SPI_TypeDef* SPIx); |
mbed_official | 157:90e3acc479a2 | 587 | uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC); |
mbed_official | 157:90e3acc479a2 | 588 | uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx); |
mbed_official | 157:90e3acc479a2 | 589 | |
mbed_official | 157:90e3acc479a2 | 590 | /* DMA transfers management functions *****************************************/ |
mbed_official | 157:90e3acc479a2 | 591 | void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 592 | void SPI_LastDMATransferCmd(SPI_TypeDef* SPIx, uint16_t SPI_LastDMATransfer); |
mbed_official | 157:90e3acc479a2 | 593 | |
mbed_official | 157:90e3acc479a2 | 594 | /* Interrupts and flags management functions **********************************/ |
mbed_official | 157:90e3acc479a2 | 595 | void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState); |
mbed_official | 157:90e3acc479a2 | 596 | uint16_t SPI_GetTransmissionFIFOStatus(SPI_TypeDef* SPIx); |
mbed_official | 157:90e3acc479a2 | 597 | uint16_t SPI_GetReceptionFIFOStatus(SPI_TypeDef* SPIx); |
mbed_official | 157:90e3acc479a2 | 598 | FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG); |
mbed_official | 157:90e3acc479a2 | 599 | void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG); |
mbed_official | 157:90e3acc479a2 | 600 | ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT); |
mbed_official | 157:90e3acc479a2 | 601 | |
mbed_official | 157:90e3acc479a2 | 602 | #ifdef __cplusplus |
mbed_official | 157:90e3acc479a2 | 603 | } |
mbed_official | 157:90e3acc479a2 | 604 | #endif |
mbed_official | 157:90e3acc479a2 | 605 | |
mbed_official | 157:90e3acc479a2 | 606 | #endif /*__STM32F30x_SPI_H */ |
mbed_official | 157:90e3acc479a2 | 607 | |
mbed_official | 157:90e3acc479a2 | 608 | /** |
mbed_official | 157:90e3acc479a2 | 609 | * @} |
mbed_official | 157:90e3acc479a2 | 610 | */ |
mbed_official | 157:90e3acc479a2 | 611 | |
mbed_official | 157:90e3acc479a2 | 612 | /** |
mbed_official | 157:90e3acc479a2 | 613 | * @} |
mbed_official | 157:90e3acc479a2 | 614 | */ |
mbed_official | 157:90e3acc479a2 | 615 | |
mbed_official | 157:90e3acc479a2 | 616 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |