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