mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/stm32f3xx_hal_spi.h@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 237:f3da66175598
test with CLOCK_SETUP = 0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 237:f3da66175598 | 1 | /** |
mbed_official | 237:f3da66175598 | 2 | ****************************************************************************** |
mbed_official | 237:f3da66175598 | 3 | * @file stm32f3xx_hal_spi.h |
mbed_official | 237:f3da66175598 | 4 | * @author MCD Application Team |
mbed_official | 237:f3da66175598 | 5 | * @version V1.0.1 |
mbed_official | 237:f3da66175598 | 6 | * @date 18-June-2014 |
mbed_official | 237:f3da66175598 | 7 | * @brief Header file of SPI HAL module. |
mbed_official | 237:f3da66175598 | 8 | ****************************************************************************** |
mbed_official | 237:f3da66175598 | 9 | * @attention |
mbed_official | 237:f3da66175598 | 10 | * |
mbed_official | 237:f3da66175598 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 237:f3da66175598 | 12 | * |
mbed_official | 237:f3da66175598 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 237:f3da66175598 | 14 | * are permitted provided that the following conditions are met: |
mbed_official | 237:f3da66175598 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 237:f3da66175598 | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 237:f3da66175598 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 237:f3da66175598 | 18 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 237:f3da66175598 | 19 | * and/or other materials provided with the distribution. |
mbed_official | 237:f3da66175598 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 237:f3da66175598 | 21 | * may be used to endorse or promote products derived from this software |
mbed_official | 237:f3da66175598 | 22 | * without specific prior written permission. |
mbed_official | 237:f3da66175598 | 23 | * |
mbed_official | 237:f3da66175598 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 237:f3da66175598 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 237:f3da66175598 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 237:f3da66175598 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 237:f3da66175598 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 237:f3da66175598 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 237:f3da66175598 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 237:f3da66175598 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 237:f3da66175598 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 237:f3da66175598 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 237:f3da66175598 | 34 | * |
mbed_official | 237:f3da66175598 | 35 | ****************************************************************************** |
mbed_official | 237:f3da66175598 | 36 | */ |
mbed_official | 237:f3da66175598 | 37 | |
mbed_official | 237:f3da66175598 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
mbed_official | 237:f3da66175598 | 39 | #ifndef __STM32F3xx_HAL_SPI_H |
mbed_official | 237:f3da66175598 | 40 | #define __STM32F3xx_HAL_SPI_H |
mbed_official | 237:f3da66175598 | 41 | |
mbed_official | 237:f3da66175598 | 42 | #ifdef __cplusplus |
mbed_official | 237:f3da66175598 | 43 | extern "C" { |
mbed_official | 237:f3da66175598 | 44 | #endif |
mbed_official | 237:f3da66175598 | 45 | |
mbed_official | 237:f3da66175598 | 46 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 47 | #include "stm32f3xx_hal_def.h" |
mbed_official | 237:f3da66175598 | 48 | |
mbed_official | 237:f3da66175598 | 49 | /** @addtogroup STM32F3xx_HAL_Driver |
mbed_official | 237:f3da66175598 | 50 | * @{ |
mbed_official | 237:f3da66175598 | 51 | */ |
mbed_official | 237:f3da66175598 | 52 | |
mbed_official | 237:f3da66175598 | 53 | /** @addtogroup SPI |
mbed_official | 237:f3da66175598 | 54 | * @{ |
mbed_official | 237:f3da66175598 | 55 | */ |
mbed_official | 237:f3da66175598 | 56 | |
mbed_official | 237:f3da66175598 | 57 | /* Exported types ------------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 58 | |
mbed_official | 237:f3da66175598 | 59 | /** |
mbed_official | 237:f3da66175598 | 60 | * @brief SPI Configuration Structure definition |
mbed_official | 237:f3da66175598 | 61 | */ |
mbed_official | 237:f3da66175598 | 62 | typedef struct |
mbed_official | 237:f3da66175598 | 63 | { |
mbed_official | 237:f3da66175598 | 64 | uint32_t Mode; /*!< Specifies the SPI operating mode. |
mbed_official | 237:f3da66175598 | 65 | This parameter can be a value of @ref SPI_mode */ |
mbed_official | 237:f3da66175598 | 66 | |
mbed_official | 237:f3da66175598 | 67 | uint32_t Direction; /*!< Specifies the SPI bidirectional mode state. |
mbed_official | 237:f3da66175598 | 68 | This parameter can be a value of @ref SPI_Direction */ |
mbed_official | 237:f3da66175598 | 69 | |
mbed_official | 237:f3da66175598 | 70 | uint32_t DataSize; /*!< Specifies the SPI data size. |
mbed_official | 237:f3da66175598 | 71 | This parameter can be a value of @ref SPI_data_size */ |
mbed_official | 237:f3da66175598 | 72 | |
mbed_official | 237:f3da66175598 | 73 | uint32_t CLKPolarity; /*!< Specifies the serial clock steady state. |
mbed_official | 237:f3da66175598 | 74 | This parameter can be a value of @ref SPI_Clock_Polarity */ |
mbed_official | 237:f3da66175598 | 75 | |
mbed_official | 237:f3da66175598 | 76 | uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture. |
mbed_official | 237:f3da66175598 | 77 | This parameter can be a value of @ref SPI_Clock_Phase */ |
mbed_official | 237:f3da66175598 | 78 | |
mbed_official | 237:f3da66175598 | 79 | uint32_t NSS; /*!< Specifies whether the NSS signal is managed by |
mbed_official | 237:f3da66175598 | 80 | hardware (NSS pin) or by software using the SSI bit. |
mbed_official | 237:f3da66175598 | 81 | This parameter can be a value of @ref SPI_Slave_Select_management */ |
mbed_official | 237:f3da66175598 | 82 | |
mbed_official | 237:f3da66175598 | 83 | uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be |
mbed_official | 237:f3da66175598 | 84 | used to configure the transmit and receive SCK clock. |
mbed_official | 237:f3da66175598 | 85 | This parameter can be a value of @ref SPI_BaudRate_Prescaler |
mbed_official | 237:f3da66175598 | 86 | @note The communication clock is derived from the master |
mbed_official | 237:f3da66175598 | 87 | clock. The slave clock does not need to be set. */ |
mbed_official | 237:f3da66175598 | 88 | |
mbed_official | 237:f3da66175598 | 89 | uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. |
mbed_official | 237:f3da66175598 | 90 | This parameter can be a value of @ref SPI_MSB_LSB_transmission */ |
mbed_official | 237:f3da66175598 | 91 | |
mbed_official | 237:f3da66175598 | 92 | uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not . |
mbed_official | 237:f3da66175598 | 93 | This parameter can be a value of @ref SPI_TI_mode */ |
mbed_official | 237:f3da66175598 | 94 | |
mbed_official | 237:f3da66175598 | 95 | uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. |
mbed_official | 237:f3da66175598 | 96 | This parameter can be a value of @ref SPI_CRC_Calculation */ |
mbed_official | 237:f3da66175598 | 97 | |
mbed_official | 237:f3da66175598 | 98 | uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. |
mbed_official | 237:f3da66175598 | 99 | This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */ |
mbed_official | 237:f3da66175598 | 100 | |
mbed_official | 237:f3da66175598 | 101 | uint32_t CRCLength; /*!< Specifies the CRC Length used for the CRC calculation. |
mbed_official | 237:f3da66175598 | 102 | CRC Length is only used with Data8 and Data16, not other data size |
mbed_official | 237:f3da66175598 | 103 | This parameter must 0 or 1 or 2*/ |
mbed_official | 237:f3da66175598 | 104 | |
mbed_official | 237:f3da66175598 | 105 | uint32_t NSSPMode; /*!< Specifies whether the NSSP signal is enabled or not . |
mbed_official | 237:f3da66175598 | 106 | This mode is activated by the NSSP bit in the SPIx_CR2 register and |
mbed_official | 237:f3da66175598 | 107 | it takes effect only if the SPI interface is configured as Motorola SPI |
mbed_official | 237:f3da66175598 | 108 | master (FRF=0) with capture on the first edge (SPIx_CR1 CPHA = 0, |
mbed_official | 237:f3da66175598 | 109 | CPOL setting is ignored).. */ |
mbed_official | 237:f3da66175598 | 110 | } SPI_InitTypeDef; |
mbed_official | 237:f3da66175598 | 111 | |
mbed_official | 237:f3da66175598 | 112 | /** |
mbed_official | 237:f3da66175598 | 113 | * @brief HAL State structures definition |
mbed_official | 237:f3da66175598 | 114 | */ |
mbed_official | 237:f3da66175598 | 115 | typedef enum |
mbed_official | 237:f3da66175598 | 116 | { |
mbed_official | 237:f3da66175598 | 117 | HAL_SPI_STATE_RESET = 0x00, /*!< Peripheral not Initialized */ |
mbed_official | 237:f3da66175598 | 118 | HAL_SPI_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ |
mbed_official | 237:f3da66175598 | 119 | HAL_SPI_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ |
mbed_official | 237:f3da66175598 | 120 | HAL_SPI_STATE_BUSY_TX = 0x03, /*!< Data Transmission process is ongoing */ |
mbed_official | 237:f3da66175598 | 121 | HAL_SPI_STATE_BUSY_RX = 0x04, /*!< Data Reception process is ongoing */ |
mbed_official | 237:f3da66175598 | 122 | HAL_SPI_STATE_BUSY_TX_RX = 0x05, /*!< Data Transmission and Reception process is ongoing */ |
mbed_official | 237:f3da66175598 | 123 | HAL_SPI_STATE_TIMEOUT = 0x06, /*!< Timeout state */ |
mbed_official | 237:f3da66175598 | 124 | HAL_SPI_STATE_ERROR = 0x07 /*!< Data Transmission and Reception process is ongoing */ |
mbed_official | 237:f3da66175598 | 125 | |
mbed_official | 237:f3da66175598 | 126 | }HAL_SPI_StateTypeDef; |
mbed_official | 237:f3da66175598 | 127 | |
mbed_official | 237:f3da66175598 | 128 | /** |
mbed_official | 237:f3da66175598 | 129 | * @brief HAL SPI Error Code structure definition |
mbed_official | 237:f3da66175598 | 130 | */ |
mbed_official | 237:f3da66175598 | 131 | typedef enum |
mbed_official | 237:f3da66175598 | 132 | { |
mbed_official | 237:f3da66175598 | 133 | HAL_SPI_ERROR_NONE = 0x00, /*!< No error */ |
mbed_official | 237:f3da66175598 | 134 | HAL_SPI_ERROR_MODF = 0x01, /*!< MODF error */ |
mbed_official | 237:f3da66175598 | 135 | HAL_SPI_ERROR_CRC = 0x02, /*!< CRC error */ |
mbed_official | 237:f3da66175598 | 136 | HAL_SPI_ERROR_OVR = 0x04, /*!< OVR error */ |
mbed_official | 237:f3da66175598 | 137 | HAL_SPI_ERROR_FRE = 0x08, /*!< FRE error */ |
mbed_official | 237:f3da66175598 | 138 | HAL_SPI_ERROR_DMA = 0x10, /*!< DMA transfer error */ |
mbed_official | 237:f3da66175598 | 139 | HAL_SPI_ERROR_FLAG = 0x20, /*!< Error on BSY/TXE/FTLVL/FRLVL Flag */ |
mbed_official | 237:f3da66175598 | 140 | HAL_SPI_ERROR_UNKNOW = 0x40, /*!< Unknow Error error */ |
mbed_official | 237:f3da66175598 | 141 | }HAL_SPI_ErrorTypeDef; |
mbed_official | 237:f3da66175598 | 142 | |
mbed_official | 237:f3da66175598 | 143 | /** |
mbed_official | 237:f3da66175598 | 144 | * @brief SPI handle Structure definition |
mbed_official | 237:f3da66175598 | 145 | */ |
mbed_official | 237:f3da66175598 | 146 | typedef struct __SPI_HandleTypeDef |
mbed_official | 237:f3da66175598 | 147 | { |
mbed_official | 237:f3da66175598 | 148 | SPI_TypeDef *Instance; /* SPI registers base address */ |
mbed_official | 237:f3da66175598 | 149 | |
mbed_official | 237:f3da66175598 | 150 | SPI_InitTypeDef Init; /* SPI communication parameters */ |
mbed_official | 237:f3da66175598 | 151 | |
mbed_official | 237:f3da66175598 | 152 | uint8_t *pTxBuffPtr; /* Pointer to SPI Tx transfer Buffer */ |
mbed_official | 237:f3da66175598 | 153 | |
mbed_official | 237:f3da66175598 | 154 | uint16_t TxXferSize; /* SPI Tx Transfer size */ |
mbed_official | 237:f3da66175598 | 155 | |
mbed_official | 237:f3da66175598 | 156 | uint16_t TxXferCount; /* SPI Tx Transfer Counter */ |
mbed_official | 237:f3da66175598 | 157 | |
mbed_official | 237:f3da66175598 | 158 | uint8_t *pRxBuffPtr; /* Pointer to SPI Rx transfer Buffer */ |
mbed_official | 237:f3da66175598 | 159 | |
mbed_official | 237:f3da66175598 | 160 | uint16_t RxXferSize; /* SPI Rx Transfer size */ |
mbed_official | 237:f3da66175598 | 161 | |
mbed_official | 237:f3da66175598 | 162 | uint16_t RxXferCount; /* SPI Rx Transfer Counter */ |
mbed_official | 237:f3da66175598 | 163 | |
mbed_official | 237:f3da66175598 | 164 | uint32_t CRCSize; /* SPI CRC size used for the transfer */ |
mbed_official | 237:f3da66175598 | 165 | |
mbed_official | 237:f3da66175598 | 166 | void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /* function pointer on Rx IRQ handler */ |
mbed_official | 237:f3da66175598 | 167 | |
mbed_official | 237:f3da66175598 | 168 | void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /* function pointer on Tx IRQ handler */ |
mbed_official | 237:f3da66175598 | 169 | |
mbed_official | 237:f3da66175598 | 170 | DMA_HandleTypeDef *hdmatx; /* SPI Tx DMA Handle parameters */ |
mbed_official | 237:f3da66175598 | 171 | |
mbed_official | 237:f3da66175598 | 172 | DMA_HandleTypeDef *hdmarx; /* SPI Rx DMA Handle parameters */ |
mbed_official | 237:f3da66175598 | 173 | |
mbed_official | 237:f3da66175598 | 174 | HAL_LockTypeDef Lock; /* Locking object */ |
mbed_official | 237:f3da66175598 | 175 | |
mbed_official | 237:f3da66175598 | 176 | HAL_SPI_StateTypeDef State; /* SPI communication state */ |
mbed_official | 237:f3da66175598 | 177 | |
mbed_official | 237:f3da66175598 | 178 | HAL_SPI_ErrorTypeDef ErrorCode; /* SPI Error code */ |
mbed_official | 237:f3da66175598 | 179 | |
mbed_official | 237:f3da66175598 | 180 | }SPI_HandleTypeDef; |
mbed_official | 237:f3da66175598 | 181 | |
mbed_official | 237:f3da66175598 | 182 | /* Exported constants --------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 183 | |
mbed_official | 237:f3da66175598 | 184 | /** @defgroup SPI_Exported_Constants |
mbed_official | 237:f3da66175598 | 185 | * @{ |
mbed_official | 237:f3da66175598 | 186 | */ |
mbed_official | 237:f3da66175598 | 187 | |
mbed_official | 237:f3da66175598 | 188 | /** @defgroup SPI_mode |
mbed_official | 237:f3da66175598 | 189 | * @{ |
mbed_official | 237:f3da66175598 | 190 | */ |
mbed_official | 237:f3da66175598 | 191 | |
mbed_official | 237:f3da66175598 | 192 | #define SPI_MODE_SLAVE ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 193 | #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) |
mbed_official | 237:f3da66175598 | 194 | #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \ |
mbed_official | 237:f3da66175598 | 195 | ((MODE) == SPI_MODE_MASTER)) |
mbed_official | 237:f3da66175598 | 196 | /** |
mbed_official | 237:f3da66175598 | 197 | * @} |
mbed_official | 237:f3da66175598 | 198 | */ |
mbed_official | 237:f3da66175598 | 199 | |
mbed_official | 237:f3da66175598 | 200 | /** @defgroup SPI_Direction |
mbed_official | 237:f3da66175598 | 201 | * @{ |
mbed_official | 237:f3da66175598 | 202 | */ |
mbed_official | 237:f3da66175598 | 203 | #define SPI_DIRECTION_2LINES ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 204 | #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY |
mbed_official | 237:f3da66175598 | 205 | #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE |
mbed_official | 237:f3da66175598 | 206 | |
mbed_official | 237:f3da66175598 | 207 | #define IS_SPI_DIRECTION(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ |
mbed_official | 237:f3da66175598 | 208 | ((MODE) == SPI_DIRECTION_2LINES_RXONLY) ||\ |
mbed_official | 237:f3da66175598 | 209 | ((MODE) == SPI_DIRECTION_1LINE)) |
mbed_official | 237:f3da66175598 | 210 | |
mbed_official | 237:f3da66175598 | 211 | #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES) |
mbed_official | 237:f3da66175598 | 212 | |
mbed_official | 237:f3da66175598 | 213 | #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES)|| \ |
mbed_official | 237:f3da66175598 | 214 | ((MODE) == SPI_DIRECTION_1LINE)) |
mbed_official | 237:f3da66175598 | 215 | /** |
mbed_official | 237:f3da66175598 | 216 | * @} |
mbed_official | 237:f3da66175598 | 217 | */ |
mbed_official | 237:f3da66175598 | 218 | |
mbed_official | 237:f3da66175598 | 219 | /** @defgroup SPI_data_size |
mbed_official | 237:f3da66175598 | 220 | * @{ |
mbed_official | 237:f3da66175598 | 221 | */ |
mbed_official | 237:f3da66175598 | 222 | |
mbed_official | 237:f3da66175598 | 223 | #define SPI_DATASIZE_4BIT ((uint16_t)0x0300) |
mbed_official | 237:f3da66175598 | 224 | #define SPI_DATASIZE_5BIT ((uint16_t)0x0400) |
mbed_official | 237:f3da66175598 | 225 | #define SPI_DATASIZE_6BIT ((uint16_t)0x0500) |
mbed_official | 237:f3da66175598 | 226 | #define SPI_DATASIZE_7BIT ((uint16_t)0x0600) |
mbed_official | 237:f3da66175598 | 227 | #define SPI_DATASIZE_8BIT ((uint16_t)0x0700) |
mbed_official | 237:f3da66175598 | 228 | #define SPI_DATASIZE_9BIT ((uint16_t)0x0800) |
mbed_official | 237:f3da66175598 | 229 | #define SPI_DATASIZE_10BIT ((uint16_t)0x0900) |
mbed_official | 237:f3da66175598 | 230 | #define SPI_DATASIZE_11BIT ((uint16_t)0x0A00) |
mbed_official | 237:f3da66175598 | 231 | #define SPI_DATASIZE_12BIT ((uint16_t)0x0B00) |
mbed_official | 237:f3da66175598 | 232 | #define SPI_DATASIZE_13BIT ((uint16_t)0x0C00) |
mbed_official | 237:f3da66175598 | 233 | #define SPI_DATASIZE_14BIT ((uint16_t)0x0D00) |
mbed_official | 237:f3da66175598 | 234 | #define SPI_DATASIZE_15BIT ((uint16_t)0x0E00) |
mbed_official | 237:f3da66175598 | 235 | #define SPI_DATASIZE_16BIT ((uint16_t)0x0F00) |
mbed_official | 237:f3da66175598 | 236 | #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \ |
mbed_official | 237:f3da66175598 | 237 | ((DATASIZE) == SPI_DATASIZE_15BIT) || \ |
mbed_official | 237:f3da66175598 | 238 | ((DATASIZE) == SPI_DATASIZE_14BIT) || \ |
mbed_official | 237:f3da66175598 | 239 | ((DATASIZE) == SPI_DATASIZE_13BIT) || \ |
mbed_official | 237:f3da66175598 | 240 | ((DATASIZE) == SPI_DATASIZE_12BIT) || \ |
mbed_official | 237:f3da66175598 | 241 | ((DATASIZE) == SPI_DATASIZE_11BIT) || \ |
mbed_official | 237:f3da66175598 | 242 | ((DATASIZE) == SPI_DATASIZE_10BIT) || \ |
mbed_official | 237:f3da66175598 | 243 | ((DATASIZE) == SPI_DATASIZE_9BIT) || \ |
mbed_official | 237:f3da66175598 | 244 | ((DATASIZE) == SPI_DATASIZE_8BIT) || \ |
mbed_official | 237:f3da66175598 | 245 | ((DATASIZE) == SPI_DATASIZE_7BIT) || \ |
mbed_official | 237:f3da66175598 | 246 | ((DATASIZE) == SPI_DATASIZE_6BIT) || \ |
mbed_official | 237:f3da66175598 | 247 | ((DATASIZE) == SPI_DATASIZE_5BIT) || \ |
mbed_official | 237:f3da66175598 | 248 | ((DATASIZE) == SPI_DATASIZE_4BIT)) |
mbed_official | 237:f3da66175598 | 249 | |
mbed_official | 237:f3da66175598 | 250 | /** |
mbed_official | 237:f3da66175598 | 251 | * @} |
mbed_official | 237:f3da66175598 | 252 | */ |
mbed_official | 237:f3da66175598 | 253 | |
mbed_official | 237:f3da66175598 | 254 | /** @defgroup SPI_Clock_Polarity |
mbed_official | 237:f3da66175598 | 255 | * @{ |
mbed_official | 237:f3da66175598 | 256 | */ |
mbed_official | 237:f3da66175598 | 257 | |
mbed_official | 237:f3da66175598 | 258 | #define SPI_POLARITY_LOW ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 259 | #define SPI_POLARITY_HIGH SPI_CR1_CPOL |
mbed_official | 237:f3da66175598 | 260 | #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \ |
mbed_official | 237:f3da66175598 | 261 | ((CPOL) == SPI_POLARITY_HIGH)) |
mbed_official | 237:f3da66175598 | 262 | /** |
mbed_official | 237:f3da66175598 | 263 | * @} |
mbed_official | 237:f3da66175598 | 264 | */ |
mbed_official | 237:f3da66175598 | 265 | |
mbed_official | 237:f3da66175598 | 266 | /** @defgroup SPI_Clock_Phase |
mbed_official | 237:f3da66175598 | 267 | * @{ |
mbed_official | 237:f3da66175598 | 268 | */ |
mbed_official | 237:f3da66175598 | 269 | |
mbed_official | 237:f3da66175598 | 270 | #define SPI_PHASE_1EDGE ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 271 | #define SPI_PHASE_2EDGE SPI_CR1_CPHA |
mbed_official | 237:f3da66175598 | 272 | #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \ |
mbed_official | 237:f3da66175598 | 273 | ((CPHA) == SPI_PHASE_2EDGE)) |
mbed_official | 237:f3da66175598 | 274 | /** |
mbed_official | 237:f3da66175598 | 275 | * @} |
mbed_official | 237:f3da66175598 | 276 | */ |
mbed_official | 237:f3da66175598 | 277 | |
mbed_official | 237:f3da66175598 | 278 | /** @defgroup SPI_Slave_Select_management |
mbed_official | 237:f3da66175598 | 279 | * @{ |
mbed_official | 237:f3da66175598 | 280 | */ |
mbed_official | 237:f3da66175598 | 281 | |
mbed_official | 237:f3da66175598 | 282 | #define SPI_NSS_SOFT SPI_CR1_SSM |
mbed_official | 237:f3da66175598 | 283 | #define SPI_NSS_HARD_INPUT ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 284 | #define SPI_NSS_HARD_OUTPUT ((uint32_t)0x00040000) |
mbed_official | 237:f3da66175598 | 285 | #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \ |
mbed_official | 237:f3da66175598 | 286 | ((NSS) == SPI_NSS_HARD_INPUT) || \ |
mbed_official | 237:f3da66175598 | 287 | ((NSS) == SPI_NSS_HARD_OUTPUT)) |
mbed_official | 237:f3da66175598 | 288 | |
mbed_official | 237:f3da66175598 | 289 | /** |
mbed_official | 237:f3da66175598 | 290 | * @} |
mbed_official | 237:f3da66175598 | 291 | */ |
mbed_official | 237:f3da66175598 | 292 | |
mbed_official | 237:f3da66175598 | 293 | |
mbed_official | 237:f3da66175598 | 294 | /** @defgroup SPI_NSS pulse management |
mbed_official | 237:f3da66175598 | 295 | * @{ |
mbed_official | 237:f3da66175598 | 296 | */ |
mbed_official | 237:f3da66175598 | 297 | #define SPI_NSS_PULSE_ENABLED SPI_CR2_NSSP |
mbed_official | 237:f3da66175598 | 298 | #define SPI_NSS_PULSE_DISABLED ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 299 | |
mbed_official | 237:f3da66175598 | 300 | #define IS_SPI_NSSP(NSSP) (((NSSP) == SPI_NSS_PULSE_ENABLED) || \ |
mbed_official | 237:f3da66175598 | 301 | ((NSSP) == SPI_NSS_PULSE_DISABLED)) |
mbed_official | 237:f3da66175598 | 302 | |
mbed_official | 237:f3da66175598 | 303 | /** |
mbed_official | 237:f3da66175598 | 304 | * @} |
mbed_official | 237:f3da66175598 | 305 | */ |
mbed_official | 237:f3da66175598 | 306 | |
mbed_official | 237:f3da66175598 | 307 | |
mbed_official | 237:f3da66175598 | 308 | /** @defgroup SPI_BaudRate_Prescaler |
mbed_official | 237:f3da66175598 | 309 | * @{ |
mbed_official | 237:f3da66175598 | 310 | */ |
mbed_official | 237:f3da66175598 | 311 | |
mbed_official | 237:f3da66175598 | 312 | #define SPI_BAUDRATEPRESCALER_2 ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 313 | #define SPI_BAUDRATEPRESCALER_4 ((uint32_t)0x00000008) |
mbed_official | 237:f3da66175598 | 314 | #define SPI_BAUDRATEPRESCALER_8 ((uint32_t)0x00000010) |
mbed_official | 237:f3da66175598 | 315 | #define SPI_BAUDRATEPRESCALER_16 ((uint32_t)0x00000018) |
mbed_official | 237:f3da66175598 | 316 | #define SPI_BAUDRATEPRESCALER_32 ((uint32_t)0x00000020) |
mbed_official | 237:f3da66175598 | 317 | #define SPI_BAUDRATEPRESCALER_64 ((uint32_t)0x00000028) |
mbed_official | 237:f3da66175598 | 318 | #define SPI_BAUDRATEPRESCALER_128 ((uint32_t)0x00000030) |
mbed_official | 237:f3da66175598 | 319 | #define SPI_BAUDRATEPRESCALER_256 ((uint32_t)0x00000038) |
mbed_official | 237:f3da66175598 | 320 | #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \ |
mbed_official | 237:f3da66175598 | 321 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \ |
mbed_official | 237:f3da66175598 | 322 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \ |
mbed_official | 237:f3da66175598 | 323 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \ |
mbed_official | 237:f3da66175598 | 324 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \ |
mbed_official | 237:f3da66175598 | 325 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \ |
mbed_official | 237:f3da66175598 | 326 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \ |
mbed_official | 237:f3da66175598 | 327 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_256)) |
mbed_official | 237:f3da66175598 | 328 | /** |
mbed_official | 237:f3da66175598 | 329 | * @} |
mbed_official | 237:f3da66175598 | 330 | */ |
mbed_official | 237:f3da66175598 | 331 | |
mbed_official | 237:f3da66175598 | 332 | /** @defgroup SPI_MSB_LSB_transmission |
mbed_official | 237:f3da66175598 | 333 | * @{ |
mbed_official | 237:f3da66175598 | 334 | */ |
mbed_official | 237:f3da66175598 | 335 | |
mbed_official | 237:f3da66175598 | 336 | #define SPI_FIRSTBIT_MSB ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 337 | #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST |
mbed_official | 237:f3da66175598 | 338 | #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \ |
mbed_official | 237:f3da66175598 | 339 | ((BIT) == SPI_FIRSTBIT_LSB)) |
mbed_official | 237:f3da66175598 | 340 | /** |
mbed_official | 237:f3da66175598 | 341 | * @} |
mbed_official | 237:f3da66175598 | 342 | */ |
mbed_official | 237:f3da66175598 | 343 | |
mbed_official | 237:f3da66175598 | 344 | /** @defgroup SPI_TI_mode |
mbed_official | 237:f3da66175598 | 345 | * @{ |
mbed_official | 237:f3da66175598 | 346 | */ |
mbed_official | 237:f3da66175598 | 347 | |
mbed_official | 237:f3da66175598 | 348 | #define SPI_TIMODE_DISABLED ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 349 | #define SPI_TIMODE_ENABLED SPI_CR2_FRF |
mbed_official | 237:f3da66175598 | 350 | #define IS_SPI_TIMODE(MODE) (((MODE) == SPI_TIMODE_DISABLED) || \ |
mbed_official | 237:f3da66175598 | 351 | ((MODE) == SPI_TIMODE_ENABLED)) |
mbed_official | 237:f3da66175598 | 352 | /** |
mbed_official | 237:f3da66175598 | 353 | * @} |
mbed_official | 237:f3da66175598 | 354 | */ |
mbed_official | 237:f3da66175598 | 355 | |
mbed_official | 237:f3da66175598 | 356 | /** @defgroup SPI_CRC_Calculation |
mbed_official | 237:f3da66175598 | 357 | * @{ |
mbed_official | 237:f3da66175598 | 358 | */ |
mbed_official | 237:f3da66175598 | 359 | |
mbed_official | 237:f3da66175598 | 360 | #define SPI_CRCCALCULATION_DISABLED ((uint32_t)0x00000000) |
mbed_official | 237:f3da66175598 | 361 | #define SPI_CRCCALCULATION_ENABLED SPI_CR1_CRCEN |
mbed_official | 237:f3da66175598 | 362 | #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLED) || \ |
mbed_official | 237:f3da66175598 | 363 | ((CALCULATION) == SPI_CRCCALCULATION_ENABLED)) |
mbed_official | 237:f3da66175598 | 364 | /** |
mbed_official | 237:f3da66175598 | 365 | * @} |
mbed_official | 237:f3da66175598 | 366 | */ |
mbed_official | 237:f3da66175598 | 367 | |
mbed_official | 237:f3da66175598 | 368 | /** @defgroup SPI_CRC_length |
mbed_official | 237:f3da66175598 | 369 | * @{ |
mbed_official | 237:f3da66175598 | 370 | * This parameter can be one of the following values: |
mbed_official | 237:f3da66175598 | 371 | * SPI_CRC_LENGTH_DATASIZE: aligned with the data size |
mbed_official | 237:f3da66175598 | 372 | * SPI_CRC_LENGTH_8BIT : CRC 8bit |
mbed_official | 237:f3da66175598 | 373 | * SPI_CRC_LENGTH_16BIT : CRC 16bit |
mbed_official | 237:f3da66175598 | 374 | */ |
mbed_official | 237:f3da66175598 | 375 | #define SPI_CRC_LENGTH_DATASIZE 0 |
mbed_official | 237:f3da66175598 | 376 | #define SPI_CRC_LENGTH_8BIT 1 |
mbed_official | 237:f3da66175598 | 377 | #define SPI_CRC_LENGTH_16BIT 2 |
mbed_official | 237:f3da66175598 | 378 | #define IS_SPI_CRC_LENGTH(LENGTH) (((LENGTH) == SPI_CRC_LENGTH_DATASIZE) ||\ |
mbed_official | 237:f3da66175598 | 379 | ((LENGTH) == SPI_CRC_LENGTH_8BIT) || \ |
mbed_official | 237:f3da66175598 | 380 | ((LENGTH) == SPI_CRC_LENGTH_16BIT)) |
mbed_official | 237:f3da66175598 | 381 | /** |
mbed_official | 237:f3da66175598 | 382 | * @} |
mbed_official | 237:f3da66175598 | 383 | */ |
mbed_official | 237:f3da66175598 | 384 | |
mbed_official | 237:f3da66175598 | 385 | /** @defgroup SPI_FIFO_reception_threshold |
mbed_official | 237:f3da66175598 | 386 | * @{ |
mbed_official | 237:f3da66175598 | 387 | * This parameter can be one of the following values: |
mbed_official | 237:f3da66175598 | 388 | * SPI_RxFIFOThreshold_HF: RXNE event is generated if the FIFO |
mbed_official | 237:f3da66175598 | 389 | * level is greater or equal to 1/2(16-bits). |
mbed_official | 237:f3da66175598 | 390 | * SPI_RxFIFOThreshold_QF: RXNE event is generated if the FIFO |
mbed_official | 237:f3da66175598 | 391 | * level is greater or equal to 1/4(8 bits). |
mbed_official | 237:f3da66175598 | 392 | */ |
mbed_official | 237:f3da66175598 | 393 | #define SPI_RXFIFO_THRESHOLD SPI_CR2_FRXTH |
mbed_official | 237:f3da66175598 | 394 | #define SPI_RXFIFO_THRESHOLD_QF SPI_CR2_FRXTH |
mbed_official | 237:f3da66175598 | 395 | #define SPI_RXFIFO_THRESHOLD_HF ((uint32_t)0x0) |
mbed_official | 237:f3da66175598 | 396 | |
mbed_official | 237:f3da66175598 | 397 | /** |
mbed_official | 237:f3da66175598 | 398 | * @} |
mbed_official | 237:f3da66175598 | 399 | */ |
mbed_official | 237:f3da66175598 | 400 | |
mbed_official | 237:f3da66175598 | 401 | /** @defgroup SPI_Interrupt_configuration_definition |
mbed_official | 237:f3da66175598 | 402 | * @brief SPI Interrupt definition |
mbed_official | 237:f3da66175598 | 403 | * Elements values convention: 0xXXXXXXXX |
mbed_official | 237:f3da66175598 | 404 | * - XXXXXXXX : Interrupt control mask |
mbed_official | 237:f3da66175598 | 405 | * @{ |
mbed_official | 237:f3da66175598 | 406 | */ |
mbed_official | 237:f3da66175598 | 407 | #define SPI_IT_TXE SPI_CR2_TXEIE |
mbed_official | 237:f3da66175598 | 408 | #define SPI_IT_RXNE SPI_CR2_RXNEIE |
mbed_official | 237:f3da66175598 | 409 | #define SPI_IT_ERR SPI_CR2_ERRIE |
mbed_official | 237:f3da66175598 | 410 | #define IS_SPI_IT(IT) (((IT) == SPI_IT_TXE) || \ |
mbed_official | 237:f3da66175598 | 411 | ((IT) == SPI_IT_RXNE) || \ |
mbed_official | 237:f3da66175598 | 412 | ((IT) == SPI_IT_ERR)) |
mbed_official | 237:f3da66175598 | 413 | /** |
mbed_official | 237:f3da66175598 | 414 | * @} |
mbed_official | 237:f3da66175598 | 415 | */ |
mbed_official | 237:f3da66175598 | 416 | |
mbed_official | 237:f3da66175598 | 417 | |
mbed_official | 237:f3da66175598 | 418 | /** @defgroup SPI_Flag_definition |
mbed_official | 237:f3da66175598 | 419 | * @brief Flag definition |
mbed_official | 237:f3da66175598 | 420 | * Elements values convention: 0xXXXXYYYY |
mbed_official | 237:f3da66175598 | 421 | * - XXXX : Flag register Index |
mbed_official | 237:f3da66175598 | 422 | * - YYYY : Flag mask |
mbed_official | 237:f3da66175598 | 423 | */ |
mbed_official | 237:f3da66175598 | 424 | #define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */ |
mbed_official | 237:f3da66175598 | 425 | #define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */ |
mbed_official | 237:f3da66175598 | 426 | #define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */ |
mbed_official | 237:f3da66175598 | 427 | #define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */ |
mbed_official | 237:f3da66175598 | 428 | #define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */ |
mbed_official | 237:f3da66175598 | 429 | #define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */ |
mbed_official | 237:f3da66175598 | 430 | #define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */ |
mbed_official | 237:f3da66175598 | 431 | #define SPI_FLAG_FTLVL SPI_SR_FTLVL /* SPI fifo transmission level */ |
mbed_official | 237:f3da66175598 | 432 | #define SPI_FLAG_FRLVL SPI_SR_FRLVL /* SPI fifo reception level */ |
mbed_official | 237:f3da66175598 | 433 | #define IS_SPI_FLAG(FLAG) (((FLAG) == SPI_FLAG_RXNE) || \ |
mbed_official | 237:f3da66175598 | 434 | ((FLAG) == SPI_FLAG_TXE) || \ |
mbed_official | 237:f3da66175598 | 435 | ((FLAG) == SPI_FLAG_BSY) || \ |
mbed_official | 237:f3da66175598 | 436 | ((FLAG) == SPI_FLAG_CRCERR)|| \ |
mbed_official | 237:f3da66175598 | 437 | ((FLAG) == SPI_FLAG_MODF) || \ |
mbed_official | 237:f3da66175598 | 438 | ((FLAG) == SPI_FLAG_OVR) || \ |
mbed_official | 237:f3da66175598 | 439 | ((FLAG) == SPI_FLAG_FTLVL) || \ |
mbed_official | 237:f3da66175598 | 440 | ((FLAG) == SPI_FLAG_FRLVL) || \ |
mbed_official | 237:f3da66175598 | 441 | ((FLAG) == SPI_IT_FRE)) |
mbed_official | 237:f3da66175598 | 442 | |
mbed_official | 237:f3da66175598 | 443 | |
mbed_official | 237:f3da66175598 | 444 | /** @defgroup SPI_transmission_fifo_status_level |
mbed_official | 237:f3da66175598 | 445 | * @{ |
mbed_official | 237:f3da66175598 | 446 | */ |
mbed_official | 237:f3da66175598 | 447 | |
mbed_official | 237:f3da66175598 | 448 | #define SPI_FTLVL_EMPTY ((uint16_t)0x0000) |
mbed_official | 237:f3da66175598 | 449 | #define SPI_FTLVL_QUARTER_FULL ((uint16_t)0x0800) |
mbed_official | 237:f3da66175598 | 450 | #define SPI_FTLVL_HALF_FULL ((uint16_t)0x1000) |
mbed_official | 237:f3da66175598 | 451 | #define SPI_FTLVL_FULL ((uint16_t)0x1800) |
mbed_official | 237:f3da66175598 | 452 | |
mbed_official | 237:f3da66175598 | 453 | |
mbed_official | 237:f3da66175598 | 454 | /** |
mbed_official | 237:f3da66175598 | 455 | * @} |
mbed_official | 237:f3da66175598 | 456 | */ |
mbed_official | 237:f3da66175598 | 457 | |
mbed_official | 237:f3da66175598 | 458 | /** @defgroup SPI_reception_fifo_status_level |
mbed_official | 237:f3da66175598 | 459 | * @{ |
mbed_official | 237:f3da66175598 | 460 | */ |
mbed_official | 237:f3da66175598 | 461 | #define SPI_FRLVL_EMPTY ((uint16_t)0x0000) |
mbed_official | 237:f3da66175598 | 462 | #define SPI_FRLVL_QUARTER_FULL ((uint16_t)0x0200) |
mbed_official | 237:f3da66175598 | 463 | #define SPI_FRLVL_HALF_FULL ((uint16_t)0x0400) |
mbed_official | 237:f3da66175598 | 464 | #define SPI_FRLVL_FULL ((uint16_t)0x0600) |
mbed_official | 237:f3da66175598 | 465 | |
mbed_official | 237:f3da66175598 | 466 | /** |
mbed_official | 237:f3da66175598 | 467 | * @} |
mbed_official | 237:f3da66175598 | 468 | */ |
mbed_official | 237:f3da66175598 | 469 | |
mbed_official | 237:f3da66175598 | 470 | /** |
mbed_official | 237:f3da66175598 | 471 | * @} |
mbed_official | 237:f3da66175598 | 472 | */ |
mbed_official | 237:f3da66175598 | 473 | |
mbed_official | 237:f3da66175598 | 474 | |
mbed_official | 237:f3da66175598 | 475 | /* Exported macros ------------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 476 | |
mbed_official | 237:f3da66175598 | 477 | /** @brief Reset SPI handle state |
mbed_official | 237:f3da66175598 | 478 | * @param __HANDLE__: SPI handle. |
mbed_official | 237:f3da66175598 | 479 | * @retval None |
mbed_official | 237:f3da66175598 | 480 | */ |
mbed_official | 237:f3da66175598 | 481 | #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) |
mbed_official | 237:f3da66175598 | 482 | |
mbed_official | 237:f3da66175598 | 483 | /** @brief Enables or disables the specified SPI interrupts. |
mbed_official | 237:f3da66175598 | 484 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 485 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 486 | * @param __INTERRUPT__: specifies the interrupt source to enable or disable. |
mbed_official | 237:f3da66175598 | 487 | * This parameter can be one of the following values: |
mbed_official | 237:f3da66175598 | 488 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
mbed_official | 237:f3da66175598 | 489 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
mbed_official | 237:f3da66175598 | 490 | * @arg SPI_IT_ERR: Error interrupt enable |
mbed_official | 237:f3da66175598 | 491 | * @retval None |
mbed_official | 237:f3da66175598 | 492 | */ |
mbed_official | 237:f3da66175598 | 493 | |
mbed_official | 237:f3da66175598 | 494 | #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__)) |
mbed_official | 237:f3da66175598 | 495 | #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__))) |
mbed_official | 237:f3da66175598 | 496 | |
mbed_official | 237:f3da66175598 | 497 | /** @brief Checks if the specified SPI interrupt source is enabled or disabled. |
mbed_official | 237:f3da66175598 | 498 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 499 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 500 | * @param __INTERRUPT__: specifies the SPI interrupt source to check. |
mbed_official | 237:f3da66175598 | 501 | * This parameter can be one of the following values: |
mbed_official | 237:f3da66175598 | 502 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
mbed_official | 237:f3da66175598 | 503 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
mbed_official | 237:f3da66175598 | 504 | * @arg SPI_IT_ERR: Error interrupt enable |
mbed_official | 237:f3da66175598 | 505 | * @retval The new state of __IT__ (TRUE or FALSE). |
mbed_official | 237:f3da66175598 | 506 | */ |
mbed_official | 237:f3da66175598 | 507 | #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
mbed_official | 237:f3da66175598 | 508 | |
mbed_official | 237:f3da66175598 | 509 | /** @brief Checks whether the specified SPI flag is set or not. |
mbed_official | 237:f3da66175598 | 510 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 511 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 512 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 237:f3da66175598 | 513 | * This parameter can be one of the following values: |
mbed_official | 237:f3da66175598 | 514 | * @arg SPI_FLAG_RXNE: Receive buffer not empty flag |
mbed_official | 237:f3da66175598 | 515 | * @arg SPI_FLAG_TXE: Transmit buffer empty flag |
mbed_official | 237:f3da66175598 | 516 | * @arg SPI_FLAG_CRCERR: CRC error flag |
mbed_official | 237:f3da66175598 | 517 | * @arg SPI_FLAG_MODF: Mode fault flag |
mbed_official | 237:f3da66175598 | 518 | * @arg SPI_FLAG_OVR: Overrun flag |
mbed_official | 237:f3da66175598 | 519 | * @arg SPI_FLAG_BSY: Busy flag |
mbed_official | 237:f3da66175598 | 520 | * @arg SPI_FLAG_FRE: Frame format error flag |
mbed_official | 237:f3da66175598 | 521 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
mbed_official | 237:f3da66175598 | 522 | */ |
mbed_official | 237:f3da66175598 | 523 | #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
mbed_official | 237:f3da66175598 | 524 | |
mbed_official | 237:f3da66175598 | 525 | /** @brief Clears the SPI CRCERR pending flag. |
mbed_official | 237:f3da66175598 | 526 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 527 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 528 | * @retval None |
mbed_official | 237:f3da66175598 | 529 | */ |
mbed_official | 237:f3da66175598 | 530 | #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = ~(SPI_FLAG_CRCERR)) |
mbed_official | 237:f3da66175598 | 531 | |
mbed_official | 237:f3da66175598 | 532 | /** @brief Clears the SPI MODF pending flag. |
mbed_official | 237:f3da66175598 | 533 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 534 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 535 | * |
mbed_official | 237:f3da66175598 | 536 | * @retval None |
mbed_official | 237:f3da66175598 | 537 | */ |
mbed_official | 237:f3da66175598 | 538 | #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ |
mbed_official | 237:f3da66175598 | 539 | (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE);}while(0) |
mbed_official | 237:f3da66175598 | 540 | |
mbed_official | 237:f3da66175598 | 541 | /** @brief Clears the SPI OVR pending flag. |
mbed_official | 237:f3da66175598 | 542 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 543 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 544 | * |
mbed_official | 237:f3da66175598 | 545 | * @retval None |
mbed_official | 237:f3da66175598 | 546 | */ |
mbed_official | 237:f3da66175598 | 547 | #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) do{(__HANDLE__)->Instance->DR;\ |
mbed_official | 237:f3da66175598 | 548 | (__HANDLE__)->Instance->SR;}while(0) |
mbed_official | 237:f3da66175598 | 549 | |
mbed_official | 237:f3da66175598 | 550 | /** @brief Clears the SPI FRE pending flag. |
mbed_official | 237:f3da66175598 | 551 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 552 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 553 | * |
mbed_official | 237:f3da66175598 | 554 | * @retval None |
mbed_official | 237:f3da66175598 | 555 | */ |
mbed_official | 237:f3da66175598 | 556 | #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR) |
mbed_official | 237:f3da66175598 | 557 | |
mbed_official | 237:f3da66175598 | 558 | /** @brief Enables the SPI. |
mbed_official | 237:f3da66175598 | 559 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 560 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 561 | * @retval None |
mbed_official | 237:f3da66175598 | 562 | */ |
mbed_official | 237:f3da66175598 | 563 | #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE) |
mbed_official | 237:f3da66175598 | 564 | |
mbed_official | 237:f3da66175598 | 565 | /** @brief Disables the SPI. |
mbed_official | 237:f3da66175598 | 566 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 567 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 568 | * @retval None |
mbed_official | 237:f3da66175598 | 569 | */ |
mbed_official | 237:f3da66175598 | 570 | #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_SPE) |
mbed_official | 237:f3da66175598 | 571 | |
mbed_official | 237:f3da66175598 | 572 | /** @brief Sets the SPI transmit-only mode. |
mbed_official | 237:f3da66175598 | 573 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 574 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 575 | * @retval None |
mbed_official | 237:f3da66175598 | 576 | */ |
mbed_official | 237:f3da66175598 | 577 | #define __HAL_SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE) |
mbed_official | 237:f3da66175598 | 578 | |
mbed_official | 237:f3da66175598 | 579 | /** @brief Sets the SPI receive-only mode. |
mbed_official | 237:f3da66175598 | 580 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 581 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 582 | * @retval None |
mbed_official | 237:f3da66175598 | 583 | */ |
mbed_official | 237:f3da66175598 | 584 | #define __HAL_SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_BIDIOE) |
mbed_official | 237:f3da66175598 | 585 | |
mbed_official | 237:f3da66175598 | 586 | /** @brief Resets the CRC calculation of the SPI. |
mbed_official | 237:f3da66175598 | 587 | * @param __HANDLE__: specifies the SPI Handle. |
mbed_official | 237:f3da66175598 | 588 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
mbed_official | 237:f3da66175598 | 589 | * @retval None |
mbed_official | 237:f3da66175598 | 590 | */ |
mbed_official | 237:f3da66175598 | 591 | #define __HAL_SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (~SPI_CR1_CRCEN);\ |
mbed_official | 237:f3da66175598 | 592 | (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0) |
mbed_official | 237:f3da66175598 | 593 | |
mbed_official | 237:f3da66175598 | 594 | |
mbed_official | 237:f3da66175598 | 595 | #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x1) && ((POLYNOMIAL) <= 0xFFFF)) |
mbed_official | 237:f3da66175598 | 596 | |
mbed_official | 237:f3da66175598 | 597 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 598 | |
mbed_official | 237:f3da66175598 | 599 | /* Initialization and de-initialization functions ****************************/ |
mbed_official | 237:f3da66175598 | 600 | HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 601 | HAL_StatusTypeDef HAL_SPI_InitExtended(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 602 | HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 603 | void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 604 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 605 | |
mbed_official | 237:f3da66175598 | 606 | /* IO operation functions *****************************************************/ |
mbed_official | 237:f3da66175598 | 607 | HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 237:f3da66175598 | 608 | HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
mbed_official | 237:f3da66175598 | 609 | HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
mbed_official | 237:f3da66175598 | 610 | HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
mbed_official | 237:f3da66175598 | 611 | HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
mbed_official | 237:f3da66175598 | 612 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
mbed_official | 237:f3da66175598 | 613 | HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
mbed_official | 237:f3da66175598 | 614 | HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
mbed_official | 237:f3da66175598 | 615 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
mbed_official | 237:f3da66175598 | 616 | void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 617 | void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 618 | void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 619 | void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 620 | void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 621 | |
mbed_official | 237:f3da66175598 | 622 | /* Peripheral State and Error functions ***************************************/ |
mbed_official | 237:f3da66175598 | 623 | HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi); |
mbed_official | 237:f3da66175598 | 624 | |
mbed_official | 237:f3da66175598 | 625 | /** |
mbed_official | 237:f3da66175598 | 626 | * @} |
mbed_official | 237:f3da66175598 | 627 | */ |
mbed_official | 237:f3da66175598 | 628 | |
mbed_official | 237:f3da66175598 | 629 | /** |
mbed_official | 237:f3da66175598 | 630 | * @} |
mbed_official | 237:f3da66175598 | 631 | */ |
mbed_official | 237:f3da66175598 | 632 | |
mbed_official | 237:f3da66175598 | 633 | #ifdef __cplusplus |
mbed_official | 237:f3da66175598 | 634 | } |
mbed_official | 237:f3da66175598 | 635 | #endif |
mbed_official | 237:f3da66175598 | 636 | |
mbed_official | 237:f3da66175598 | 637 | #endif /* __STM32F3xx_HAL_SPI_H */ |
mbed_official | 237:f3da66175598 | 638 | |
mbed_official | 237:f3da66175598 | 639 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |