2 ******************************************************************************
3 * @file stm32l0xx_hal_spi.h
4 * @author MCD Application Team
6 * @date 06-February-2015
7 * @brief Header file of SPI HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32L0xx_HAL_SPI_H
40 #define __STM32L0xx_HAL_SPI_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
49 /** @addtogroup STM32L0xx_HAL_Driver
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup SPI_Exported_Types SPI Exported Types
63 * @brief SPI Configuration Structure definition
67 uint32_t Mode; /*!< Specifies the SPI operating mode.
68 This parameter can be a value of @ref SPI_mode */
70 uint32_t Direction; /*!< Specifies the SPI Directional mode state.
71 This parameter can be a value of @ref SPI_Direction_mode */
73 uint32_t DataSize; /*!< Specifies the SPI data size.
74 This parameter can be a value of @ref SPI_data_size */
76 uint32_t CLKPolarity; /*!< Specifies the serial clock steady state.
77 This parameter can be a value of @ref SPI_Clock_Polarity */
79 uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture.
80 This parameter can be a value of @ref SPI_Clock_Phase */
82 uint32_t NSS; /*!< Specifies whether the NSS signal is managed by
83 hardware (NSS pin) or by software using the SSI bit.
84 This parameter can be a value of @ref SPI_Slave_Select_management */
86 uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
87 used to configure the transmit and receive SCK clock.
88 This parameter can be a value of @ref SPI_BaudRate_Prescaler
89 @note The communication clock is derived from the master
90 clock. The slave clock does not need to be set */
92 uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
93 This parameter can be a value of @ref SPI_MSB_LSB_transmission */
95 uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not.
96 This parameter can be a value of @ref SPI_TI_mode */
98 uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
99 This parameter can be a value of @ref SPI_CRC_Calculation */
101 uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation.
102 This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */
107 * @brief HAL SPI State structure definition
111 HAL_SPI_STATE_RESET = 0x00, /*!< SPI not yet initialized or disabled */
112 HAL_SPI_STATE_READY = 0x01, /*!< SPI initialized and ready for use */
113 HAL_SPI_STATE_BUSY = 0x02, /*!< SPI process is ongoing */
114 HAL_SPI_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
115 HAL_SPI_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
116 HAL_SPI_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
117 HAL_SPI_STATE_ERROR = 0x03 /*!< SPI error state */
119 }HAL_SPI_StateTypeDef;
122 * @brief SPI handle Structure definition
124 typedef struct __SPI_HandleTypeDef
126 SPI_TypeDef *Instance; /*!< SPI registers base address */
128 SPI_InitTypeDef Init; /*!< SPI communication parameters */
130 uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */
132 uint16_t TxXferSize; /*!< SPI Tx transfer size */
134 uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */
136 uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */
138 uint16_t RxXferSize; /*!< SPI Rx transfer size */
140 uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */
142 DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA handle parameters */
144 DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA handle parameters */
146 void (*RxISR)(struct __SPI_HandleTypeDef * hspi); /*!< function pointer on Rx ISR */
148 void (*TxISR)(struct __SPI_HandleTypeDef * hspi); /*!< function pointer on Tx ISR */
150 HAL_LockTypeDef Lock; /*!< SPI locking object */
152 __IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */
154 __IO uint32_t ErrorCode; /*!< SPI Error code */
162 /* Exported constants --------------------------------------------------------*/
164 /** @defgroup SPI_Exported_Constants SPI Exported Constants
169 * @defgroup SPI_ErrorCode SPI Error Code
172 #define HAL_SPI_ERROR_NONE ((uint32_t)0x00) /*!< No error */
173 #define HAL_SPI_ERROR_MODF ((uint32_t)0x01) /*!< MODF error */
174 #define HAL_SPI_ERROR_CRC ((uint32_t)0x02) /*!< CRC error */
175 #define HAL_SPI_ERROR_OVR ((uint32_t)0x04) /*!< OVR error */
176 #define HAL_SPI_ERROR_FRE ((uint32_t)0x08) /*!< FRE error */
177 #define HAL_SPI_ERROR_DMA ((uint32_t)0x10) /*!< DMA transfer error */
178 #define HAL_SPI_ERROR_FLAG ((uint32_t)0x20) /*!< Flag: RXNE,TXE, BSY */
183 /** @defgroup SPI_mode SPI mode
186 #define SPI_MODE_SLAVE ((uint32_t)0x00000000)
187 #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
193 /** @defgroup SPI_Direction_mode SPI Direction mode
196 #define SPI_DIRECTION_2LINES ((uint32_t)0x00000000)
197 #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
198 #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
204 /** @defgroup SPI_data_size SPI data size
207 #define SPI_DATASIZE_8BIT ((uint32_t)0x00000000)
208 #define SPI_DATASIZE_16BIT SPI_CR1_DFF
214 /** @defgroup SPI_Clock_Polarity SPI Clock Polarity
217 #define SPI_POLARITY_LOW ((uint32_t)0x00000000)
218 #define SPI_POLARITY_HIGH SPI_CR1_CPOL
224 /** @defgroup SPI_Clock_Phase SPI Clock Phase
227 #define SPI_PHASE_1EDGE ((uint32_t)0x00000000)
228 #define SPI_PHASE_2EDGE SPI_CR1_CPHA
234 /** @defgroup SPI_Slave_Select_management SPI Slave Select management
237 #define SPI_NSS_SOFT SPI_CR1_SSM
238 #define SPI_NSS_HARD_INPUT ((uint32_t)0x00000000)
239 #define SPI_NSS_HARD_OUTPUT ((uint32_t)(SPI_CR2_SSOE << 16))
245 /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
248 #define SPI_BAUDRATEPRESCALER_2 ((uint32_t)0x00000000)
249 #define SPI_BAUDRATEPRESCALER_4 ((uint32_t)SPI_CR1_BR_0)
250 #define SPI_BAUDRATEPRESCALER_8 ((uint32_t)SPI_CR1_BR_1)
251 #define SPI_BAUDRATEPRESCALER_16 ((uint32_t)SPI_CR1_BR_1 | SPI_CR1_BR_0)
252 #define SPI_BAUDRATEPRESCALER_32 ((uint32_t)SPI_CR1_BR_2)
253 #define SPI_BAUDRATEPRESCALER_64 ((uint32_t)SPI_CR1_BR_2 | SPI_CR1_BR_0)
254 #define SPI_BAUDRATEPRESCALER_128 ((uint32_t)SPI_CR1_BR_2 | SPI_CR1_BR_1)
255 #define SPI_BAUDRATEPRESCALER_256 ((uint32_t)SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
261 /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB transmission
264 #define SPI_FIRSTBIT_MSB ((uint32_t)0x00000000)
265 #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
271 /** @defgroup SPI_TI_mode SPI TI mode
274 #define SPI_TIMODE_DISABLE ((uint32_t)0x00000000)
275 #define SPI_TIMODE_ENABLE SPI_CR2_FRF
281 /** @defgroup SPI_CRC_Calculation SPI CRC Calculation
284 #define SPI_CRCCALCULATION_DISABLE ((uint32_t)0x00000000)
285 #define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN
291 /** @defgroup SPI_Interrupt_configuration_definition SPI Interrupt configuration definition
294 #define SPI_IT_TXE SPI_CR2_TXEIE
295 #define SPI_IT_RXNE SPI_CR2_RXNEIE
296 #define SPI_IT_ERR SPI_CR2_ERRIE
301 /** @defgroup SPI_Flag_definition SPI Flag definition
304 #define SPI_FLAG_RXNE SPI_SR_RXNE
305 #define SPI_FLAG_TXE SPI_SR_TXE
306 #define SPI_FLAG_CRCERR SPI_SR_CRCERR
307 #define SPI_FLAG_MODF SPI_SR_MODF
308 #define SPI_FLAG_OVR SPI_SR_OVR
309 #define SPI_FLAG_BSY SPI_SR_BSY
310 #define SPI_FLAG_FRE SPI_SR_FRE
321 /* Exported macro ------------------------------------------------------------*/
322 /** @defgroup SPI_Exported_Macros SPI Exported Macros
326 /** @brief Reset SPI handle state
327 * @param __HANDLE__: specifies the SPI handle.
328 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
331 #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
333 /** @brief Enable the specified SPI interrupts.
334 * @param __HANDLE__: specifies the SPI handle.
335 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
336 * @param __INTERRUPT__: specifies the interrupt source to enable.
337 * This parameter can be one of the following values:
338 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
339 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
340 * @arg SPI_IT_ERR: Error interrupt enable
343 #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
345 /** @brief Disable the specified SPI interrupts.
346 * @param __HANDLE__: specifies the SPI handle.
347 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
348 * @param __INTERRUPT__: specifies the interrupt source to disable.
349 * This parameter can be one of the following values:
350 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
351 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
352 * @arg SPI_IT_ERR: Error interrupt enable
355 #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
357 /** @brief Check if the specified SPI interrupt source is enabled or disabled.
358 * @param __HANDLE__: specifies the SPI handle.
359 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
360 * @param __INTERRUPT__: specifies the SPI interrupt source to check.
361 * This parameter can be one of the following values:
362 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
363 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
364 * @arg SPI_IT_ERR: Error interrupt enable
365 * @retval The new state of __IT__ (TRUE or FALSE).
367 #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
369 /** @brief Check whether the specified SPI flag is set or not.
370 * @param __HANDLE__: specifies the SPI handle.
371 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
372 * @param __FLAG__: specifies the flag to check.
373 * This parameter can be one of the following values:
374 * @arg SPI_FLAG_RXNE: Receive buffer not empty flag
375 * @arg SPI_FLAG_TXE: Transmit buffer empty flag
376 * @arg SPI_FLAG_CRCERR: CRC error flag
377 * @arg SPI_FLAG_MODF: Mode fault flag
378 * @arg SPI_FLAG_OVR: Overrun flag
379 * @arg SPI_FLAG_BSY: Busy flag
380 * @arg SPI_FLAG_FRE: Frame format error flag
381 * @retval The new state of __FLAG__ (TRUE or FALSE).
383 #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
385 /** @brief Clear the SPI CRCERR pending flag.
386 * @param __HANDLE__: specifies the SPI handle.
387 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
390 #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = ~(SPI_FLAG_CRCERR))
392 /** @brief Clear the SPI MODF pending flag.
393 * @param __HANDLE__: specifies the SPI handle.
394 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
397 #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \
399 __IO uint32_t tmpreg; \
400 tmpreg = (__HANDLE__)->Instance->SR; \
401 (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE); \
405 /** @brief Clear the SPI OVR pending flag.
406 * @param __HANDLE__: specifies the SPI handle.
407 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
410 #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \
412 __IO uint32_t tmpreg; \
413 tmpreg = (__HANDLE__)->Instance->DR; \
414 tmpreg = (__HANDLE__)->Instance->SR; \
418 /** @brief Clear the SPI FRE pending flag.
419 * @param __HANDLE__: specifies the SPI handle.
420 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
423 #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \
425 __IO uint32_t tmpreg; \
426 tmpreg = (__HANDLE__)->Instance->SR; \
430 /** @brief Enables the SPI.
431 * @param __HANDLE__: specifies the SPI Handle.
432 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
435 #define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
437 /** @brief Disables the SPI.
438 * @param __HANDLE__: specifies the SPI Handle.
439 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
442 #define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
448 /* Private macros -----------------------------------------------------------*/
449 /** @defgroup SPI_Private_Macros SPI Private Macros
453 /** @brief Checks if SPI Mode parameter is in allowed range.
454 * @param __MODE__: specifies the SPI Mode.
455 * This parameter can be a value of @ref SPI_mode
458 #define IS_SPI_MODE(__MODE__) (((__MODE__) == SPI_MODE_SLAVE) || ((__MODE__) == SPI_MODE_MASTER))
460 /** @brief Checks if SPI Direction Mode parameter is in allowed range.
461 * @param __MODE__: specifies the SPI Direction Mode.
462 * This parameter can be a value of @ref SPI_Direction_mode
465 #define IS_SPI_DIRECTION_MODE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
466 ((__MODE__) == SPI_DIRECTION_2LINES_RXONLY) || \
467 ((__MODE__) == SPI_DIRECTION_1LINE))
469 /** @brief Checks if SPI Direction Mode parameter is 1 or 2 lines.
470 * @param __MODE__: specifies the SPI Direction Mode.
473 #define IS_SPI_DIRECTION_2LINES_OR_1LINE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
474 ((__MODE__) == SPI_DIRECTION_1LINE))
476 /** @brief Checks if SPI Direction Mode parameter is 2 lines.
477 * @param __MODE__: specifies the SPI Direction Mode.
480 #define IS_SPI_DIRECTION_2LINES(__MODE__) ((__MODE__) == SPI_DIRECTION_2LINES)
482 /** @brief Checks if SPI Data Size parameter is in allowed range.
483 * @param __DATASIZE__: specifies the SPI Data Size.
484 * This parameter can be a value of @ref SPI_data_size
487 #define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) == SPI_DATASIZE_16BIT) || \
488 ((__DATASIZE__) == SPI_DATASIZE_8BIT))
490 /** @brief Checks if SPI Serial clock steady state parameter is in allowed range.
491 * @param __CPOL__: specifies the SPI serial clock steady state.
492 * This parameter can be a value of @ref SPI_Clock_Polarity
495 #define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \
496 ((__CPOL__) == SPI_POLARITY_HIGH))
498 /** @brief Checks if SPI Clock Phase parameter is in allowed range.
499 * @param __CPHA__: specifies the SPI Clock Phase.
500 * This parameter can be a value of @ref SPI_Clock_Phase
503 #define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \
504 ((__CPHA__) == SPI_PHASE_2EDGE))
506 /** @brief Checks if SPI Slave select parameter is in allowed range.
507 * @param __NSS__: specifies the SPI Slave Slelect management parameter.
508 * This parameter can be a value of @ref SPI_Slave_Select_management
511 #define IS_SPI_NSS(__NSS__) (((__NSS__) == SPI_NSS_SOFT) || \
512 ((__NSS__) == SPI_NSS_HARD_INPUT) || \
513 ((__NSS__) == SPI_NSS_HARD_OUTPUT))
515 /** @brief Checks if SPI Baudrate prescaler parameter is in allowed range.
516 * @param __PRESCALER__: specifies the SPI Baudrate prescaler.
517 * This parameter can be a value of @ref SPI_BaudRate_Prescaler
520 #define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) (((__PRESCALER__) == SPI_BAUDRATEPRESCALER_2) || \
521 ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_4) || \
522 ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_8) || \
523 ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_16) || \
524 ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_32) || \
525 ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_64) || \
526 ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_128) || \
527 ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_256))
529 /** @brief Checks if SPI MSB LSB transmission parameter is in allowed range.
530 * @param __BIT__: specifies the SPI MSB LSB transmission (whether data transfer starts from MSB or LSB bit).
531 * This parameter can be a value of @ref SPI_MSB_LSB_transmission
534 #define IS_SPI_FIRST_BIT(__BIT__) (((__BIT__) == SPI_FIRSTBIT_MSB) || \
535 ((__BIT__) == SPI_FIRSTBIT_LSB))
537 /** @brief Checks if SPI TI mode parameter is in allowed range.
538 * @param __MODE__: specifies the SPI TI mode.
539 * This parameter can be a value of @ref SPI_TI_mode
542 #define IS_SPI_TIMODE(__MODE__) (((__MODE__) == SPI_TIMODE_DISABLE) || \
543 ((__MODE__) == SPI_TIMODE_ENABLE))
544 /** @brief Checks if SPI CRC calculation enabled state is in allowed range.
545 * @param __CALCULATION__: specifies the SPI CRC calculation enable state.
546 * This parameter can be a value of @ref SPI_CRC_Calculation
549 #define IS_SPI_CRC_CALCULATION(__CALCULATION__) (((__CALCULATION__) == SPI_CRCCALCULATION_DISABLE) || \
550 ((__CALCULATION__) == SPI_CRCCALCULATION_ENABLE))
552 /** @brief Checks if SPI polynomial value to be used for the CRC calculation, is in allowed range.
553 * @param __POLYNOMIAL__: specifies the SPI polynomial value to be used for the CRC calculation.
554 * This parameter must be a number between Min_Data = 0 and Max_Data = 65535
557 #define IS_SPI_CRC_POLYNOMIAL(__POLYNOMIAL__) (((__POLYNOMIAL__) >= 0x1) && ((__POLYNOMIAL__) <= 0xFFFF))
558 /** @brief Sets the SPI transmit-only mode.
559 * @param __HANDLE__: specifies the SPI Handle.
560 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
563 #define SPI_1LINE_TX(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
565 /** @brief Sets the SPI receive-only mode.
566 * @param __HANDLE__: specifies the SPI Handle.
567 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
570 #define SPI_1LINE_RX(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
572 /** @brief Resets the CRC calculation of the SPI.
573 * @param __HANDLE__: specifies the SPI Handle.
574 * This parameter can be SPIx where x: 1 or 2 to select the SPI peripheral.
577 #define SPI_RESET_CRC(__HANDLE__) do{CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);\
578 SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);}while(0)
583 /* Exported functions --------------------------------------------------------*/
584 /** @addtogroup SPI_Exported_Functions
588 /* Initialization/de-initialization functions **********************************/
589 /** @addtogroup SPI_Exported_Functions_Group1
592 HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
593 HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi);
594 void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
595 void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
600 /* I/O operation functions *****************************************************/
601 /** @addtogroup SPI_Exported_Functions_Group2
604 HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
605 HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
606 HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
607 HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
608 HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
609 HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
610 HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
611 HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
612 HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
613 HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
614 HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
615 HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
617 void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
618 void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
619 void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
620 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
621 void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
622 void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
623 void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
624 void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
630 /* Peripheral State and Control functions **************************************/
631 /** @addtogroup SPI_Exported_Functions_Group3
634 HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi);
635 uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi);
658 #endif /* __STM32L0xx_HAL_SPI_H */
660 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/