mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
112:6f327212ef96
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 112:6f327212ef96 1 /**
Kojto 112:6f327212ef96 2 ******************************************************************************
Kojto 112:6f327212ef96 3 * @file stm32f4xx_hal_spi.h
Kojto 112:6f327212ef96 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.0
Kojto 122:f9eeca106725 6 * @date 06-May-2016
Kojto 112:6f327212ef96 7 * @brief Header file of SPI HAL module.
Kojto 112:6f327212ef96 8 ******************************************************************************
Kojto 112:6f327212ef96 9 * @attention
Kojto 112:6f327212ef96 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 112:6f327212ef96 12 *
Kojto 112:6f327212ef96 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 112:6f327212ef96 14 * are permitted provided that the following conditions are met:
Kojto 112:6f327212ef96 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 112:6f327212ef96 16 * this list of conditions and the following disclaimer.
Kojto 112:6f327212ef96 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 112:6f327212ef96 18 * this list of conditions and the following disclaimer in the documentation
Kojto 112:6f327212ef96 19 * and/or other materials provided with the distribution.
Kojto 112:6f327212ef96 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 112:6f327212ef96 21 * may be used to endorse or promote products derived from this software
Kojto 112:6f327212ef96 22 * without specific prior written permission.
Kojto 112:6f327212ef96 23 *
Kojto 112:6f327212ef96 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 112:6f327212ef96 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 112:6f327212ef96 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 112:6f327212ef96 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 112:6f327212ef96 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 112:6f327212ef96 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 112:6f327212ef96 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 112:6f327212ef96 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 112:6f327212ef96 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 112:6f327212ef96 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 112:6f327212ef96 34 *
Kojto 112:6f327212ef96 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 112:6f327212ef96 37
Kojto 112:6f327212ef96 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 112:6f327212ef96 39 #ifndef __STM32F4xx_HAL_SPI_H
Kojto 112:6f327212ef96 40 #define __STM32F4xx_HAL_SPI_H
Kojto 112:6f327212ef96 41
Kojto 112:6f327212ef96 42 #ifdef __cplusplus
Kojto 112:6f327212ef96 43 extern "C" {
Kojto 112:6f327212ef96 44 #endif
Kojto 112:6f327212ef96 45
Kojto 112:6f327212ef96 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32f4xx_hal_def.h"
Kojto 112:6f327212ef96 48
Kojto 112:6f327212ef96 49 /** @addtogroup STM32F4xx_HAL_Driver
Kojto 112:6f327212ef96 50 * @{
Kojto 112:6f327212ef96 51 */
Kojto 112:6f327212ef96 52
Kojto 112:6f327212ef96 53 /** @addtogroup SPI
Kojto 112:6f327212ef96 54 * @{
Kojto 112:6f327212ef96 55 */
Kojto 112:6f327212ef96 56
Kojto 112:6f327212ef96 57 /* Exported types ------------------------------------------------------------*/
Kojto 112:6f327212ef96 58 /** @defgroup SPI_Exported_Types SPI Exported Types
Kojto 112:6f327212ef96 59 * @{
Kojto 112:6f327212ef96 60 */
Kojto 122:f9eeca106725 61
Kojto 122:f9eeca106725 62 /**
Kojto 122:f9eeca106725 63 * @brief SPI Configuration Structure definition
Kojto 112:6f327212ef96 64 */
Kojto 112:6f327212ef96 65 typedef struct
Kojto 112:6f327212ef96 66 {
Kojto 112:6f327212ef96 67 uint32_t Mode; /*!< Specifies the SPI operating mode.
Kojto 122:f9eeca106725 68 This parameter can be a value of @ref SPI_Mode */
Kojto 112:6f327212ef96 69
Kojto 122:f9eeca106725 70 uint32_t Direction; /*!< Specifies the SPI bidirectional mode state.
Kojto 122:f9eeca106725 71 This parameter can be a value of @ref SPI_Direction */
Kojto 112:6f327212ef96 72
Kojto 112:6f327212ef96 73 uint32_t DataSize; /*!< Specifies the SPI data size.
Kojto 122:f9eeca106725 74 This parameter can be a value of @ref SPI_Data_Size */
Kojto 112:6f327212ef96 75
Kojto 112:6f327212ef96 76 uint32_t CLKPolarity; /*!< Specifies the serial clock steady state.
Kojto 112:6f327212ef96 77 This parameter can be a value of @ref SPI_Clock_Polarity */
Kojto 112:6f327212ef96 78
Kojto 112:6f327212ef96 79 uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture.
Kojto 112:6f327212ef96 80 This parameter can be a value of @ref SPI_Clock_Phase */
Kojto 112:6f327212ef96 81
Kojto 112:6f327212ef96 82 uint32_t NSS; /*!< Specifies whether the NSS signal is managed by
Kojto 112:6f327212ef96 83 hardware (NSS pin) or by software using the SSI bit.
Kojto 112:6f327212ef96 84 This parameter can be a value of @ref SPI_Slave_Select_management */
Kojto 112:6f327212ef96 85
Kojto 112:6f327212ef96 86 uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
Kojto 112:6f327212ef96 87 used to configure the transmit and receive SCK clock.
Kojto 112:6f327212ef96 88 This parameter can be a value of @ref SPI_BaudRate_Prescaler
Kojto 112:6f327212ef96 89 @note The communication clock is derived from the master
Kojto 122:f9eeca106725 90 clock. The slave clock does not need to be set. */
Kojto 112:6f327212ef96 91
Kojto 112:6f327212ef96 92 uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
Kojto 112:6f327212ef96 93 This parameter can be a value of @ref SPI_MSB_LSB_transmission */
Kojto 112:6f327212ef96 94
Kojto 112:6f327212ef96 95 uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not.
Kojto 112:6f327212ef96 96 This parameter can be a value of @ref SPI_TI_mode */
Kojto 112:6f327212ef96 97
Kojto 112:6f327212ef96 98 uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
Kojto 112:6f327212ef96 99 This parameter can be a value of @ref SPI_CRC_Calculation */
Kojto 112:6f327212ef96 100
Kojto 112:6f327212ef96 101 uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation.
Kojto 112:6f327212ef96 102 This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */
Kojto 112:6f327212ef96 103 }SPI_InitTypeDef;
Kojto 112:6f327212ef96 104
Kojto 112:6f327212ef96 105 /**
Kojto 112:6f327212ef96 106 * @brief HAL SPI State structure definition
Kojto 112:6f327212ef96 107 */
Kojto 112:6f327212ef96 108 typedef enum
Kojto 112:6f327212ef96 109 {
Kojto 122:f9eeca106725 110 HAL_SPI_STATE_RESET = 0x00U, /*!< Peripheral not Initialized */
Kojto 122:f9eeca106725 111 HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
Kojto 122:f9eeca106725 112 HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
Kojto 122:f9eeca106725 113 HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */
Kojto 122:f9eeca106725 114 HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */
Kojto 122:f9eeca106725 115 HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */
Kojto 122:f9eeca106725 116 HAL_SPI_STATE_ERROR = 0x06U /*!< SPI error state */
Kojto 112:6f327212ef96 117 }HAL_SPI_StateTypeDef;
Kojto 112:6f327212ef96 118
Kojto 122:f9eeca106725 119 /**
Kojto 112:6f327212ef96 120 * @brief SPI handle Structure definition
Kojto 112:6f327212ef96 121 */
Kojto 112:6f327212ef96 122 typedef struct __SPI_HandleTypeDef
Kojto 112:6f327212ef96 123 {
Kojto 112:6f327212ef96 124 SPI_TypeDef *Instance; /* SPI registers base address */
Kojto 112:6f327212ef96 125
Kojto 112:6f327212ef96 126 SPI_InitTypeDef Init; /* SPI communication parameters */
Kojto 112:6f327212ef96 127
Kojto 112:6f327212ef96 128 uint8_t *pTxBuffPtr; /* Pointer to SPI Tx transfer Buffer */
Kojto 112:6f327212ef96 129
Kojto 122:f9eeca106725 130 uint16_t TxXferSize; /* SPI Tx Transfer size */
Kojto 122:f9eeca106725 131
Kojto 122:f9eeca106725 132 __IO uint16_t TxXferCount; /* SPI Tx Transfer Counter */
Kojto 112:6f327212ef96 133
Kojto 112:6f327212ef96 134 uint8_t *pRxBuffPtr; /* Pointer to SPI Rx transfer Buffer */
Kojto 112:6f327212ef96 135
Kojto 122:f9eeca106725 136 uint16_t RxXferSize; /* SPI Rx Transfer size */
Kojto 112:6f327212ef96 137
Kojto 122:f9eeca106725 138 __IO uint16_t RxXferCount; /* SPI Rx Transfer Counter */
Kojto 112:6f327212ef96 139
Kojto 112:6f327212ef96 140 void (*RxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Rx ISR */
Kojto 112:6f327212ef96 141
Kojto 112:6f327212ef96 142 void (*TxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Tx ISR */
Kojto 112:6f327212ef96 143
Kojto 122:f9eeca106725 144 DMA_HandleTypeDef *hdmatx; /* SPI Tx DMA Handle parameters */
Kojto 122:f9eeca106725 145
Kojto 122:f9eeca106725 146 DMA_HandleTypeDef *hdmarx; /* SPI Rx DMA Handle parameters */
Kojto 122:f9eeca106725 147
Kojto 122:f9eeca106725 148 HAL_LockTypeDef Lock; /* Locking object */
Kojto 112:6f327212ef96 149
Kojto 112:6f327212ef96 150 __IO HAL_SPI_StateTypeDef State; /* SPI communication state */
Kojto 112:6f327212ef96 151
Kojto 112:6f327212ef96 152 __IO uint32_t ErrorCode; /* SPI Error code */
Kojto 112:6f327212ef96 153
Kojto 112:6f327212ef96 154 }SPI_HandleTypeDef;
Kojto 122:f9eeca106725 155
Kojto 112:6f327212ef96 156 /**
Kojto 112:6f327212ef96 157 * @}
Kojto 112:6f327212ef96 158 */
Kojto 112:6f327212ef96 159
Kojto 112:6f327212ef96 160 /* Exported constants --------------------------------------------------------*/
Kojto 112:6f327212ef96 161 /** @defgroup SPI_Exported_Constants SPI Exported Constants
Kojto 112:6f327212ef96 162 * @{
Kojto 112:6f327212ef96 163 */
Kojto 112:6f327212ef96 164
Kojto 112:6f327212ef96 165 /** @defgroup SPI_Error_Code SPI Error Code
Kojto 112:6f327212ef96 166 * @{
Kojto 122:f9eeca106725 167 */
Kojto 122:f9eeca106725 168 #define HAL_SPI_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
Kojto 122:f9eeca106725 169 #define HAL_SPI_ERROR_MODF ((uint32_t)0x00000001U) /*!< MODF error */
Kojto 122:f9eeca106725 170 #define HAL_SPI_ERROR_CRC ((uint32_t)0x00000002U) /*!< CRC error */
Kojto 122:f9eeca106725 171 #define HAL_SPI_ERROR_OVR ((uint32_t)0x00000004U) /*!< OVR error */
Kojto 122:f9eeca106725 172 #define HAL_SPI_ERROR_FRE ((uint32_t)0x00000008U) /*!< FRE error */
Kojto 122:f9eeca106725 173 #define HAL_SPI_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */
Kojto 122:f9eeca106725 174 #define HAL_SPI_ERROR_FLAG ((uint32_t)0x00000020U) /*!< Flag: RXNE,TXE, BSY */
Kojto 112:6f327212ef96 175 /**
Kojto 112:6f327212ef96 176 * @}
Kojto 112:6f327212ef96 177 */
Kojto 112:6f327212ef96 178
Kojto 122:f9eeca106725 179 /** @defgroup SPI_Mode SPI Mode
Kojto 112:6f327212ef96 180 * @{
Kojto 112:6f327212ef96 181 */
Kojto 122:f9eeca106725 182 #define SPI_MODE_SLAVE ((uint32_t)0x00000000U)
Kojto 112:6f327212ef96 183 #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
Kojto 112:6f327212ef96 184 /**
Kojto 112:6f327212ef96 185 * @}
Kojto 112:6f327212ef96 186 */
Kojto 112:6f327212ef96 187
Kojto 122:f9eeca106725 188 /** @defgroup SPI_Direction SPI Direction Mode
Kojto 112:6f327212ef96 189 * @{
Kojto 112:6f327212ef96 190 */
Kojto 122:f9eeca106725 191 #define SPI_DIRECTION_2LINES ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 192 #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
Kojto 122:f9eeca106725 193 #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
Kojto 112:6f327212ef96 194 /**
Kojto 112:6f327212ef96 195 * @}
Kojto 112:6f327212ef96 196 */
Kojto 112:6f327212ef96 197
Kojto 122:f9eeca106725 198 /** @defgroup SPI_Data_Size SPI Data Size
Kojto 112:6f327212ef96 199 * @{
Kojto 112:6f327212ef96 200 */
Kojto 122:f9eeca106725 201 #define SPI_DATASIZE_8BIT ((uint32_t)0x00000000U)
Kojto 112:6f327212ef96 202 #define SPI_DATASIZE_16BIT SPI_CR1_DFF
Kojto 112:6f327212ef96 203 /**
Kojto 112:6f327212ef96 204 * @}
Kojto 122:f9eeca106725 205 */
Kojto 112:6f327212ef96 206
Kojto 122:f9eeca106725 207 /** @defgroup SPI_Clock_Polarity SPI Clock Polarity
Kojto 112:6f327212ef96 208 * @{
Kojto 112:6f327212ef96 209 */
Kojto 122:f9eeca106725 210 #define SPI_POLARITY_LOW ((uint32_t)0x00000000U)
Kojto 112:6f327212ef96 211 #define SPI_POLARITY_HIGH SPI_CR1_CPOL
Kojto 112:6f327212ef96 212 /**
Kojto 112:6f327212ef96 213 * @}
Kojto 112:6f327212ef96 214 */
Kojto 112:6f327212ef96 215
Kojto 112:6f327212ef96 216 /** @defgroup SPI_Clock_Phase SPI Clock Phase
Kojto 112:6f327212ef96 217 * @{
Kojto 112:6f327212ef96 218 */
Kojto 122:f9eeca106725 219 #define SPI_PHASE_1EDGE ((uint32_t)0x00000000U)
Kojto 112:6f327212ef96 220 #define SPI_PHASE_2EDGE SPI_CR1_CPHA
Kojto 112:6f327212ef96 221 /**
Kojto 112:6f327212ef96 222 * @}
Kojto 112:6f327212ef96 223 */
Kojto 112:6f327212ef96 224
Kojto 112:6f327212ef96 225 /** @defgroup SPI_Slave_Select_management SPI Slave Select Management
Kojto 112:6f327212ef96 226 * @{
Kojto 112:6f327212ef96 227 */
Kojto 112:6f327212ef96 228 #define SPI_NSS_SOFT SPI_CR1_SSM
Kojto 122:f9eeca106725 229 #define SPI_NSS_HARD_INPUT ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 230 #define SPI_NSS_HARD_OUTPUT ((uint32_t)0x00040000U)
Kojto 112:6f327212ef96 231 /**
Kojto 112:6f327212ef96 232 * @}
Kojto 122:f9eeca106725 233 */
Kojto 112:6f327212ef96 234
Kojto 112:6f327212ef96 235 /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
Kojto 112:6f327212ef96 236 * @{
Kojto 112:6f327212ef96 237 */
Kojto 122:f9eeca106725 238 #define SPI_BAUDRATEPRESCALER_2 ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 239 #define SPI_BAUDRATEPRESCALER_4 ((uint32_t)0x00000008U)
Kojto 122:f9eeca106725 240 #define SPI_BAUDRATEPRESCALER_8 ((uint32_t)0x00000010U)
Kojto 122:f9eeca106725 241 #define SPI_BAUDRATEPRESCALER_16 ((uint32_t)0x00000018U)
Kojto 122:f9eeca106725 242 #define SPI_BAUDRATEPRESCALER_32 ((uint32_t)0x00000020U)
Kojto 122:f9eeca106725 243 #define SPI_BAUDRATEPRESCALER_64 ((uint32_t)0x00000028U)
Kojto 122:f9eeca106725 244 #define SPI_BAUDRATEPRESCALER_128 ((uint32_t)0x00000030U)
Kojto 122:f9eeca106725 245 #define SPI_BAUDRATEPRESCALER_256 ((uint32_t)0x00000038U)
Kojto 112:6f327212ef96 246 /**
Kojto 112:6f327212ef96 247 * @}
Kojto 122:f9eeca106725 248 */
Kojto 112:6f327212ef96 249
Kojto 122:f9eeca106725 250 /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission
Kojto 112:6f327212ef96 251 * @{
Kojto 112:6f327212ef96 252 */
Kojto 122:f9eeca106725 253 #define SPI_FIRSTBIT_MSB ((uint32_t)0x00000000U)
Kojto 112:6f327212ef96 254 #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
Kojto 112:6f327212ef96 255 /**
Kojto 112:6f327212ef96 256 * @}
Kojto 112:6f327212ef96 257 */
Kojto 112:6f327212ef96 258
Kojto 112:6f327212ef96 259 /** @defgroup SPI_TI_mode SPI TI Mode
Kojto 112:6f327212ef96 260 * @{
Kojto 112:6f327212ef96 261 */
Kojto 122:f9eeca106725 262 #define SPI_TIMODE_DISABLE ((uint32_t)0x00000000U)
Kojto 112:6f327212ef96 263 #define SPI_TIMODE_ENABLE SPI_CR2_FRF
Kojto 112:6f327212ef96 264 /**
Kojto 112:6f327212ef96 265 * @}
Kojto 112:6f327212ef96 266 */
Kojto 112:6f327212ef96 267
Kojto 112:6f327212ef96 268 /** @defgroup SPI_CRC_Calculation SPI CRC Calculation
Kojto 112:6f327212ef96 269 * @{
Kojto 112:6f327212ef96 270 */
Kojto 122:f9eeca106725 271 #define SPI_CRCCALCULATION_DISABLE ((uint32_t)0x00000000U)
Kojto 112:6f327212ef96 272 #define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN
Kojto 112:6f327212ef96 273 /**
Kojto 112:6f327212ef96 274 * @}
Kojto 112:6f327212ef96 275 */
Kojto 112:6f327212ef96 276
Kojto 112:6f327212ef96 277 /** @defgroup SPI_Interrupt_definition SPI Interrupt Definition
Kojto 112:6f327212ef96 278 * @{
Kojto 112:6f327212ef96 279 */
Kojto 112:6f327212ef96 280 #define SPI_IT_TXE SPI_CR2_TXEIE
Kojto 112:6f327212ef96 281 #define SPI_IT_RXNE SPI_CR2_RXNEIE
Kojto 112:6f327212ef96 282 #define SPI_IT_ERR SPI_CR2_ERRIE
Kojto 112:6f327212ef96 283 /**
Kojto 112:6f327212ef96 284 * @}
Kojto 112:6f327212ef96 285 */
Kojto 112:6f327212ef96 286
Kojto 122:f9eeca106725 287 /** @defgroup SPI_Flags_definition SPI Flags Definition
Kojto 112:6f327212ef96 288 * @{
Kojto 112:6f327212ef96 289 */
Kojto 122:f9eeca106725 290 #define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */
Kojto 122:f9eeca106725 291 #define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */
Kojto 122:f9eeca106725 292 #define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */
Kojto 122:f9eeca106725 293 #define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */
Kojto 122:f9eeca106725 294 #define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */
Kojto 122:f9eeca106725 295 #define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */
Kojto 122:f9eeca106725 296 #define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */
Kojto 112:6f327212ef96 297 /**
Kojto 112:6f327212ef96 298 * @}
Kojto 112:6f327212ef96 299 */
Kojto 112:6f327212ef96 300
Kojto 112:6f327212ef96 301 /**
Kojto 112:6f327212ef96 302 * @}
Kojto 112:6f327212ef96 303 */
Kojto 112:6f327212ef96 304
Kojto 112:6f327212ef96 305 /* Exported macro ------------------------------------------------------------*/
Kojto 112:6f327212ef96 306 /** @defgroup SPI_Exported_Macros SPI Exported Macros
Kojto 112:6f327212ef96 307 * @{
Kojto 112:6f327212ef96 308 */
Kojto 122:f9eeca106725 309
Kojto 122:f9eeca106725 310 /** @brief Reset SPI handle state.
Kojto 122:f9eeca106725 311 * @param __HANDLE__: specifies the SPI Handle.
Kojto 112:6f327212ef96 312 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 313 * @retval None
Kojto 112:6f327212ef96 314 */
Kojto 112:6f327212ef96 315 #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
Kojto 112:6f327212ef96 316
Kojto 112:6f327212ef96 317 /** @brief Enable or disable the specified SPI interrupts.
Kojto 122:f9eeca106725 318 * @param __HANDLE__: specifies the SPI Handle.
Kojto 112:6f327212ef96 319 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 320 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
Kojto 112:6f327212ef96 321 * This parameter can be one of the following values:
Kojto 112:6f327212ef96 322 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
Kojto 112:6f327212ef96 323 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
Kojto 112:6f327212ef96 324 * @arg SPI_IT_ERR: Error interrupt enable
Kojto 112:6f327212ef96 325 * @retval None
Kojto 112:6f327212ef96 326 */
Kojto 112:6f327212ef96 327 #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
Kojto 112:6f327212ef96 328 #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__)))
Kojto 112:6f327212ef96 329
Kojto 122:f9eeca106725 330 /** @brief Check whether the specified SPI interrupt source is enabled or not.
Kojto 122:f9eeca106725 331 * @param __HANDLE__: specifies the SPI Handle.
Kojto 112:6f327212ef96 332 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 333 * @param __INTERRUPT__: specifies the SPI interrupt source to check.
Kojto 112:6f327212ef96 334 * This parameter can be one of the following values:
Kojto 112:6f327212ef96 335 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
Kojto 112:6f327212ef96 336 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
Kojto 112:6f327212ef96 337 * @arg SPI_IT_ERR: Error interrupt enable
Kojto 112:6f327212ef96 338 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 112:6f327212ef96 339 */
Kojto 112:6f327212ef96 340 #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
Kojto 112:6f327212ef96 341
Kojto 112:6f327212ef96 342 /** @brief Check whether the specified SPI flag is set or not.
Kojto 122:f9eeca106725 343 * @param __HANDLE__: specifies the SPI Handle.
Kojto 112:6f327212ef96 344 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 345 * @param __FLAG__: specifies the flag to check.
Kojto 112:6f327212ef96 346 * This parameter can be one of the following values:
Kojto 112:6f327212ef96 347 * @arg SPI_FLAG_RXNE: Receive buffer not empty flag
Kojto 112:6f327212ef96 348 * @arg SPI_FLAG_TXE: Transmit buffer empty flag
Kojto 112:6f327212ef96 349 * @arg SPI_FLAG_CRCERR: CRC error flag
Kojto 112:6f327212ef96 350 * @arg SPI_FLAG_MODF: Mode fault flag
Kojto 112:6f327212ef96 351 * @arg SPI_FLAG_OVR: Overrun flag
Kojto 112:6f327212ef96 352 * @arg SPI_FLAG_BSY: Busy flag
Kojto 122:f9eeca106725 353 * @arg SPI_FLAG_FRE: Frame format error flag
Kojto 112:6f327212ef96 354 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 112:6f327212ef96 355 */
Kojto 112:6f327212ef96 356 #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 112:6f327212ef96 357
Kojto 112:6f327212ef96 358 /** @brief Clear the SPI CRCERR pending flag.
Kojto 122:f9eeca106725 359 * @param __HANDLE__: specifies the SPI Handle.
Kojto 122:f9eeca106725 360 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 122:f9eeca106725 361 * @retval None
Kojto 122:f9eeca106725 362 */
Kojto 122:f9eeca106725 363 #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR))
Kojto 122:f9eeca106725 364
Kojto 122:f9eeca106725 365 /** @brief Clear the SPI MODF pending flag.
Kojto 122:f9eeca106725 366 * @param __HANDLE__: specifies the SPI Handle.
Kojto 122:f9eeca106725 367 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 122:f9eeca106725 368 * @retval None
Kojto 122:f9eeca106725 369 */
Kojto 122:f9eeca106725 370 #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \
Kojto 122:f9eeca106725 371 do{ \
Kojto 122:f9eeca106725 372 __IO uint32_t tmpreg_modf = 0x00U; \
Kojto 122:f9eeca106725 373 tmpreg_modf = (__HANDLE__)->Instance->SR; \
Kojto 122:f9eeca106725 374 (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE); \
Kojto 122:f9eeca106725 375 UNUSED(tmpreg_modf); \
Kojto 122:f9eeca106725 376 } while(0)
Kojto 122:f9eeca106725 377
Kojto 122:f9eeca106725 378 /** @brief Clear the SPI OVR pending flag.
Kojto 122:f9eeca106725 379 * @param __HANDLE__: specifies the SPI Handle.
Kojto 112:6f327212ef96 380 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 381 * @retval None
Kojto 112:6f327212ef96 382 */
Kojto 122:f9eeca106725 383 #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \
Kojto 122:f9eeca106725 384 do{ \
Kojto 122:f9eeca106725 385 __IO uint32_t tmpreg_ovr = 0x00U; \
Kojto 122:f9eeca106725 386 tmpreg_ovr = (__HANDLE__)->Instance->DR; \
Kojto 122:f9eeca106725 387 tmpreg_ovr = (__HANDLE__)->Instance->SR; \
Kojto 122:f9eeca106725 388 UNUSED(tmpreg_ovr); \
Kojto 122:f9eeca106725 389 } while(0)
Kojto 112:6f327212ef96 390
Kojto 122:f9eeca106725 391 /** @brief Clear the SPI FRE pending flag.
Kojto 122:f9eeca106725 392 * @param __HANDLE__: specifies the SPI Handle.
Kojto 122:f9eeca106725 393 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 394 * @retval None
Kojto 112:6f327212ef96 395 */
Kojto 122:f9eeca106725 396 #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \
Kojto 122:f9eeca106725 397 do{ \
Kojto 122:f9eeca106725 398 __IO uint32_t tmpreg_fre = 0x00U; \
Kojto 122:f9eeca106725 399 tmpreg_fre = (__HANDLE__)->Instance->SR; \
Kojto 122:f9eeca106725 400 UNUSED(tmpreg_fre); \
Kojto 122:f9eeca106725 401 }while(0)
Kojto 112:6f327212ef96 402
Kojto 122:f9eeca106725 403 /** @brief Enable the SPI peripheral.
Kojto 122:f9eeca106725 404 * @param __HANDLE__: specifies the SPI Handle.
Kojto 112:6f327212ef96 405 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 406 * @retval None
Kojto 112:6f327212ef96 407 */
Kojto 112:6f327212ef96 408 #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE)
Kojto 112:6f327212ef96 409
Kojto 122:f9eeca106725 410 /** @brief Disable the SPI peripheral.
Kojto 122:f9eeca106725 411 * @param __HANDLE__: specifies the SPI Handle.
Kojto 122:f9eeca106725 412 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 112:6f327212ef96 413 * @retval None
Kojto 112:6f327212ef96 414 */
Kojto 122:f9eeca106725 415 #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE))
Kojto 112:6f327212ef96 416 /**
Kojto 112:6f327212ef96 417 * @}
Kojto 112:6f327212ef96 418 */
Kojto 122:f9eeca106725 419
Kojto 112:6f327212ef96 420 /* Exported functions --------------------------------------------------------*/
Kojto 112:6f327212ef96 421 /** @addtogroup SPI_Exported_Functions
Kojto 112:6f327212ef96 422 * @{
Kojto 112:6f327212ef96 423 */
Kojto 112:6f327212ef96 424
Kojto 112:6f327212ef96 425 /** @addtogroup SPI_Exported_Functions_Group1
Kojto 112:6f327212ef96 426 * @{
Kojto 112:6f327212ef96 427 */
Kojto 112:6f327212ef96 428 /* Initialization/de-initialization functions **********************************/
Kojto 112:6f327212ef96 429 HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 430 HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 431 void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 432 void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 433 /**
Kojto 112:6f327212ef96 434 * @}
Kojto 112:6f327212ef96 435 */
Kojto 112:6f327212ef96 436
Kojto 112:6f327212ef96 437 /** @addtogroup SPI_Exported_Functions_Group2
Kojto 112:6f327212ef96 438 * @{
Kojto 112:6f327212ef96 439 */
Kojto 112:6f327212ef96 440 /* I/O operation functions *****************************************************/
Kojto 112:6f327212ef96 441 HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 112:6f327212ef96 442 HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 112:6f327212ef96 443 HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
Kojto 112:6f327212ef96 444 HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
Kojto 112:6f327212ef96 445 HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
Kojto 112:6f327212ef96 446 HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
Kojto 112:6f327212ef96 447 HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
Kojto 112:6f327212ef96 448 HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
Kojto 112:6f327212ef96 449 HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
Kojto 112:6f327212ef96 450 HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 451 HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 452 HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 453
Kojto 112:6f327212ef96 454 void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 455 void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 456 void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 457 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 458 void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 459 void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 460 void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
Kojto 122:f9eeca106725 461 void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 462 /**
Kojto 112:6f327212ef96 463 * @}
Kojto 112:6f327212ef96 464 */
Kojto 122:f9eeca106725 465
Kojto 112:6f327212ef96 466 /** @addtogroup SPI_Exported_Functions_Group3
Kojto 112:6f327212ef96 467 * @{
Kojto 112:6f327212ef96 468 */
Kojto 122:f9eeca106725 469 /* Peripheral State and Error functions ***************************************/
Kojto 112:6f327212ef96 470 HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi);
Kojto 122:f9eeca106725 471 uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi);
Kojto 112:6f327212ef96 472 /**
Kojto 112:6f327212ef96 473 * @}
Kojto 122:f9eeca106725 474 */
Kojto 112:6f327212ef96 475
Kojto 112:6f327212ef96 476 /**
Kojto 112:6f327212ef96 477 * @}
Kojto 112:6f327212ef96 478 */
Kojto 122:f9eeca106725 479
Kojto 112:6f327212ef96 480 /* Private types -------------------------------------------------------------*/
Kojto 112:6f327212ef96 481 /* Private variables ---------------------------------------------------------*/
Kojto 112:6f327212ef96 482 /* Private constants ---------------------------------------------------------*/
Kojto 112:6f327212ef96 483
Kojto 112:6f327212ef96 484 /* Private macros ------------------------------------------------------------*/
Kojto 112:6f327212ef96 485 /** @defgroup SPI_Private_Macros SPI Private Macros
Kojto 112:6f327212ef96 486 * @{
Kojto 112:6f327212ef96 487 */
Kojto 112:6f327212ef96 488
Kojto 122:f9eeca106725 489 /** @brief Set the SPI transmit-only mode.
Kojto 122:f9eeca106725 490 * @param __HANDLE__: specifies the SPI Handle.
Kojto 122:f9eeca106725 491 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 122:f9eeca106725 492 * @retval None
Kojto 122:f9eeca106725 493 */
Kojto 122:f9eeca106725 494 #define SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE)
Kojto 122:f9eeca106725 495
Kojto 122:f9eeca106725 496 /** @brief Set the SPI receive-only mode.
Kojto 122:f9eeca106725 497 * @param __HANDLE__: specifies the SPI Handle.
Kojto 122:f9eeca106725 498 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 122:f9eeca106725 499 * @retval None
Kojto 122:f9eeca106725 500 */
Kojto 122:f9eeca106725 501 #define SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_BIDIOE))
Kojto 122:f9eeca106725 502
Kojto 122:f9eeca106725 503 /** @brief Reset the CRC calculation of the SPI.
Kojto 122:f9eeca106725 504 * @param __HANDLE__: specifies the SPI Handle.
Kojto 122:f9eeca106725 505 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
Kojto 122:f9eeca106725 506 * @retval None
Kojto 122:f9eeca106725 507 */
Kojto 122:f9eeca106725 508 #define SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (uint16_t)(~SPI_CR1_CRCEN);\
Kojto 122:f9eeca106725 509 (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0)
Kojto 122:f9eeca106725 510
Kojto 112:6f327212ef96 511 #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \
Kojto 112:6f327212ef96 512 ((MODE) == SPI_MODE_MASTER))
Kojto 112:6f327212ef96 513
Kojto 122:f9eeca106725 514 #define IS_SPI_DIRECTION(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \
Kojto 122:f9eeca106725 515 ((MODE) == SPI_DIRECTION_2LINES_RXONLY) || \
Kojto 122:f9eeca106725 516 ((MODE) == SPI_DIRECTION_1LINE))
Kojto 122:f9eeca106725 517
Kojto 122:f9eeca106725 518 #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES)
Kojto 112:6f327212ef96 519
Kojto 112:6f327212ef96 520 #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \
Kojto 112:6f327212ef96 521 ((MODE) == SPI_DIRECTION_1LINE))
Kojto 112:6f327212ef96 522
Kojto 112:6f327212ef96 523 #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \
Kojto 112:6f327212ef96 524 ((DATASIZE) == SPI_DATASIZE_8BIT))
Kojto 112:6f327212ef96 525
Kojto 112:6f327212ef96 526 #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \
Kojto 122:f9eeca106725 527 ((CPOL) == SPI_POLARITY_HIGH))
Kojto 112:6f327212ef96 528
Kojto 112:6f327212ef96 529 #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \
Kojto 112:6f327212ef96 530 ((CPHA) == SPI_PHASE_2EDGE))
Kojto 112:6f327212ef96 531
Kojto 112:6f327212ef96 532 #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \
Kojto 112:6f327212ef96 533 ((NSS) == SPI_NSS_HARD_INPUT) || \
Kojto 112:6f327212ef96 534 ((NSS) == SPI_NSS_HARD_OUTPUT))
Kojto 112:6f327212ef96 535
Kojto 112:6f327212ef96 536 #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \
Kojto 112:6f327212ef96 537 ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \
Kojto 112:6f327212ef96 538 ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \
Kojto 112:6f327212ef96 539 ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \
Kojto 112:6f327212ef96 540 ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \
Kojto 112:6f327212ef96 541 ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \
Kojto 112:6f327212ef96 542 ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \
Kojto 112:6f327212ef96 543 ((PRESCALER) == SPI_BAUDRATEPRESCALER_256))
Kojto 112:6f327212ef96 544
Kojto 112:6f327212ef96 545 #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \
Kojto 112:6f327212ef96 546 ((BIT) == SPI_FIRSTBIT_LSB))
Kojto 112:6f327212ef96 547
Kojto 112:6f327212ef96 548 #define IS_SPI_TIMODE(MODE) (((MODE) == SPI_TIMODE_DISABLE) || \
Kojto 112:6f327212ef96 549 ((MODE) == SPI_TIMODE_ENABLE))
Kojto 112:6f327212ef96 550
Kojto 112:6f327212ef96 551 #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLE) || \
Kojto 112:6f327212ef96 552 ((CALCULATION) == SPI_CRCCALCULATION_ENABLE))
Kojto 112:6f327212ef96 553
Kojto 122:f9eeca106725 554 #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x01U) && ((POLYNOMIAL) <= 0xFFFFU))
Kojto 112:6f327212ef96 555
Kojto 112:6f327212ef96 556 /**
Kojto 112:6f327212ef96 557 * @}
Kojto 112:6f327212ef96 558 */
Kojto 112:6f327212ef96 559
Kojto 112:6f327212ef96 560 /* Private functions ---------------------------------------------------------*/
Kojto 112:6f327212ef96 561 /** @defgroup SPI_Private_Functions SPI Private Functions
Kojto 112:6f327212ef96 562 * @{
Kojto 112:6f327212ef96 563 */
Kojto 112:6f327212ef96 564
Kojto 112:6f327212ef96 565 /**
Kojto 112:6f327212ef96 566 * @}
Kojto 112:6f327212ef96 567 */
Kojto 112:6f327212ef96 568
Kojto 112:6f327212ef96 569 /**
Kojto 112:6f327212ef96 570 * @}
Kojto 122:f9eeca106725 571 */
Kojto 112:6f327212ef96 572
Kojto 112:6f327212ef96 573 /**
Kojto 112:6f327212ef96 574 * @}
Kojto 112:6f327212ef96 575 */
Kojto 112:6f327212ef96 576
Kojto 112:6f327212ef96 577 #ifdef __cplusplus
Kojto 112:6f327212ef96 578 }
Kojto 112:6f327212ef96 579 #endif
Kojto 112:6f327212ef96 580
Kojto 112:6f327212ef96 581 #endif /* __STM32F4xx_HAL_SPI_H */
Kojto 112:6f327212ef96 582
Kojto 112:6f327212ef96 583 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/