Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
116:c0f6e94411f5
.

Who changed what in which revision?

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