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