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:
99:dbbf35b96557
.

Who changed what in which revision?

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