hal_spi.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file hal_spi.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of SPI HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
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
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_SPI SPI
47  * @brief SPI HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef HAL_SPI_H
53 #define HAL_SPI_H
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "ll_spi.h"
61 #include "hal_def.h"
62 #include "hal_dma.h"
63 #include "hal_pwr_mgmt.h"
64 /* Exported types ------------------------------------------------------------*/
65 /** @addtogroup HAL_SPI_ENUMERATIONS Enumerations
66  * @{
67  */
68 
69 /** @defgroup HAL_SPI_state HAL SPI state
70  * @{
71  */
72 
73 /**
74  * @brief HAL SPI State Enumerations definition
75  */
76 typedef enum
77 {
78  HAL_SPI_STATE_RESET = 0x00, /**< Peripheral not initialized. */
79  HAL_SPI_STATE_READY = 0x01, /**< Peripheral initialized and ready for use. */
80  HAL_SPI_STATE_BUSY = 0x02, /**< An internal process is ongoing. */
81  HAL_SPI_STATE_BUSY_TX = 0x12, /**< Data Transmission process is ongoing. */
82  HAL_SPI_STATE_BUSY_RX = 0x22, /**< Data Reception process is ongoing. */
83  HAL_SPI_STATE_BUSY_TX_RX = 0x32, /**< Data Transmission and Reception process is ongoing. */
84  HAL_SPI_STATE_ABORT = 0x08, /**< Peripheral with abort request ongoing. */
85  HAL_SPI_STATE_ERROR = 0x04 /**< Peripheral in error. */
86 
88 
89 /** @} */
90 
91 /** @} */
92 
93 /** @addtogroup HAL_SPI_STRUCTURES Structures
94  * @{
95  */
96 
97 /** @defgroup SPI_Configuration SPI Configuration
98  * @{
99  */
100 
101 /**
102  * @brief SPI init Structure definition
103  */
104 typedef struct _spi_init
105 {
106  uint32_t data_size; /**< Specifies the SPI data size.
107  This parameter can be a value of @ref SPI_Data_Size. */
108 
109  uint32_t clock_polarity; /**< Specifies the serial clock steady state.
110  This parameter can be a value of @ref SPI_Clock_Polarity. */
111 
112  uint32_t clock_phase; /**< Specifies the clock active edge for the bit capture.
113  This parameter can be a value of @ref SPI_Clock_Phase. */
114 
115  uint32_t baudrate_prescaler; /**< Specifies the BaudRate prescaler value which will be
116  used to configure the transmit and receive SCK clock.
117  @note The communication clock is derived from the master
118  clock. The slave clock does not need to be set. */
119 
120  uint32_t ti_mode; /**< Specifies if the TI mode is enabled or not.
121  This parameter can be a value of @ref SPI_TI_Mode. */
122 
123  uint32_t slave_select; /**< Specifies the slaves to be selected.
124  This parameter can be a value of @ref SPI_Slave_Select. */
125 
126  uint32_t rx_sample_delay; /**< Specifies the RX sample delay. It is used to delay the sample of the RX input port.
127  This parameter can be a number between 0 and 0x7. */
129 /** @} */
130 /** @} */
131 
132 /** @defgroup SOFT CS Signal Description
133  * @{
134  */
135 #define SPI_SOFT_CS_MAGIC_NUMBER 0xDEADBEAFU /**< CS magic number. */
136 
137 /**
138  * @defgroup HAL_SPI_MACRO Defines
139  * @{
140  */
141 
142 /** @defgroup CS_STA_STATE State from Software CS Assert
143  * @{
144  */
145 /**
146  * @brief State from Software CS Assert
147  */
148 #define CS_STA_STATE_POLL_TX 0x01U /**< CS ASSERT when Transferring Starts by Polling */
149 #define CS_STA_STATE_POLL_RX 0x02U /**< CS ASSERT when Receiving Starts by Polling */
150 #define CS_STA_STATE_POLL_TX_RX 0x03U /**< CS ASSERT when DUPLEX Starts by Polling */
151 #define CS_STA_STATE_POLL_EEPREAD 0x04U /**< CS ASSERT when EEPREAD Starts by Polling */
152 #define CS_STA_STATE_IT_TX 0x05U /**< CS ASSERT when Transferring Starts by Interrupt */
153 #define CS_STA_STATE_IT_RX 0x06U /**< CS ASSERT when Receiving Starts by Interrupt */
154 #define CS_STA_STATE_IT_TX_RX 0x07U /**< CS ASSERT when DUPLEX Starts by Interrupt */
155 #define CS_STA_STATE_IT_EEPREAD 0x08U /**< CS ASSERT when EEPREAD Starts by Interrupt */
156 #define CS_STA_STATE_DMA_TX 0x09U /**< CS ASSERT when Transferring Starts by DMA */
157 #define CS_STA_STATE_DMA_RX 0x0AU /**< CS ASSERT when Receiving Starts by DMA */
158 #define CS_STA_STATE_DMA_TX_RX 0x0BU /**< CS ASSERT when DUPLEX Starts by DMA */
159 #define CS_STA_STATE_DMA_EEPREAD 0x0CU /**< CS ASSERT when EEPREAD Starts by DMA */
160 #define CS_STA_STATE_DMA_LLP_TX 0x0DU /**< CS ASSERT when Transferring Starts by DMA LLP */
161 #define CS_STA_STATE_DMA_SCATTER_RX 0x0EU /**< CS ASSERT when Receiving Starts by DMA Scatter */
162 /** @} */
163 
164 /**
165  * @brief State from Software CS De-Assert
166  */
167 #define CS_END_STATE_POLL_TX 0x81U /**< CS DE-ASSERT when Transferring Ends by Polling */
168 #define CS_END_STATE_POLL_RX 0x82U /**< CS DE-ASSERT when Receiving Ends by Polling */
169 #define CS_END_STATE_POLL_TX_RX 0x83U /**< CS DE-ASSERT when DUPLEX Ends by Polling */
170 #define CS_END_STATE_POLL_EEPREAD 0x84U /**< CS DE-ASSERT when EEPREAD Ends by Polling */
171 #define CS_END_STATE_TX_CPLT 0x90U /**< CS DE-ASSERT when Transferring Ends by IT/DMA */
172 #define CS_END_STATE_RX_CPLT 0x91U /**< CS DE-ASSERT when Receiving Ends by IT/DMA */
173 #define CS_END_STATE_TX_RX_CPLT 0x92U /**< CS DE-ASSERT when DUPLEX Ends by IT/DMA */
174 #define CS_END_STATE_XFER_ERR 0x93U /**< CS DE-ASSERT when xfer Error by IT/DMA */
175 #define CS_END_STATE_TX_ABORT_CPLT 0x94U /**< CS DE-ASSERT when abort The transfer Ends by IT/DMA */
176 #define CS_END_STATE_RX_ABORT_CPLT 0x95U /**< CS DE-ASSERT when abort the receive Ends by IT/DMA */
177 #define CS_END_STATE_ABORT_CPLT 0x96U /**< CS DE-ASSERT when abort the tx/rx by IT/DMA */
178 /** @} */
179 /** @} */
180 
181 /** @addtogroup HAL_SPI_STRUCTURES Structures
182  * @{
183  */
184 /** @defgroup SPI_handle SPI handle
185  * @{
186  */
187 
188 /**
189  * @brief SPI handle Structure definition
190  */
191 typedef struct _spi_handle
192 {
193  spi_regs_t *p_instance; /**< SPI registers base address */
194 
195  spi_init_t init; /**< SPI communication parameters */
196 
197  __IO uint32_t soft_cs_magic; /**< if equals to @ref SPI_SOFT_CS_MAGIC_NUMBER, control the CS signal by software */
198 
199  uint8_t *p_tx_buffer; /**< Pointer to SPI Tx transfer Buffer */
200 
201  __IO uint32_t tx_xfer_size; /**< SPI Tx Transfer size */
202 
203  __IO uint32_t tx_xfer_count; /**< SPI Tx Transfer Counter */
204 
205  uint8_t *p_rx_buffer; /**< Pointer to SPI Rx transfer Buffer */
206 
207  __IO uint32_t rx_xfer_size; /**< SPI Rx Transfer size */
208 
209  __IO uint32_t rx_xfer_count; /**< SPI Rx Transfer Counter */
210 
211  void (*write_fifo)(struct _spi_handle *p_spi); /**< Pointer to SPI Tx transfer FIFO write function */
212 
213  void (*read_fifo)(struct _spi_handle *p_spi); /**< Pointer to SPI Rx transfer FIFO read function */
214 
215  void (*read_write_fifo)(struct _spi_handle *p_spi); /**< Pointer to SPI transfer FIFO read and write function */
216 
217  dma_handle_t *p_dmatx; /**< SPI Tx DMA Handle parameters */
218 
219  dma_handle_t *p_dmarx; /**< SPI Rx DMA Handle parameters */
220 
221  __IO hal_spi_state_t state; /**< SPI communication state */
222 
223  __IO uint32_t error_code; /**< SPI Error code */
224 
225  uint32_t timeout; /**< Timeout for the SPI memory access */
226 
227  uint32_t retention[9]; /**< SPI important register information. */
229 /** @} */
230 
231 /** @} */
232 
233 /** @addtogroup HAL_SPI_CALLBACK_STRUCTURES Callback Structures
234  * @{
235  */
236 
237 /** @defgroup HAL_SPI_Callback Callback
238  * @{
239  */
240 
241 /**
242  * @brief HAL_SPI Callback function definition
243  */
244 
245 typedef struct _hal_spi_callback
246 {
247  void (*spi_msp_init)(spi_handle_t *p_spi); /**< SPI init MSP callback */
248  void (*spi_msp_deinit)(spi_handle_t *p_spi); /**< SPI de-init MSP callback */
249  void (*spi_error_callback)(spi_handle_t *p_spi); /**< SPI error callback */
250  void (*spi_abort_cplt_callback)(spi_handle_t *p_spi); /**< SPI abort completed callback */
251  void (*spi_rx_cplt_callback)(spi_handle_t *p_spi); /**< SPI rx transfer completed callback */
252  void (*spi_tx_cplt_callback)(spi_handle_t *p_spi); /**< SPI tx transfer completed callback */
253  void (*spi_tx_rx_cplt_callback)(spi_handle_t *p_spi); /**< SPI tx/rx transfer completed callback */
254  void (*spi_soft_cs_assert)(spi_handle_t *p_spi, uint32_t state); /**< assert the cs signal by software setting */
255  void (*spi_soft_cs_deassert)(spi_handle_t *p_spi, uint32_t state); /**< deassert the cs signal by software setting */
257 
258 /** @} */
259 
260 /** @} */
261 
262 /**
263  * @defgroup HAL_SPI_MACRO Defines
264  * @{
265  */
266 
267 /* Exported constants --------------------------------------------------------*/
268 /** @defgroup SPI_Exported_Constants SPI Exported Constants
269  * @{
270  */
271 
272 /** @defgroup SPI_Direction SPI Direction
273  * @{
274  */
275 
276 #define SPI_DIRECTION_FULL_DUPLEX LL_SPI_FULL_DUPLEX /**< Full Duplex: Transmit & Receive */
277 #define SPI_DIRECTION_SIMPLEX_TX LL_SPI_SIMPLEX_TX /**< Simplex Tx: Transmit only */
278 #define SPI_DIRECTION_SIMPLEX_RX LL_SPI_SIMPLEX_RX /**< Simplex Rx: Receive only */
279 #define SPI_DIRECTION_READ_EEPROM LL_SPI_READ_EEPROM /**< Read EEPROM */
280 
281 /** @} */
282 
283 /** @defgroup SPI_Error_Code SPI Error Code
284  * @{
285  */
286 #define HAL_SPI_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
287 #define HAL_SPI_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
288 #define HAL_SPI_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
289 #define HAL_SPI_ERROR_DMA ((uint32_t)0x00000004) /**< DMA transfer error */
290 #define HAL_SPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
291 /** @} */
292 
293 /** @defgroup SPI_Data_Size SPI Data Size
294  * @{
295  */
296 
297 #define SPI_DATASIZE_4BIT LL_SPI_DATASIZE_4BIT /**< 4-bit serial data transfer */
298 #define SPI_DATASIZE_5BIT LL_SPI_DATASIZE_5BIT /**< 5-bit serial data transfer */
299 #define SPI_DATASIZE_6BIT LL_SPI_DATASIZE_6BIT /**< 6-bit serial data transfer */
300 #define SPI_DATASIZE_7BIT LL_SPI_DATASIZE_7BIT /**< 7-bit serial data transfer */
301 #define SPI_DATASIZE_8BIT LL_SPI_DATASIZE_8BIT /**< 8-bit serial data transfer */
302 #define SPI_DATASIZE_9BIT LL_SPI_DATASIZE_9BIT /**< 9-bit serial data transfer */
303 #define SPI_DATASIZE_10BIT LL_SPI_DATASIZE_10BIT /**< 10-bit serial data transfer */
304 #define SPI_DATASIZE_11BIT LL_SPI_DATASIZE_11BIT /**< 11-bit serial data transfer */
305 #define SPI_DATASIZE_12BIT LL_SPI_DATASIZE_12BIT /**< 12-bit serial data transfer */
306 #define SPI_DATASIZE_13BIT LL_SPI_DATASIZE_13BIT /**< 13-bit serial data transfer */
307 #define SPI_DATASIZE_14BIT LL_SPI_DATASIZE_14BIT /**< 14-bit serial data transfer */
308 #define SPI_DATASIZE_15BIT LL_SPI_DATASIZE_15BIT /**< 15-bit serial data transfer */
309 #define SPI_DATASIZE_16BIT LL_SPI_DATASIZE_16BIT /**< 16-bit serial data transfer */
310 #define SPI_DATASIZE_17BIT LL_SPI_DATASIZE_17BIT /**< 17-bit serial data transfer */
311 #define SPI_DATASIZE_18BIT LL_SPI_DATASIZE_18BIT /**< 18-bit serial data transfer */
312 #define SPI_DATASIZE_19BIT LL_SPI_DATASIZE_19BIT /**< 19-bit serial data transfer */
313 #define SPI_DATASIZE_20BIT LL_SPI_DATASIZE_20BIT /**< 20-bit serial data transfer */
314 #define SPI_DATASIZE_21BIT LL_SPI_DATASIZE_21BIT /**< 21-bit serial data transfer */
315 #define SPI_DATASIZE_22BIT LL_SPI_DATASIZE_22BIT /**< 22-bit serial data transfer */
316 #define SPI_DATASIZE_23BIT LL_SPI_DATASIZE_23BIT /**< 23-bit serial data transfer */
317 #define SPI_DATASIZE_24BIT LL_SPI_DATASIZE_24BIT /**< 24-bit serial data transfer */
318 #define SPI_DATASIZE_25BIT LL_SPI_DATASIZE_25BIT /**< 25-bit serial data transfer */
319 #define SPI_DATASIZE_26BIT LL_SPI_DATASIZE_26BIT /**< 26-bit serial data transfer */
320 #define SPI_DATASIZE_27BIT LL_SPI_DATASIZE_27BIT /**< 27-bit serial data transfer */
321 #define SPI_DATASIZE_28BIT LL_SPI_DATASIZE_28BIT /**< 28-bit serial data transfer */
322 #define SPI_DATASIZE_29BIT LL_SPI_DATASIZE_29BIT /**< 29-bit serial data transfer */
323 #define SPI_DATASIZE_30BIT LL_SPI_DATASIZE_30BIT /**< 30-bit serial data transfer */
324 #define SPI_DATASIZE_31BIT LL_SPI_DATASIZE_31BIT /**< 31-bit serial data transfer */
325 #define SPI_DATASIZE_32BIT LL_SPI_DATASIZE_32BIT /**< 32-bit serial data transfer */
326 
327 /** @} */
328 
329 /** @defgroup SPI_Clock_Polarity SPI Clock Polarity
330  * @{
331  */
332 
333 #define SPI_POLARITY_LOW LL_SPI_SCPOL_LOW /**< Inactive state of CLK is low */
334 #define SPI_POLARITY_HIGH LL_SPI_SCPOL_HIGH /**< Inactive state of CLK is high */
335 
336 /** @} */
337 
338 /** @defgroup SPI_Clock_Phase SPI Clock Phase
339  * @{
340  */
341 
342 #define SPI_PHASE_1EDGE LL_SPI_SCPHA_1EDGE /**< CLK toggles at start of first data bit */
343 #define SPI_PHASE_2EDGE LL_SPI_SCPHA_2EDGE /**< CLK toggles in middle of first data bit */
344 
345 /** @} */
346 
347 /** @defgroup SPI_TI_Mode SPI TI Mode
348  * @{
349  */
350 #define SPI_TIMODE_DISABLE ((uint32_t)0x00000000) /**< SPI TI mode disable */
351 
352 #define SPI_TIMODE_ENABLE LL_SPI_PROTOCOL_TI /**< SPI TI mode enable */
353 
354 /** @} */
355 
356 /** @defgroup SPI_Slave_Select SPI Slave Select
357  * @{
358  */
359 
360 #define SPI_SLAVE_SELECT_0 LL_SPI_SLAVE0 /**< SPIM Select Slave 0 */
361 #define SPI_SLAVE_SELECT_1 LL_SPI_SLAVE1 /**< SPIM Select Slave 1 */
362 #define SPI_SLAVE_SELECT_ALL (LL_SPI_SLAVE0 | LL_SPI_SLAVE1) /**< SPIM Select All Slave */
363 
364 /** @} */
365 
366 /** @defgroup SPI_FIFO_LEVEL_MAX SPI FIFO Level Max
367  * @{
368  */
369 #define SPI_TX_FIFO_LEVEL_MAX 8U /**< SPI TX FIFO Level Max Value */
370 #define SPI_RX_FIFO_LEVEL_MAX 8U /**< SPI RX FIFO Level Max Value */
371 /** @} */
372 
373 /** @defgroup SPI_Flags_definition SPI Flags Definition
374  * @{
375  */
376 
377 #define SPI_FLAG_DCOL LL_SPI_SR_DCOL /**< Data collision error flag */
378 #define SPI_FLAG_TXE LL_SPI_SR_TXE /**< Transmission error flag */
379 #define SPI_FLAG_RFF LL_SPI_SR_RFF /**< Rx FIFO full flag */
380 #define SPI_FLAG_RFNE LL_SPI_SR_RFNE /**< Rx FIFO not empty flag */
381 #define SPI_FLAG_TFE LL_SPI_SR_TFE /**< Tx FIFO empty flag */
382 #define SPI_FLAG_TFNF LL_SPI_SR_TFNF /**< Tx FIFO not full flag */
383 #define SPI_FLAG_BUSY LL_SPI_SR_BUSY /**< Busy flag */
384 
385 /** @} */
386 
387 /** @defgroup SPI_Interrupt_definition SPI Interrupt Definition
388  * @{
389  */
390 
391 #define SPI_IT_MST LL_SPI_IS_MST /**< Multi-Master Contention Interrupt flag */
392 #define SPI_IT_RXF LL_SPI_IS_RXF /**< Receive FIFO Full Interrupt flag */
393 #define SPI_IT_RXO LL_SPI_IS_RXO /**< Receive FIFO Overflow Interrupt flag */
394 #define SPI_IT_RXU LL_SPI_IS_RXU /**< Receive FIFO Underflow Interrupt flag */
395 #define SPI_IT_TXO LL_SPI_IS_TXO /**< Transmit FIFO Overflow Interrupt flag */
396 #define SPI_IT_TXE LL_SPI_IS_TXE /**< Transmit FIFO Empty Interrupt flag */
397 
398 /** @} */
399 
400 /** @defgroup SPI_Timeout_definition SPI Timeout_definition
401  * @{
402  */
403 #define HAL_SPI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
404 /** @} */
405 
406 /** @} */
407 
408 /* Exported macro ------------------------------------------------------------*/
409 /** @defgroup SPI_Exported_Macros SPI Exported Macros
410  * @{
411  */
412 
413 /** @brief Reset SPI handle states.
414  * @param __HANDLE__ SPI handle.
415  * @retval None
416  */
417 #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_SPI_STATE_RESET)
418 
419 
420 /** @brief Enable the specified SPI peripheral.
421  * @param __HANDLE__ Specifies the SPI Handle.
422  * @retval None
423  */
424 #define __HAL_SPI_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->SSI_EN, SPI_SSI_EN)
425 
426 
427 /** @brief Disable the specified SPI peripheral.
428  * @param __HANDLE__ Specifies the SPI Handle.
429  * @retval None
430  */
431 #define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->SSI_EN, SPI_SSI_EN)
432 
433 
434 /** @brief Enable the SPI DMA TX Request.
435  * @param __HANDLE__ Specifies the SPI Handle.
436  * @retval None
437  */
438 #define __HAL_SPI_ENABLE_DMATX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->DMA_CTRL, SPI_DMA_CTRL_TX_DMA_EN)
439 
440 
441 /** @brief Enable the SPI DMA RX Request.
442  * @param __HANDLE__ Specifies the SPI Handle.
443  * @retval None
444  */
445 #define __HAL_SPI_ENABLE_DMARX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->DMA_CTRL, SPI_DMA_CTRL_RX_DMA_EN)
446 
447 
448 /** @brief Disable the SPI DMA TX Request.
449  * @param __HANDLE__ Specifies the SPI Handle.
450  * @retval None
451  */
452 #define __HAL_SPI_DISABLE_DMATX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->DMA_CTRL, SPI_DMA_CTRL_TX_DMA_EN)
453 
454 
455 /** @brief Disable the SPI DMA RX Request.
456  * @param __HANDLE__ Specifies the SPI Handle.
457  * @retval None
458  */
459 #define __HAL_SPI_DISABLE_DMARX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->DMA_CTRL, SPI_DMA_CTRL_RX_DMA_EN)
460 
461 
462 /** @brief Enable the specified SPI interrupts.
463  * @param __HANDLE__ Specifies the SPI Handle.
464  * @param __INTERRUPT__ Specifies the interrupt source to enable.
465  * This parameter can be one of the following values:
466  * @arg @ref SPI_IT_MST Multi-Master Contention Interrupt enable
467  * @arg @ref SPI_IT_RXF Receive FIFO Full Interrupt enable
468  * @arg @ref SPI_IT_RXO Receive FIFO Overflow Interrupt enable
469  * @arg @ref SPI_IT_RXU Receive FIFO Underflow Interrupt enable
470  * @arg @ref SPI_IT_TXO Transmit FIFO Overflow Interrupt enable
471  * @arg @ref SPI_IT_TXE Transmit FIFO Empty Interrupt enable
472  * @retval None
473  */
474 #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INT_MASK, (__INTERRUPT__))
475 
476 
477 /** @brief Disable the specified SPI interrupts.
478  * @param __HANDLE__ Specifies the SPI handle.
479  * @param __INTERRUPT__ Specifies the interrupt source to disable.
480  * This parameter can be one of the following values:
481  * @arg @ref SPI_IT_MST Multi-Master Contention Interrupt enable
482  * @arg @ref SPI_IT_RXF Receive FIFO Full Interrupt enable
483  * @arg @ref SPI_IT_RXO Receive FIFO Overflow Interrupt enable
484  * @arg @ref SPI_IT_RXU Receive FIFO Underflow Interrupt enable
485  * @arg @ref SPI_IT_TXO Transmit FIFO Overflow Interrupt enable
486  * @arg @ref SPI_IT_TXE Transmit FIFO Empty Interrupt enable
487  * @retval None
488  */
489 #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INT_MASK, (__INTERRUPT__))
490 
491 
492 /** @brief Check whether the specified SPI interrupt source is enabled or not.
493  * @param __HANDLE__ Specifies the SPI Handle.
494  * @param __INTERRUPT__ Specifies the interrupt source to check.
495  * This parameter can be one of the following values:
496  * @arg @ref SPI_IT_MST Multi-Master Contention Interrupt enable
497  * @arg @ref SPI_IT_RXF Receive FIFO Full Interrupt enable
498  * @arg @ref SPI_IT_RXO Receive FIFO Overflow Interrupt enable
499  * @arg @ref SPI_IT_RXU Receive FIFO Underflow Interrupt enable
500  * @arg @ref SPI_IT_TXO Transmit FIFO Overflow Interrupt enable
501  * @arg @ref SPI_IT_TXE Transmit FIFO Empty Interrupt enable
502  * @retval The new state of __IT__ (TRUE or FALSE).
503  */
504 #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BITS((__HANDLE__)->p_instance->INT_STAT, (__INTERRUPT__)) == (__INTERRUPT__))
505 
506 
507 /** @brief Check whether the specified SPI flag is set or not.
508  * @param __HANDLE__ Specifies the SPI Handle.
509  * @param __FLAG__ Specifies the flag to check.
510  * This parameter can be one of the following values:
511  * @arg @ref SPI_FLAG_DCOL Data collision error flag
512  * @arg @ref SPI_FLAG_TXE Transmission error flag
513  * @arg @ref SPI_FLAG_RFF Rx FIFO full flag
514  * @arg @ref SPI_FLAG_RFNE Rx FIFO not empty flag
515  * @arg @ref SPI_FLAG_TFE Tx FIFO empty flag
516  * @arg @ref SPI_FLAG_TFNF Tx FIFO not full flag
517  * @arg @ref SPI_FLAG_BUSY Busy flag
518  * @retval The new state of __FLAG__ (TRUE or FALSE).
519  */
520 #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0U) ? SET : RESET)
521 
522 
523 /** @brief Clear the specified SPI flag.
524  * @param __HANDLE__ Specifies the SPI Handle.
525  * @param __FLAG__ Specifies the flag to clear.
526  * This parameter can be one of the following values:
527  * @arg @ref SPI_FLAG_DCOL Data collision error flag
528  * @arg @ref SPI_FLAG_TXE Transmission error flag
529  * @arg @ref SPI_FLAG_RFF Rx FIFO full flag
530  * @arg @ref SPI_FLAG_RFNE Rx FIFO not empty flag
531  * @arg @ref SPI_FLAG_TFE Tx FIFO empty flag
532  * @arg @ref SPI_FLAG_TFNF Tx FIFO not full flag
533  * @arg @ref SPI_FLAG_BUSY Busy flag
534  * @retval None
535  */
536 #define __HAL_SPI_CLEAR_FLAG(__HANDLE__, __FLAG__) READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__))
537 
538 
539 /** @} */
540 
541 /* Private macros ------------------------------------------------------------*/
542 /** @defgroup SPI_Private_Macro SPI Private Macros
543  * @{
544  */
545 
546 /** @brief Check if SPI Direction Mode is valid.
547  * @param __MODE__ SPI Direction Mode.
548  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
549  */
550 #define IS_SPI_DIRECTION(__MODE__) (((__MODE__) == SPI_DIRECTION_FULL_DUPLEX) || \
551  ((__MODE__) == SPI_DIRECTION_SIMPLEX_TX) || \
552  ((__MODE__) == SPI_DIRECTION_SIMPLEX_RX) || \
553  ((__MODE__) == SPI_DIRECTION_READ_EEPROM))
554 
555 
556 /** @brief Check if SPI Data Size is valid.
557  * @param __DATASIZE__ SPI Data Size.
558  * @retval SET (__DATASIZE__ is valid) or RESET (__DATASIZE__ is invalid)
559  */
560 #define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) >= SPI_DATASIZE_4BIT) && \
561  ((__DATASIZE__) <= SPI_DATASIZE_32BIT))
562 
563 /** @brief Check if SPI Clock Polarity is valid.
564  * @param __CPOL__ SPI Clock Polarity.
565  * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
566  */
567 #define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \
568  ((__CPOL__) == SPI_POLARITY_HIGH))
569 
570 /** @brief Check if SPI Clock Phase is valid.
571  * @param __CPHA__ SPI Clock Phase.
572  * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid)
573  */
574 #define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \
575  ((__CPHA__) == SPI_PHASE_2EDGE))
576 
577 /** @brief Check if SPI BaudRate Prescaler is valid.
578  * @param __PRESCALER__ SPI BaudRate Prescaler.
579  * @retval SET (__PRESCALER__ is valid) or RESET (__PRESCALER__ is invalid)
580  */
581 #define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) ((__PRESCALER__) <= 0xFFFF)
582 
583 /** @brief Check if SPI TI Mode is valid.
584  * @param __MODE__ SPI TI Mode.
585  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
586  */
587 #define IS_SPI_TIMODE(__MODE__) (((__MODE__) == SPI_TIMODE_DISABLE) || \
588  ((__MODE__) == SPI_TIMODE_ENABLE))
589 
590 /** @brief Check if SPI Slave Select is valid.
591  * @param __SLAVE__ SPI Slave Select.
592  * @retval SET (__SLAVE__ is valid) or RESET (__SLAVE__ is invalid)
593  */
594 #define IS_SPI_SLAVE(__SLAVE__) (((__SLAVE__) == SPI_SLAVE_SELECT_0) || \
595  ((__SLAVE__) == SPI_SLAVE_SELECT_1) || \
596  ((__SLAVE__) == SPI_SLAVE_SELECT_ALL))
597 
598 /** @brief Check if SPI RX Sample Delay Value is valid.
599  * @param __DLY__ SPI RX Sample Delay value.
600  * @retval SET (__DLY__ is valid) or RESET (__DLY__ is invalid)
601  */
602 #define IS_SPI_RX_SAMPLE_DLY(__DLY__) (((__DLY__) >= 0) && ((__DLY__) <= 7))
603 
604 
605 /** @brief Check if SPI FIFO Threshold is valid.
606  * @param __THR__ SPI FIFO Threshold.
607  * @retval SET (__THR__ is valid) or RESET (__THR__ is invalid)
608  */
609 
610 #define IS_SPI_FIFO_THRESHOLD(__THR__) (((__THR__) >= 0) && ((__THR__) <= (LL_SPI_M_FIFO_DEPTH - 1)))
611 
612 /** @} */
613 
614 /** @} */
615 
616 /* Exported functions --------------------------------------------------------*/
617 /** @addtogroup HAL_SPI_DRIVER_FUNCTIONS Functions
618  * @{
619  */
620 
621 /** @defgroup SPI_Exported_Functions_Group1 Initialization and de-initialization functions
622  * @brief Initialization and de-initialization functions
623  *
624 @verbatim
625  ===============================================================================
626  ##### Initialization and de-initialization functions #####
627  ===============================================================================
628  [..] This subsection provides a set of functions allowing to initialize and
629  de-initialize the SPIx peripheral:
630 
631  (+) User must implement hal_spi_msp_init() function in which he configures
632  all related peripherals resources (GPIO, DMA, IT and NVIC ).
633 
634  (+) Call the function hal_spi_init() to configure the selected device with
635  the selected configuration:
636  (++) Direction
637  (++) Data Size
638  (++) Clock Polarity and Phase
639  (++) BaudRate Prescaler
640  (++) TIMode
641  (++) Slave Select
642 
643  (+) Call the function hal_spi_deinit() to restore the default configuration
644  of the selected SPIx peripheral.
645 
646 @endverbatim
647  * @{
648  */
649 
650 /**
651  ****************************************************************************************
652  * @brief Initialize the SPI according to the specified parameters
653  * in the spi_init_t and initialize the associated handle.
654  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
655  * @retval ::HAL_OK: Operation is OK.
656  * @retval ::HAL_ERROR: Parameter error or operation not supported.
657  * @retval ::HAL_BUSY: Driver is busy.
658  * @retval ::HAL_TIMEOUT: Timeout occurred.
659  ****************************************************************************************
660  */
662 
663 /**
664  ****************************************************************************************
665  * @brief De-initialize the SPI peripheral.
666  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
667  * @retval ::HAL_OK: Operation is OK.
668  * @retval ::HAL_ERROR: Parameter error or operation not supported.
669  * @retval ::HAL_BUSY: Driver is busy.
670  * @retval ::HAL_TIMEOUT: Timeout occurred.
671  ****************************************************************************************
672  */
674 
675 /**
676  ****************************************************************************************
677  * @brief Initialize the SPI MSP.
678  * @note This function should not be modified. When the callback is needed,
679  the hal_spi_msp_deinit can be implemented in the user file.
680  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
681  ****************************************************************************************
682  */
684 
685 /**
686  ****************************************************************************************
687  * @brief De-initialize the SPI MSP.
688  * @note This function should not be modified. When the callback is needed,
689  the hal_spi_msp_deinit can be implemented in the user file.
690  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
691  ****************************************************************************************
692  */
694 
695 /** @} */
696 
697 /** @defgroup SPI_Exported_Functions_Group2 IO operation functions
698  * @brief Data transfer functions
699  *
700 @verbatim
701  ==============================================================================
702  ##### IO operation functions #####
703  ===============================================================================
704  [..]
705  This subsection provides a set of functions allowing to manage the SPI
706  data transfer.
707 
708  [..] The SPI supports master and slave mode:
709 
710  (#) There are two modes of transfer:
711  (++) Blocking mode: The communication is performed in polling mode.
712  The HAL status of all data processing is returned by the same function
713  after finishing transfer.
714  (++) No-Blocking mode: The communication is performed using Interrupts
715  or DMA, These APIs return the HAL status.
716  The end of the data processing will be indicated through the
717  dedicated SPI IRQ when using Interrupt mode or the DMA IRQ when
718  using DMA mode.
719  The hal_spi_tx_cplt_callback(), hal_spi_rx_cplt_callback() and hal_spi_txrx_cplt_callback() user callbacks
720  will be executed respectively at the end of the transmit or Receive process
721  The hal_spi_error_callback() user callback will be executed when a communication error is detected.
722 
723  (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
724  exist for 1-Line (simplex) and 2-Line (full duplex) modes.
725 
726 @endverbatim
727  * @{
728  */
729 
730 /**
731  ****************************************************************************************
732  * @brief Transmit an amount of data in blocking mode.
733  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
734  * @param[in] p_data: Pointer to data buffer
735  * @param[in] length: Amount of data to be sent in bytes
736  * @param[in] timeout: Timeout duration
737  * @retval ::HAL_OK: Operation is OK.
738  * @retval ::HAL_ERROR: Parameter error or operation not supported.
739  * @retval ::HAL_BUSY: Driver is busy.
740  * @retval ::HAL_TIMEOUT: Timeout occurred.
741  ****************************************************************************************
742  */
743 hal_status_t hal_spi_transmit(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout);
744 
745 /**
746  ****************************************************************************************
747  * @brief Receive an amount of data in blocking mode.
748  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
749  * @param[out] p_data: Pointer to data buffer
750  * @param[in] length: Amount of data to be received in bytes
751  * @param[in] timeout: Timeout duration
752  * @retval ::HAL_OK: Operation is OK.
753  * @retval ::HAL_ERROR: Parameter error or operation not supported.
754  * @retval ::HAL_BUSY: Driver is busy.
755  * @retval ::HAL_TIMEOUT: Timeout occurred.
756  ****************************************************************************************
757  */
758 hal_status_t hal_spi_receive(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout);
759 
760 /**
761  ****************************************************************************************
762  * @brief Transmit and Receive an amount of data in blocking mode.
763  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
764  * @param[in] p_tx_data: Pointer to transmission data buffer
765  * @param[out] p_rx_data: Pointer to reception data buffer
766  * @param[in] length: Amount of data to be sent and received in bytes
767  * @param[in] timeout: Timeout duration
768  * @retval ::HAL_OK: Operation is OK.
769  * @retval ::HAL_ERROR: Parameter error or operation not supported.
770  * @retval ::HAL_BUSY: Driver is busy.
771  * @retval ::HAL_TIMEOUT: Timeout occurred.
772  ****************************************************************************************
773  */
774 hal_status_t hal_spi_transmit_receive(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length, uint32_t timeout);
775 
776 /**
777  ****************************************************************************************
778  * @brief Read an amount of data from EEPROM in blocking mode.
779  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
780  * @param[in] p_tx_data: Pointer to transmission data buffer
781  * @param[out] p_rx_data: Pointer to reception data buffer
782  * @param[in] tx_number_data: Amount of data to be sent in bytes
783  * @param[in] rx_number_data: Amount of data to be received in bytes
784  * @param[in] timeout: Timeout duration
785  * @retval ::HAL_OK: Operation is OK.
786  * @retval ::HAL_ERROR: Parameter error or operation not supported.
787  * @retval ::HAL_BUSY: Driver is busy.
788  * @retval ::HAL_TIMEOUT: Timeout occurred.
789  ****************************************************************************************
790  */
791 hal_status_t hal_spi_read_eeprom(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data, uint32_t timeout);
792 
793 /**
794  ****************************************************************************************
795  * @brief Transmit an amount of data in non-blocking mode with Interrupt.
796  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
797  * @param[in] p_data: Pointer to data buffer
798  * @param[in] length: Amount of data to be sent in bytes
799  * @retval ::HAL_OK: Operation is OK.
800  * @retval ::HAL_ERROR: Parameter error or operation not supported.
801  * @retval ::HAL_BUSY: Driver is busy.
802  * @retval ::HAL_TIMEOUT: Timeout occurred.
803  ****************************************************************************************
804  */
805 hal_status_t hal_spi_transmit_it(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length);
806 
807 /**
808  ****************************************************************************************
809  * @brief Receive an amount of data in non-blocking mode with Interrupt.
810  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
811  * @param[out] p_data: Pointer to data buffer
812  * @param[in] length: Amount of data to be sent in bytes
813  * @retval ::HAL_OK: Operation is OK.
814  * @retval ::HAL_ERROR: Parameter error or operation not supported.
815  * @retval ::HAL_BUSY: Driver is busy.
816  * @retval ::HAL_TIMEOUT: Timeout occurred.
817  ****************************************************************************************
818  */
819 hal_status_t hal_spi_receive_it(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length);
820 
821 /**
822  ****************************************************************************************
823  * @brief Transmit and Receive an amount of data in non-blocking mode with Interrupt.
824  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
825  * @param[in] p_tx_data: Pointer to transmission data buffer
826  * @param[out] p_rx_data: Pointer to reception data buffer
827  * @param[in] length: Amount of data to be sent and received in bytes
828  * @retval ::HAL_OK: Operation is OK.
829  * @retval ::HAL_ERROR: Parameter error or operation not supported.
830  * @retval ::HAL_BUSY: Driver is busy.
831  * @retval ::HAL_TIMEOUT: Timeout occurred.
832  ****************************************************************************************
833  */
834 hal_status_t hal_spi_transmit_receive_it(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length);
835 
836 /**
837  ****************************************************************************************
838  * @brief Read an amount of data from EEPROM in non-blocking mode with Interrupt.
839  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
840  * @param[in] p_tx_data: Pointer to transmission data buffer
841  * @param[out] p_rx_data: Pointer to reception data buffer
842  * @param[in] tx_number_data: Amount of data to be sent in bytes
843  * @param[in] rx_number_data: Amount of data to be received in bytes
844  * @retval ::HAL_OK: Operation is OK.
845  * @retval ::HAL_ERROR: Parameter error or operation not supported.
846  * @retval ::HAL_BUSY: Driver is busy.
847  * @retval ::HAL_TIMEOUT: Timeout occurred.
848  ****************************************************************************************
849  */
850 hal_status_t hal_spi_read_eeprom_it(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data);
851 
852 /**
853  ****************************************************************************************
854  * @brief Transmit an amount of data in non-blocking mode with DMA.
855  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
856  * @param[in] p_data: Pointer to data buffer
857  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
858  * @retval ::HAL_OK: Operation is OK.
859  * @retval ::HAL_ERROR: Parameter error or operation not supported.
860  * @retval ::HAL_BUSY: Driver is busy.
861  * @retval ::HAL_TIMEOUT: Timeout occurred.
862  ****************************************************************************************
863  */
864 hal_status_t hal_spi_transmit_dma(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length);
865 
866 /**
867  ****************************************************************************************
868  * @brief Receive an amount of data in non-blocking mode with DMA.
869  * @note In case of MASTER mode and SPI_DIRECTION_2LINES direction, p_dmatx shall be defined.
870  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
871  * @param[out] p_data: Pointer to data buffer
872  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
873  * @retval ::HAL_OK: Operation is OK.
874  * @retval ::HAL_ERROR: Parameter error or operation not supported.
875  * @retval ::HAL_BUSY: Driver is busy.
876  * @retval ::HAL_TIMEOUT: Timeout occurred.
877  ****************************************************************************************
878  */
879 hal_status_t hal_spi_receive_dma(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length);
880 
881 /**
882  ****************************************************************************************
883  * @brief Transmit and Receive an amount of data in non-blocking mode with DMA.
884  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
885  * @param[in] p_tx_data: Pointer to transmission data buffer
886  * @param[out] p_rx_data: Pointer to reception data buffer
887  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
888  * @retval ::HAL_OK: Operation is OK.
889  * @retval ::HAL_ERROR: Parameter error or operation not supported.
890  * @retval ::HAL_BUSY: Driver is busy.
891  * @retval ::HAL_TIMEOUT: Timeout occurred.
892  ****************************************************************************************
893  */
894 hal_status_t hal_spi_transmit_receive_dma(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length);
895 
896 /**
897  ****************************************************************************************
898  * @brief Read an amount of data from EEPROM in non-blocking mode with DMA.
899  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
900  * @param[in] p_tx_data: Pointer to transmission data buffer
901  * @param[out] p_rx_data: Pointer to reception data buffer
902  * @param[in] tx_number_data: Amount of data to be sent in bytes
903  * @param[in] rx_number_data: Amount of data to be received in bytes, ranging between 0 and 4095.
904  * @retval ::HAL_OK: Operation is OK.
905  * @retval ::HAL_ERROR: Parameter error or operation not supported.
906  * @retval ::HAL_BUSY: Driver is busy.
907  * @retval ::HAL_TIMEOUT: Timeout occurred.
908  ****************************************************************************************
909  */
910 hal_status_t hal_spi_read_eeprom_dma(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data);
911 
912 
913 
914 /**
915  ****************************************************************************************
916  * @brief Transmit an amount of data in non-blocking mode with polling. Support Setting C&A
917  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
918  * @param[in] inst: 1 byte instruction
919  * @param[in] addr: 3 bytes address
920  * @param[in] p_data: Pointer to data buffer
921  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
922  * @param[in] timeout: Timeout duration
923  * @retval ::HAL_OK: Operation is OK.
924  * @retval ::HAL_ERROR: Parameter error or operation not supported.
925  * @retval ::HAL_BUSY: Driver is busy.
926  * @retval ::HAL_TIMEOUT: Timeout occurred.
927  ****************************************************************************************
928  */
929 hal_status_t hal_spi_transmit_with_ia(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout);
930 
931 /**
932  ****************************************************************************************
933  * @brief Transmit an amount of data in non-blocking mode with DMA. Support Setting C&A
934  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
935  * @param[in] inst: 1 byte instruction
936  * @param[in] addr: 3 bytes address
937  * @param[in] p_data: Pointer to data buffer
938  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
939  * @retval ::HAL_OK: Operation is OK.
940  * @retval ::HAL_ERROR: Parameter error or operation not supported.
941  * @retval ::HAL_BUSY: Driver is busy.
942  * @retval ::HAL_TIMEOUT: Timeout occurred.
943  ****************************************************************************************
944  */
945 hal_status_t hal_spi_transmit_dma_with_ia(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length);
946 
947 /**
948  ****************************************************************************************
949  * @brief Transmit an amount of data in non-blocking mode with polling. Support Setting C&A
950  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
951  * @param[in] inst: 1 byte instruction
952  * @param[in] addr: 4 bytes address
953  * @param[in] p_data: Pointer to data buffer
954  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
955  * @param[in] timeout: Timeout duration
956  * @retval ::HAL_OK: Operation is OK.
957  * @retval ::HAL_ERROR: Parameter error or operation not supported.
958  * @retval ::HAL_BUSY: Driver is busy.
959  * @retval ::HAL_TIMEOUT: Timeout occurred.
960  ****************************************************************************************
961  */
962 hal_status_t hal_spi_transmit_with_ia_32addr(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout);
963 
964 /**
965  ****************************************************************************************
966  * @brief Transmit an amount of data in non-blocking mode with DMA. Support Setting C&A
967  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
968  * @param[in] inst: 1 byte instruction
969  * @param[in] addr: 4 bytes address
970  * @param[in] p_data: Pointer to data buffer
971  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
972  * @retval ::HAL_OK: Operation is OK.
973  * @retval ::HAL_ERROR: Parameter error or operation not supported.
974  * @retval ::HAL_BUSY: Driver is busy.
975  * @retval ::HAL_TIMEOUT: Timeout occurred.
976  ****************************************************************************************
977  */
978 hal_status_t hal_spi_transmit_dma_with_ia_32addr(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length);
979 
980 /**
981  ****************************************************************************************
982  * @brief Abort ongoing transfer (blocking mode).
983  * @param[in] p_spi: SPI handle.
984  * @note This procedure could be used for aborting any ongoing transfer (Tx and Rx),
985  * started in Interrupt or DMA mode.
986  * This procedure performs following operations :
987  * - Disable SPI Interrupts (depending of transfer direction)
988  * - Disable the DMA transfer in the peripheral register (if enabled)
989  * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
990  * - Set handle State to READY
991  * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
992  * @retval ::HAL_OK: Operation is OK.
993  * @retval ::HAL_ERROR: Parameter error or operation not supported.
994  * @retval ::HAL_BUSY: Driver is busy.
995  * @retval ::HAL_TIMEOUT: Timeout occurred.
996  ****************************************************************************************
997  */
999 
1000 /**
1001  ****************************************************************************************
1002  * @brief Abort ongoing transfer (Interrupt mode).
1003  * @param[in] p_spi: SPI handle.
1004  * @note This procedure could be used for aborting any ongoing transfer (Tx and Rx),
1005  * started in Interrupt or DMA mode.
1006  * This procedure performs following operations :
1007  * - Disable SPI Interrupts (depending of transfer direction)
1008  * - Disable the DMA transfer in the peripheral register (if enabled)
1009  * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
1010  * - Set handle State to READY
1011  * - At abort completion, call user abort complete callback
1012  * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
1013  * considered as completed only when user abort complete callback is executed (not when exiting function).
1014  * @retval ::HAL_OK: Operation is OK.
1015  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1016  * @retval ::HAL_BUSY: Driver is busy.
1017  * @retval ::HAL_TIMEOUT: Timeout occurred.
1018  ****************************************************************************************
1019  */
1021 
1022 /** @} */
1023 
1024 /** @addtogroup SPI_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
1025  * @brief IRQ Handler and Callbacks functions
1026  * @{
1027  */
1028 
1029 /**
1030  ****************************************************************************************
1031  * @brief Handle SPI interrupt request.
1032  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1033  ****************************************************************************************
1034  */
1036 
1037 /**
1038  ****************************************************************************************
1039  * @brief Tx Transfer completed callback.
1040  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1041  ****************************************************************************************
1042  */
1044 
1045 /**
1046  ****************************************************************************************
1047  * @brief Rx Transfer completed callback.
1048  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1049  ****************************************************************************************
1050  */
1052 
1053 /**
1054  ****************************************************************************************
1055  * @brief Tx and Rx Transfer completed callback.
1056  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1057  ****************************************************************************************
1058  */
1060 
1061 /**
1062  ****************************************************************************************
1063  * @brief SPI error callback.
1064  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1065  ****************************************************************************************
1066  */
1068 
1069 /**
1070  ****************************************************************************************
1071  * @brief SPI Abort Completed callback.
1072  * @param[in] p_spi: SPI handle.
1073  ****************************************************************************************
1074  */
1076 
1077 /** @} */
1078 
1079 /** @defgroup SPI_Exported_Functions_Group3 Peripheral State and Errors functions
1080  * @brief SPI control functions
1081  *
1082 @verbatim
1083  ===============================================================================
1084  ##### Peripheral State and Errors functions #####
1085  ===============================================================================
1086  [..]
1087  This subsection provides a set of functions allowing to control the SPI.
1088  (+) hal_spi_get_state() API can be helpful to check in run-time the state of the SPI peripheral
1089  (+) hal_spi_get_error() check in run-time Errors occurring during communication
1090  (+) hal_spi_set_timeout() set the timeout during internal process
1091  (+) hal_spi_set_tx_fifo_threshold() set the TX FIFO Threshold
1092  (+) hal_spi_set_rx_fifo_threshold() set the RX FIFO Threshold
1093  (+) hal_spi_get_tx_fifo_threshold() get the TX FIFO Threshold
1094  (+) hal_spi_get_rx_fifo_threshold() get the RX FIFO Threshold
1095 @endverbatim
1096  * @{
1097  */
1098 
1099 /**
1100  ****************************************************************************************
1101  * @brief Return the SPI handle state.
1102  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1103  * @retval ::HAL_SPI_STATE_RESET: Peripheral not initialized.
1104  * @retval ::HAL_SPI_STATE_READY: Peripheral initialized and ready for use.
1105  * @retval ::HAL_SPI_STATE_BUSY: An internal process is ongoing.
1106  * @retval ::HAL_SPI_STATE_BUSY_TX: Data Transmission process is ongoing.
1107  * @retval ::HAL_SPI_STATE_BUSY_RX: Data Reception process is ongoing.
1108  * @retval ::HAL_SPI_STATE_BUSY_TX_RX: Data Transmission and Reception process is ongoing.
1109  * @retval ::HAL_SPI_STATE_ABORT: Peripheral with abort request ongoing.
1110  * @retval ::HAL_SPI_STATE_ERROR: Peripheral in error.
1111  ****************************************************************************************
1112  */
1114 
1115 /**
1116  ****************************************************************************************
1117  * @brief Return the SPI error code.
1118  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1119  * @return SPI error code in bitmap format
1120  ****************************************************************************************
1121  */
1123 
1124 /**
1125  ****************************************************************************************
1126  * @brief Set the SPI internal process timeout value.
1127  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1128  * @param[in] timeout: Internal process timeout value.
1129  ****************************************************************************************
1130  */
1131 void hal_spi_set_timeout(spi_handle_t *p_spi, uint32_t timeout);
1132 
1133 /**
1134  ****************************************************************************************
1135  * @brief Set the TX FIFO threshold.
1136  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1137  * @param[in] threshold: TX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
1138  * @retval ::HAL_OK: Operation is OK.
1139  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1140  * @retval ::HAL_BUSY: Driver is busy.
1141  * @retval ::HAL_TIMEOUT: Timeout occurred.
1142  ****************************************************************************************
1143  */
1145 
1146 /**
1147  ****************************************************************************************
1148  * @brief Set the RX FIFO threshold.
1149  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1150  * @param[in] threshold: RX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
1151  * @retval ::HAL_OK: Operation is OK.
1152  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1153  * @retval ::HAL_BUSY: Driver is busy.
1154  * @retval ::HAL_TIMEOUT: Timeout occurred.
1155  ****************************************************************************************
1156  */
1158 
1159 /**
1160  ****************************************************************************************
1161  * @brief Get the TX FIFO threshold.
1162  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1163  * @return TX FIFO threshold
1164  ****************************************************************************************
1165  */
1167 
1168 /**
1169  ****************************************************************************************
1170  * @brief Get the RX FIFO threshold.
1171  * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
1172  * @return RX FIFO threshold
1173  ****************************************************************************************
1174  */
1176 
1177 /**
1178  ****************************************************************************************
1179  * @brief Suspend some registers related to SPI configuration before sleep.
1180  * @param[in] p_spi: Pointer to a SPI handle which contains the configuration
1181  * information for the specified SPI module.
1182  * @retval None
1183  ****************************************************************************************
1184  */
1186 
1187 /**
1188  ****************************************************************************************
1189  * @brief Restore some registers related to SPI configuration after sleep.
1190  * This function must be used in conjunction with the hal_spi_suspend_reg().
1191  * @param[in] p_spi: Pointer to a SPI handle which contains the configuration
1192  * information for the specified SPI module.
1193  * @retval None
1194  ****************************************************************************************
1195  */
1197 
1198 #ifdef HAL_PM_ENABLE
1199 /**
1200  ****************************************************************************************
1201  * @brief Suspend the specified SPI.
1202  * @param[in] p_spi: Pointer to a SPI handle
1203  * @retval ::HAL_PM_ACTIVE: Device is active, not allow sleep.
1204  * @retval ::HAL_PM_SLEEP: Allow sleep.
1205  ****************************************************************************************
1206  */
1208 
1209 /**
1210  ****************************************************************************************
1211  * @brief Resume the specified SPI
1212  * @param[in] p_spi: Pointer to a SPI handle
1213  * @retval ::None
1214  ****************************************************************************************
1215  */
1217 #endif /* HAL_PM_ENABLE */
1218 
1219 /**
1220  ****************************************************************************************
1221  * @brief Assert the CS Singal line by software (When activate the soft-cs mode)
1222  * @param[in] p_spi: Pointer to a SPI handle which contains the configuration
1223  * information for the specified SPI module.
1224  * @param[in] state: assert state, please @ref CS_STA_STATE.
1225  * @retval :: none
1226  ****************************************************************************************
1227  */
1228 void hal_spi_soft_cs_assert(spi_handle_t *p_spi, uint32_t state);
1229 
1230 /**
1231  ****************************************************************************************
1232  * @brief De-Assert the CS Singal line by software (When activate the soft-cs mode)
1233  * @param[in] p_spi: Pointer to a SPI handle which contains the configuration
1234  * information for the specified SPI module.
1235  * @param[in] state: assert state, please @ref CS_STA_STATE.
1236  * @retval :: none
1237  ****************************************************************************************
1238  */
1239 void hal_spi_soft_cs_deassert(spi_handle_t *p_spi, uint32_t state);
1240 
1241 /** @} */
1242 
1243 /** @} */
1244 
1245 #ifdef __cplusplus
1246 }
1247 #endif
1248 
1249 #endif /* HAL_SPI_H */
1250 
1251 /** @} */
1252 
1253 /** @} */
1254 
1255 /** @} */
hal_spi_abort_cplt_callback
void hal_spi_abort_cplt_callback(spi_handle_t *p_spi)
SPI Abort Completed callback.
hal_spi_get_state
hal_spi_state_t hal_spi_get_state(spi_handle_t *p_spi)
Return the SPI handle state.
hal_spi_transmit_dma_with_ia_32addr
hal_status_t hal_spi_transmit_dma_with_ia_32addr(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with DMA. Support Setting C&A.
_hal_spi_callback::spi_rx_cplt_callback
void(* spi_rx_cplt_callback)(spi_handle_t *p_spi)
Definition: hal_spi.h:251
HAL_SPI_STATE_READY
@ HAL_SPI_STATE_READY
Definition: hal_spi.h:79
_spi_handle
SPI handle Structure definition.
Definition: hal_spi.h:192
hal_spi_deinit
hal_status_t hal_spi_deinit(spi_handle_t *p_spi)
De-initialize the SPI peripheral.
_spi_init::ti_mode
uint32_t ti_mode
Definition: hal_spi.h:120
_hal_spi_callback::spi_soft_cs_deassert
void(* spi_soft_cs_deassert)(spi_handle_t *p_spi, uint32_t state)
Definition: hal_spi.h:255
hal_spi_abort
hal_status_t hal_spi_abort(spi_handle_t *p_spi)
Abort ongoing transfer (blocking mode).
_hal_spi_callback::spi_abort_cplt_callback
void(* spi_abort_cplt_callback)(spi_handle_t *p_spi)
Definition: hal_spi.h:250
_hal_spi_callback::spi_tx_cplt_callback
void(* spi_tx_cplt_callback)(spi_handle_t *p_spi)
Definition: hal_spi.h:252
hal_spi_callback_t
struct _hal_spi_callback hal_spi_callback_t
HAL_SPI Callback function definition.
hal_spi_error_callback
void hal_spi_error_callback(spi_handle_t *p_spi)
SPI error callback.
_spi_init::slave_select
uint32_t slave_select
Definition: hal_spi.h:123
_spi_handle::read_fifo
void(* read_fifo)(struct _spi_handle *p_spi)
Definition: hal_spi.h:213
hal_spi_init
hal_status_t hal_spi_init(spi_handle_t *p_spi)
Initialize the SPI according to the specified parameters in the spi_init_t and initialize the associa...
hal_spi_get_tx_fifo_threshold
uint32_t hal_spi_get_tx_fifo_threshold(spi_handle_t *p_spi)
Get the TX FIFO threshold.
HAL_SPI_STATE_ERROR
@ HAL_SPI_STATE_ERROR
Definition: hal_spi.h:85
hal_spi_transmit_dma
hal_status_t hal_spi_transmit_dma(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with DMA.
hal_spi_transmit
hal_status_t hal_spi_transmit(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in blocking mode.
hal_pwr_mgmt.h
This file contains all the functions prototypes for the HAL module driver.
hal_spi_read_eeprom_dma
hal_status_t hal_spi_read_eeprom_dma(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data)
Read an amount of data from EEPROM in non-blocking mode with DMA.
_spi_handle::p_tx_buffer
uint8_t * p_tx_buffer
Definition: hal_spi.h:199
_spi_init
SPI init Structure definition.
Definition: hal_spi.h:105
HAL_SPI_STATE_BUSY_TX
@ HAL_SPI_STATE_BUSY_TX
Definition: hal_spi.h:81
_spi_handle::tx_xfer_count
__IO uint32_t tx_xfer_count
Definition: hal_spi.h:203
hal_spi_receive_dma
hal_status_t hal_spi_receive_dma(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
Receive an amount of data in non-blocking mode with DMA.
hal_spi_transmit_with_ia
hal_status_t hal_spi_transmit_with_ia(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in non-blocking mode with polling. Support Setting C&A.
hal_spi_tx_cplt_callback
void hal_spi_tx_cplt_callback(spi_handle_t *p_spi)
Tx Transfer completed callback.
hal_spi_soft_cs_assert
void hal_spi_soft_cs_assert(spi_handle_t *p_spi, uint32_t state)
Assert the CS Singal line by software (When activate the soft-cs mode)
hal_spi_read_eeprom
hal_status_t hal_spi_read_eeprom(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data, uint32_t timeout)
Read an amount of data from EEPROM in blocking mode.
hal_spi_state_t
hal_spi_state_t
HAL SPI State Enumerations definition.
Definition: hal_spi.h:77
hal_spi_rx_cplt_callback
void hal_spi_rx_cplt_callback(spi_handle_t *p_spi)
Rx Transfer completed callback.
_spi_handle::p_dmatx
dma_handle_t * p_dmatx
Definition: hal_spi.h:217
_spi_handle::timeout
uint32_t timeout
Definition: hal_spi.h:225
_spi_handle::p_rx_buffer
uint8_t * p_rx_buffer
Definition: hal_spi.h:205
_hal_spi_callback::spi_error_callback
void(* spi_error_callback)(spi_handle_t *p_spi)
Definition: hal_spi.h:249
hal_pm_spi_resume
void hal_pm_spi_resume(spi_handle_t *p_spi)
Resume the specified SPI.
_spi_handle::error_code
__IO uint32_t error_code
Definition: hal_spi.h:223
hal_pm_status_t
hal_pm_status_t
Definition: hal_pwr_mgmt.h:59
HAL_SPI_STATE_BUSY
@ HAL_SPI_STATE_BUSY
Definition: hal_spi.h:80
_spi_handle::rx_xfer_count
__IO uint32_t rx_xfer_count
Definition: hal_spi.h:209
hal_spi_irq_handler
void hal_spi_irq_handler(spi_handle_t *p_spi)
Handle SPI interrupt request.
hal_spi_suspend_reg
void hal_spi_suspend_reg(spi_handle_t *p_spi)
Suspend some registers related to SPI configuration before sleep.
_hal_spi_callback::spi_msp_init
void(* spi_msp_init)(spi_handle_t *p_spi)
Definition: hal_spi.h:247
_hal_spi_callback::spi_tx_rx_cplt_callback
void(* spi_tx_rx_cplt_callback)(spi_handle_t *p_spi)
Definition: hal_spi.h:253
_spi_handle::tx_xfer_size
__IO uint32_t tx_xfer_size
Definition: hal_spi.h:201
hal_spi_soft_cs_deassert
void hal_spi_soft_cs_deassert(spi_handle_t *p_spi, uint32_t state)
De-Assert the CS Singal line by software (When activate the soft-cs mode)
_spi_handle::p_dmarx
dma_handle_t * p_dmarx
Definition: hal_spi.h:219
_spi_handle::retention
uint32_t retention[9]
Definition: hal_spi.h:227
_spi_handle::soft_cs_magic
__IO uint32_t soft_cs_magic
Definition: hal_spi.h:197
hal_spi_transmit_receive
hal_status_t hal_spi_transmit_receive(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length, uint32_t timeout)
Transmit and Receive an amount of data in blocking mode.
hal_spi_set_rx_fifo_threshold
hal_status_t hal_spi_set_rx_fifo_threshold(spi_handle_t *p_spi, uint32_t threshold)
Set the RX FIFO threshold.
hal_spi_get_rx_fifo_threshold
uint32_t hal_spi_get_rx_fifo_threshold(spi_handle_t *p_spi)
Get the RX FIFO threshold.
_hal_spi_callback::spi_soft_cs_assert
void(* spi_soft_cs_assert)(spi_handle_t *p_spi, uint32_t state)
Definition: hal_spi.h:254
spi_handle_t
struct _spi_handle spi_handle_t
SPI handle Structure definition.
hal_spi_transmit_dma_with_ia
hal_status_t hal_spi_transmit_dma_with_ia(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with DMA. Support Setting C&A.
HAL_SPI_STATE_ABORT
@ HAL_SPI_STATE_ABORT
Definition: hal_spi.h:84
HAL_SPI_STATE_BUSY_RX
@ HAL_SPI_STATE_BUSY_RX
Definition: hal_spi.h:82
_spi_init::rx_sample_delay
uint32_t rx_sample_delay
Definition: hal_spi.h:126
_spi_handle::init
spi_init_t init
Definition: hal_spi.h:195
hal_spi_abort_it
hal_status_t hal_spi_abort_it(spi_handle_t *p_spi)
Abort ongoing transfer (Interrupt mode).
HAL_SPI_STATE_RESET
@ HAL_SPI_STATE_RESET
Definition: hal_spi.h:78
hal_spi_transmit_it
hal_status_t hal_spi_transmit_it(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with Interrupt.
hal_spi_transmit_with_ia_32addr
hal_status_t hal_spi_transmit_with_ia_32addr(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in non-blocking mode with polling. Support Setting C&A.
hal_spi_receive_it
hal_status_t hal_spi_receive_it(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
Receive an amount of data in non-blocking mode with Interrupt.
HAL_SPI_STATE_BUSY_TX_RX
@ HAL_SPI_STATE_BUSY_TX_RX
Definition: hal_spi.h:83
hal_spi_msp_deinit
void hal_spi_msp_deinit(spi_handle_t *p_spi)
De-initialize the SPI MSP.
hal_spi_receive
hal_status_t hal_spi_receive(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout)
Receive an amount of data in blocking mode.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr_common.h:140
spi_init_t
struct _spi_init spi_init_t
SPI init Structure definition.
hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_hal_spi_callback::spi_msp_deinit
void(* spi_msp_deinit)(spi_handle_t *p_spi)
Definition: hal_spi.h:248
_spi_init::clock_polarity
uint32_t clock_polarity
Definition: hal_spi.h:109
_spi_init::baudrate_prescaler
uint32_t baudrate_prescaler
Definition: hal_spi.h:115
hal_spi_set_tx_fifo_threshold
hal_status_t hal_spi_set_tx_fifo_threshold(spi_handle_t *p_spi, uint32_t threshold)
Set the TX FIFO threshold.
_spi_handle::read_write_fifo
void(* read_write_fifo)(struct _spi_handle *p_spi)
Definition: hal_spi.h:215
hal_spi_msp_init
void hal_spi_msp_init(spi_handle_t *p_spi)
Initialize the SPI MSP.
_spi_handle::state
__IO hal_spi_state_t state
Definition: hal_spi.h:221
hal_spi_tx_rx_cplt_callback
void hal_spi_tx_rx_cplt_callback(spi_handle_t *p_spi)
Tx and Rx Transfer completed callback.
_spi_handle::rx_xfer_size
__IO uint32_t rx_xfer_size
Definition: hal_spi.h:207
hal_spi_transmit_receive_dma
hal_status_t hal_spi_transmit_receive_dma(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length)
Transmit and Receive an amount of data in non-blocking mode with DMA.
hal_spi_read_eeprom_it
hal_status_t hal_spi_read_eeprom_it(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data)
Read an amount of data from EEPROM in non-blocking mode with Interrupt.
hal_spi_transmit_receive_it
hal_status_t hal_spi_transmit_receive_it(spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length)
Transmit and Receive an amount of data in non-blocking mode with Interrupt.
_spi_handle::p_instance
spi_regs_t * p_instance
Definition: hal_spi.h:193
hal_dma.h
Header file containing functions prototypes of DMA HAL library.
hal_spi_get_error
uint32_t hal_spi_get_error(spi_handle_t *p_spi)
Return the SPI error code.
_spi_init::clock_phase
uint32_t clock_phase
Definition: hal_spi.h:112
hal_pm_spi_suspend
hal_pm_status_t hal_pm_spi_suspend(spi_handle_t *p_spi)
Suspend the specified SPI.
_hal_spi_callback
HAL_SPI Callback function definition.
Definition: hal_spi.h:246
ll_spi.h
Header file containing functions prototypes of SPI LL library.
hal_spi_resume_reg
void hal_spi_resume_reg(spi_handle_t *p_spi)
Restore some registers related to SPI configuration after sleep. This function must be used in conjun...
_dma_handle
DMA handle Structure definition.
Definition: hal_dma.h:195
_spi_handle::write_fifo
void(* write_fifo)(struct _spi_handle *p_spi)
Definition: hal_spi.h:211
_spi_init::data_size
uint32_t data_size
Definition: hal_spi.h:106
hal_spi_set_timeout
void hal_spi_set_timeout(spi_handle_t *p_spi, uint32_t timeout)
Set the SPI internal process timeout value.