gr55xx_hal_spi_v2.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_hal_spi_v2.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of SPI HAL library.
7 *
8 ****************************************************************************************
9 * @attention
10 #####Copyright (c) 2020 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_V2_H__
53 #define __GR55xx_HAL_SPI_V2_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 #include "gr55xx_hal_dma.h"
63 #include "gr55xx_hal_spi.h"
64
65 /**
66 * @defgroup HAL_SPI_MACRO Defines
67 * @{
68 */
69 #define SPI_XFER_INST_NONE 0xFF /**< SPI XFER Instruction None. */
70 #define SPI_XFER_ADDR_NONE 0xFFFFFF /**< SPI XFER Address None. */
71 #define SPI_XFER_INST_ADDR_NONE 0xFFFFFFFF /**< SPI XFER Instruction Address None. */
72 /** @} */
73
74
75 /** @addtogroup HAL_SPI_DRIVER_FUNCTIONS Functions
76 * @{
77 */
78 /** @defgroup SPI_Exported_Functions_Group1 Initialization and de-initialization functions
79 * @brief Initialization and de-initialization functions
80 *
81 @verbatim
82 ===============================================================================
83 ##### Initialization and de-initialization functions #####
84 ===============================================================================
85 [..] This subsection provides a set of functions allowing to initialize and
86 de-initialize the SPIx peripheral:
87
88 (+) User must implement hal_spi_msp_init() function in which he configures
89 all related peripherals resources (GPIO, DMA, IT and NVIC ).
90
91 (+) Call the function hal_spi_init() to configure the selected device with
92 the selected configuration:
93 (++) Direction
94 (++) Data Size
95 (++) Clock Polarity and Phase
96 (++) BaudRate Prescaler
97 (++) TIMode
98 (++) Slave Select
99
100 (+) Call the function hal_spi_deinit() to restore the default configuration
101 of the selected SPIx peripheral.
102
103 @endverbatim
104 * @{
105 */
106
107 /**
108 ****************************************************************************************
109 * @brief Initialize the SPI according to the specified parameters
110 * in the spi_init_t and initialize the associated handle.
111 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
112 * @param[in] rx_sample_delay: Receive sample delay [0, 7]
113 *
114 * @retval ::HAL_OK: Operation is OK.
115 * @retval ::HAL_ERROR: Parameter error or operation not supported.
116 * @retval ::HAL_BUSY: Driver is busy.
117 * @retval ::HAL_TIMEOUT: Timeout occurred.
118 ****************************************************************************************
119 */
120 hal_status_t hal_spi_v2_init(spi_handle_t *p_spi, uint32_t rx_sample_delay);
121
122 /**
123 ****************************************************************************************
124 * @brief De-initialize the SPI peripheral.
125 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
126 *
127 * @retval ::HAL_OK: Operation is OK.
128 * @retval ::HAL_ERROR: Parameter error or operation not supported.
129 * @retval ::HAL_BUSY: Driver is busy.
130 * @retval ::HAL_TIMEOUT: Timeout occurred.
131 ****************************************************************************************
132 */
133 hal_status_t hal_spi_v2_deinit(spi_handle_t *p_spi);
134
135 /**
136 ****************************************************************************************
137 * @brief Initialize the SPI MSP.
138 * @note This function should not be modified. When the callback is needed,
139 the hal_spi_msp_deinit can be implemented in the user file.
140 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
141 ****************************************************************************************
142 */
143 void hal_spi_v2_msp_init(spi_handle_t *p_spi);
144
145 /**
146 ****************************************************************************************
147 * @brief De-initialize the SPI MSP.
148 * @note This function should not be modified. When the callback is needed,
149 the hal_spi_msp_deinit can be implemented in the user file.
150 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
151 ****************************************************************************************
152 */
153 void hal_spi_v2_msp_deinit(spi_handle_t *p_spi);
154 /** @} */
155
156 /**
157 ****************************************************************************************
158 * @brief set receive sample delay
159 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
160 * @param[in] rx_delay: 0 ~ 7.
161 *
162 * @retval ::HAL_OK: Operation is OK.
163 * @retval ::HAL_ERROR: Parameter error or operation not supported.
164 * @retval ::HAL_BUSY: Driver is busy.
165 * @retval ::HAL_TIMEOUT: Timeout occurred.
166 ****************************************************************************************
167 */
168 void hal_spi_v2_set_rx_delay(spi_handle_t *p_spi, uint32_t rx_delay);
169
170
171 /** @defgroup SPI_Exported_Functions_Group2 IO operation functions
172 * @brief Data transfer functions
173 *
174 @verbatim
175 ==============================================================================
176 ##### IO operation functions #####
177 ===============================================================================
178 [..]
179 This subsection provides a set of functions allowing to manage the SPI
180 data transfer.
181
182 [..] The SPI supports master and slave mode:
183
184 (#) There are two modes of transfer:
185 (++) Blocking mode: The communication is performed in polling mode.
186 The HAL status of all data processing is returned by the same function
187 after finishing transfer.
188 (++) No-Blocking mode: The communication is performed using Interrupts
189 or DMA, These APIs return the HAL status.
190 The end of the data processing will be indicated through the
191 dedicated SPI IRQ when using Interrupt mode or the DMA IRQ when
192 using DMA mode.
193 The hal_spi_tx_cplt_callback(), hal_spi_rx_cplt_callback() and hal_spi_txrx_cplt_callback() user callbacks
194 will be executed respectively at the end of the transmit or Receive process
195 The hal_spi_error_callback() user callback will be executed when a communication error is detected.
196
197 (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
198 exist for 1-Line (simplex) and 2-Line (full duplex) modes.
199
200 @endverbatim
201 * @{
202 */
203
204 /**
205 ****************************************************************************************
206 * @brief Transmit an amount of data in blocking mode with 8bit data width, and CS Signal will be assert/de-assert in every byte.
207 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
208 * @param[in] p_data: Pointer to data buffer
209 * @param[in] length: Amount of data to be sent in bytes
210 * @param[in] timeout: Timeout duration
211 *
212 * @retval ::HAL_OK: Operation is OK.
213 * @retval ::HAL_ERROR: Parameter error or operation not supported.
214 * @retval ::HAL_BUSY: Driver is busy.
215 * @retval ::HAL_TIMEOUT: Timeout occurred.
216 ****************************************************************************************
217 */
218 hal_status_t hal_spi_v2_transmit_8bit_toggle(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout);
219
220 /**
221 ****************************************************************************************
222 * @brief Transmit an amount of data in blocking mode with 8bit data width.
223 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
224 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
225 * @param[in] inst: Instruction used in transfer
226 * @param[in] addr: Address used in transfer
227 * @param[in] p_data: Pointer to data buffer
228 * @param[in] length: Amount of data to be sent in bytes
229 * @param[in] timeout: Timeout duration
230 *
231 * @retval ::HAL_OK: Operation is OK.
232 * @retval ::HAL_ERROR: Parameter error or operation not supported.
233 * @retval ::HAL_BUSY: Driver is busy.
234 * @retval ::HAL_TIMEOUT: Timeout occurred.
235 ****************************************************************************************
236 */
237 hal_status_t hal_spi_v2_transmit_8bit(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout);
238
239 /**
240 ****************************************************************************************
241 * @brief Receive an amount of data in blocking mode with 8bit data width.
242 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
243 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
244 * @param[in] inst: Instruction used in transfer
245 * @param[in] addr: Address used in transfer
246 * @param[in] p_data: Pointer to data buffer
247 * @param[in] length: Amount of data to be received in bytes
248 * @param[in] timeout: Timeout duration
249 *
250 * @retval ::HAL_OK: Operation is OK.
251 * @retval ::HAL_ERROR: Parameter error or operation not supported.
252 * @retval ::HAL_BUSY: Driver is busy.
253 * @retval ::HAL_TIMEOUT: Timeout occurred.
254 ****************************************************************************************
255 */
256 hal_status_t hal_spi_v2_receive_8bit(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout);
257
258 /**
259 ****************************************************************************************
260 * @brief Transmit Then Receive an amount of data in blocking mode with 8bit data width.
261 * This Function works at EEPROM Read Mode, not Full duplex Mode
262 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
263 * @param[in] tx_data: Pointer to transmit data buffer
264 * @param[in] tx_length: Amount of data to be transmited in bytes
265 * @param[in] rx_data: Pointer to received data buffer
266 * @param[in] rx_length: Amount of data to be received in bytes
267 * @param[in] timeout: Timeout duration
268 *
269 * @retval ::HAL_OK: Operation is OK.
270 * @retval ::HAL_ERROR: Parameter error or operation not supported.
271 * @retval ::HAL_BUSY: Driver is busy.
272 * @retval ::HAL_TIMEOUT: Timeout occurred.
273 ****************************************************************************************
274 */
275 hal_status_t hal_spi_v2_transmit_receive_8bit(spi_handle_t *p_spi, uint8_t *tx_data, uint32_t tx_length, uint8_t *rx_data, uint32_t rx_length, uint32_t timeout);
276
277 /**
278 ****************************************************************************************
279 * @brief Transmit an amount of data in blocking mode with 32bit data width.
280 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
281 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
282 * @param[in] inst: Instruction used in transfer
283 * @param[in] addr: Address used in transfer
284 * @param[in] p_data: Pointer to data buffer
285 * @param[in] length: Amount of data to be sent in bytes
286 * @param[in] timeout: Timeout duration
287 *
288 * @retval ::HAL_OK: Operation is OK.
289 * @retval ::HAL_ERROR: Parameter error or operation not supported.
290 * @retval ::HAL_BUSY: Driver is busy.
291 * @retval ::HAL_TIMEOUT: Timeout occurred.
292 ****************************************************************************************
293 */
294 hal_status_t hal_spi_v2_transmit_32bit(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout);
295
296
297 /**
298 ****************************************************************************************
299 * @brief Receive an amount of data in blocking mode with 32bit data width.
300 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
301 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
302 * @param[in] inst: Instruction used in transfer
303 * @param[in] addr: Address used in transfer
304 * @param[in] p_data: Pointer to data buffer
305 * @param[in] length: Amount of data to be sent in bytes
306 * @param[in] timeout: Timeout duration
307 *
308 * @retval ::HAL_OK: Operation is OK.
309 * @retval ::HAL_ERROR: Parameter error or operation not supported.
310 * @retval ::HAL_BUSY: Driver is busy.
311 * @retval ::HAL_TIMEOUT: Timeout occurred.
312 ****************************************************************************************
313 */
314 hal_status_t hal_spi_v2_receive_32bit(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout);
315
316 /**
317 ****************************************************************************************
318 * @brief Transmit an amount of data in DMA mode with 8bit data width.
319 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
320 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
321 * @param[in] inst: Instruction used in transfer
322 * @param[in] addr: Address used in transfer
323 * @param[in] p_data: Pointer to data buffer
324 * @param[in] length: Amount of data to be sent in bytes
325 *
326 * @retval ::HAL_OK: Operation is OK.
327 * @retval ::HAL_ERROR: Parameter error or operation not supported.
328 * @retval ::HAL_BUSY: Driver is busy.
329 * @retval ::HAL_TIMEOUT: Timeout occurred.
330 ****************************************************************************************
331 */
332 hal_status_t hal_spi_v2_transmit_8bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length);
333
334 /**
335 ****************************************************************************************
336 * @brief Receive an amount of data in DMA mode with 8bit data width.
337 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
338 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
339 * @param[in] inst: Instruction used in transfer
340 * @param[in] addr: Address used in transfer
341 * @param[in] p_data: Pointer to data buffer
342 * @param[in] length: Amount of data to be received in bytes
343 *
344 * @retval ::HAL_OK: Operation is OK.
345 * @retval ::HAL_ERROR: Parameter error or operation not supported.
346 * @retval ::HAL_BUSY: Driver is busy.
347 * @retval ::HAL_TIMEOUT: Timeout occurred.
348 ****************************************************************************************
349 */
350 hal_status_t hal_spi_v2_receive_8bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length);
351
352 /**
353 ****************************************************************************************
354 * @brief Transmit an amount of data in DMA mode with 32bit data width.
355 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
356 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
357 * @param[in] inst: Instruction used in transfer
358 * @param[in] addr: Address used in transfer
359 * @param[in] p_tx_data: Pointer to data buffer
360 * @param[in] length: Amount of data to be sent in bytes
361 *
362 * @retval ::HAL_OK: Operation is OK.
363 * @retval ::HAL_ERROR: Parameter error or operation not supported.
364 * @retval ::HAL_BUSY: Driver is busy.
365 * @retval ::HAL_TIMEOUT: Timeout occurred.
366 ****************************************************************************************
367 */
368 hal_status_t hal_spi_v2_transmit_32bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_tx_data, uint32_t length);
369
370 /**
371 ****************************************************************************************
372 * @brief Receive an amount of data in DMA mode with 32bit data width.
373 * if set inst to SPI_XFER_INST_NONE or set addr to SPI_XFER_ADDR_NONE, inst & addr won't be used in transfer
374 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
375 * @param[in] inst: Instruction used in transfer
376 * @param[in] addr: Address used in transfer
377 * @param[in] p_data: Pointer to data buffer
378 * @param[in] length: Amount of data to be received in bytes
379 *
380 * @retval ::HAL_OK: Operation is OK.
381 * @retval ::HAL_ERROR: Parameter error or operation not supported.
382 * @retval ::HAL_BUSY: Driver is busy.
383 * @retval ::HAL_TIMEOUT: Timeout occurred.
384 ****************************************************************************************
385 */
386 hal_status_t hal_spi_v2_receive_32bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length);
387
388 /**
389 ****************************************************************************************
390 * @brief Abort ongoing transfer (blocking mode).
391 * @param[in] p_spi: SPI handle.
392 * @note This procedure could be used for aborting any ongoing transfer (Tx and Rx),
393 * started in Interrupt or DMA mode.
394 * This procedure performs following operations :
395 * - Disable SPI Interrupts (depending of transfer direction)
396 * - Disable the DMA transfer in the peripheral register (if enabled)
397 * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
398 * - Set handle State to READY
399 * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
400 * @retval ::HAL_OK: Operation is OK.
401 * @retval ::HAL_ERROR: Parameter error or operation not supported.
402 * @retval ::HAL_BUSY: Driver is busy.
403 * @retval ::HAL_TIMEOUT: Timeout occurred.
404 ****************************************************************************************
405 */
406 hal_status_t hal_spi_v2_abort(spi_handle_t *p_spi);
407
408 /**
409 ****************************************************************************************
410 * @brief Abort ongoing transfer (Interrupt mode).
411 * @param[in] p_spi: SPI handle.
412 * @note This procedure could be used for aborting any ongoing transfer (Tx and Rx),
413 * started in Interrupt or DMA mode.
414 * This procedure performs following operations :
415 * - Disable SPI Interrupts (depending of transfer direction)
416 * - Disable the DMA transfer in the peripheral register (if enabled)
417 * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
418 * - Set handle State to READY
419 * - At abort completion, call user abort complete callback
420 * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
421 * considered as completed only when user abort complete callback is executed (not when exiting function).
422 * @retval ::HAL_OK: Operation is OK.
423 * @retval ::HAL_ERROR: Parameter error or operation not supported.
424 * @retval ::HAL_BUSY: Driver is busy.
425 * @retval ::HAL_TIMEOUT: Timeout occurred.
426 ****************************************************************************************
427 */
428 hal_status_t hal_spi_v2_abort_it(spi_handle_t *p_spi);
429 /** @} */
430
431
432 /** @addtogroup SPI_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
433 * @brief IRQ Handler and Callbacks functions
434 * @{
435 */
436
437 /**
438 ****************************************************************************************
439 * @brief Handle SPI interrupt request.
440 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
441 ****************************************************************************************
442 */
443 void hal_spi_v2_irq_handler(spi_handle_t *p_spi);
444
445 /**
446 ****************************************************************************************
447 * @brief Tx Transfer completed callback.
448 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
449 ****************************************************************************************
450 */
451 void hal_spi_v2_tx_cplt_callback(spi_handle_t *p_spi);
452
453 /**
454 ****************************************************************************************
455 * @brief Rx Transfer completed callback.
456 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
457 ****************************************************************************************
458 */
459 void hal_spi_v2_rx_cplt_callback(spi_handle_t *p_spi);
460
461 /**
462 ****************************************************************************************
463 * @brief Tx and Rx Transfer completed callback.
464 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
465 ****************************************************************************************
466 */
467 void hal_spi_v2_tx_rx_cplt_callback(spi_handle_t *p_spi);
468
469 /**
470 ****************************************************************************************
471 * @brief SPI error callback.
472 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
473 ****************************************************************************************
474 */
475 void hal_spi_v2_error_callback(spi_handle_t *p_spi);
476
477 /**
478 ****************************************************************************************
479 * @brief SPI Abort Completed callback.
480 * @param[in] p_spi: SPI handle.
481 ****************************************************************************************
482 */
483 void hal_spi_v2_abort_cplt_callback(spi_handle_t *p_spi);
484
485 /** @} */
486
487 /** @defgroup SPI_Exported_Functions_Group3 Peripheral State and Errors functions
488 * @brief SPI control functions
489 *
490 @verbatim
491 ===============================================================================
492 ##### Peripheral State and Errors functions #####
493 ===============================================================================
494 [..]
495 This subsection provides a set of functions allowing to control the SPI.
496 (+) hal_spi_get_state() API can be helpful to check in run-time the state of the SPI peripheral
497 (+) hal_spi_get_error() check in run-time Errors occurring during communication
498 (+) hal_spi_set_timeout() set the timeout during internal process
499 (+) hal_spi_get_tx_fifo_threshold() get the TX FIFO Threshold
500 (+) hal_spi_get_rx_fifo_threshold() get the RX FIFO Threshold
501 @endverbatim
502 * @{
503 */
504
505 /**
506 ****************************************************************************************
507 * @brief Return the SPI handle state.
508 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
509 * @retval ::HAL_SPI_STATE_RESET: Peripheral not initialized.
510 * @retval ::HAL_SPI_STATE_READY: Peripheral initialized and ready for use.
511 * @retval ::HAL_SPI_STATE_BUSY: An internal process is ongoing.
512 * @retval ::HAL_SPI_STATE_BUSY_TX: Data Transmission process is ongoing.
513 * @retval ::HAL_SPI_STATE_BUSY_RX: Data Reception process is ongoing.
514 * @retval ::HAL_SPI_STATE_BUSY_TX_RX: Data Transmission and Reception process is ongoing.
515 * @retval ::HAL_SPI_STATE_ABORT: Peripheral with abort request ongoing.
516 * @retval ::HAL_SPI_STATE_ERROR: Peripheral in error.
517 ****************************************************************************************
518 */
519 hal_spi_state_t hal_spi_v2_get_state(spi_handle_t *p_spi);
520
521 /**
522 ****************************************************************************************
523 * @brief Return the SPI error code.
524 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
525 * @return SPI error code in bitmap format
526 ****************************************************************************************
527 */
528 uint32_t hal_spi_v2_get_error(spi_handle_t *p_spi);
529
530 /**
531 ****************************************************************************************
532 * @brief Set the SPI internal process timeout value.
533 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
534 * @param[in] timeout: Internal process timeout value.
535 ****************************************************************************************
536 */
537 void hal_spi_v2_set_timeout(spi_handle_t *p_spi, uint32_t timeout);
538
539 /**
540 ****************************************************************************************
541 * @brief Get the TX FIFO threshold.
542 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
543 * @return TX FIFO threshold
544 ****************************************************************************************
545 */
546 uint32_t hal_spi_v2_get_tx_fifo_threshold(spi_handle_t *p_spi);
547
548 /**
549 ****************************************************************************************
550 * @brief Get the RX FIFO threshold.
551 * @param[in] p_spi: Pointer to an SPI handle which contains the configuration information for the specified SPI module.
552 * @return RX FIFO threshold
553 ****************************************************************************************
554 */
555 uint32_t hal_spi_v2_get_rx_fifo_threshold(spi_handle_t *p_spi);
556
557 /**
558 ****************************************************************************************
559 * @brief Suspend some registers related to SPI configuration before sleep.
560 * @param[in] p_spi: Pointer to a SPI handle which contains the configuration
561 * information for the specified SPI module.
562 * @retval ::HAL_OK: Operation is OK.
563 * @retval ::HAL_ERROR: Parameter error or operation not supported.
564 * @retval ::HAL_BUSY: Driver is busy.
565 * @retval ::HAL_TIMEOUT: Timeout occurred.
566 ****************************************************************************************
567 */
568 hal_status_t hal_spi_v2_suspend_reg(spi_handle_t *p_spi);
569
570 /**
571 ****************************************************************************************
572 * @brief Restore some registers related to SPI configuration after sleep.
573 * This function must be used in conjunction with the hal_spi_suspend_reg().
574 * @param[in] p_spi: Pointer to a SPI handle which contains the configuration
575 * information for the specified SPI module.
576 * @retval ::HAL_OK: Operation is OK.
577 * @retval ::HAL_ERROR: Parameter error or operation not supported.
578 * @retval ::HAL_BUSY: Driver is busy.
579 * @retval ::HAL_TIMEOUT: Timeout occurred.
580 ****************************************************************************************
581 */
582 hal_status_t hal_spi_v2_resume_reg(spi_handle_t *p_spi);
583
584 /**
585 ****************************************************************************************
586 * @brief Using DMA to Transmit data by toggling CS in every data beat.
587 *
588 * @param[in] p_spi: Pointer to a SPI handle which contains the configuration
589 * information for the specified SPI module.
590 * @param[in] data_size: Optional value - @ref SPI_DATASIZE_8BIT @ref SPI_DATASIZE_16BIT @ref SPI_DATASIZE_32BIT
591 * @param[in] p_data: Pointer to data buffer
592 * @param[in] length: Length of data to be sent
593 *
594 * @return Result of operation.
595 ****************************************************************************************
596 */
597 hal_status_t hal_spi_v2_transmit_dma_with_toggle(spi_handle_t *p_spi, uint32_t data_size, uint8_t *p_data, uint32_t length);
598
599 /** @} */
600
601 /** @} */
602
603 #ifdef __cplusplus
604 }
605 #endif
606
607 #endif /* __GR55xx_HAL_SPI_V2_H__ */
608
609 /** @} */
610
611 /** @} */
612
613 /** @} */
_spi_handle
SPI handle Structure definition.
Definition: gr55xx_hal_spi.h:135
hal_spi_v2_init
hal_status_t hal_spi_v2_init(spi_handle_t *p_spi, uint32_t rx_sample_delay)
Initialize the SPI according to the specified parameters in the spi_init_t and initialize the associa...
hal_spi_v2_transmit_8bit
hal_status_t hal_spi_v2_transmit_8bit(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 blocking mode with 8bit data width. if set inst to SPI_XFER_INST_NONE o...
hal_spi_v2_transmit_8bit_dma
hal_status_t hal_spi_v2_transmit_8bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length)
Transmit an amount of data in DMA mode with 8bit data width. if set inst to SPI_XFER_INST_NONE or set...
hal_spi_v2_receive_8bit_dma
hal_status_t hal_spi_v2_receive_8bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length)
Receive an amount of data in DMA mode with 8bit data width. if set inst to SPI_XFER_INST_NONE or set ...
gr55xx_hal_spi.h
Header file containing functions prototypes of SPI HAL library.
hal_spi_v2_transmit_dma_with_toggle
hal_status_t hal_spi_v2_transmit_dma_with_toggle(spi_handle_t *p_spi, uint32_t data_size, uint8_t *p_data, uint32_t length)
Using DMA to Transmit data by toggling CS in every data beat.
hal_spi_v2_transmit_32bit
hal_status_t hal_spi_v2_transmit_32bit(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 blocking mode with 32bit data width. if set inst to SPI_XFER_INST_NONE ...
hal_spi_v2_get_rx_fifo_threshold
uint32_t hal_spi_v2_get_rx_fifo_threshold(spi_handle_t *p_spi)
Get the RX FIFO threshold.
hal_spi_v2_deinit
hal_status_t hal_spi_v2_deinit(spi_handle_t *p_spi)
De-initialize the SPI peripheral.
hal_spi_state_t
hal_spi_state_t
HAL SPI State Enumerations definition.
Definition: gr55xx_hal_spi.h:76
hal_spi_v2_suspend_reg
hal_status_t hal_spi_v2_suspend_reg(spi_handle_t *p_spi)
Suspend some registers related to SPI configuration before sleep.
hal_spi_v2_abort_it
hal_status_t hal_spi_v2_abort_it(spi_handle_t *p_spi)
Abort ongoing transfer (Interrupt mode).
hal_spi_v2_rx_cplt_callback
void hal_spi_v2_rx_cplt_callback(spi_handle_t *p_spi)
Rx Transfer completed callback.
hal_spi_v2_tx_cplt_callback
void hal_spi_v2_tx_cplt_callback(spi_handle_t *p_spi)
Tx Transfer completed callback.
hal_spi_v2_get_state
hal_spi_state_t hal_spi_v2_get_state(spi_handle_t *p_spi)
Return the SPI handle state.
hal_spi_v2_receive_8bit
hal_status_t hal_spi_v2_receive_8bit(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout)
Receive an amount of data in blocking mode with 8bit data width. if set inst to SPI_XFER_INST_NONE or...
hal_spi_v2_abort
hal_status_t hal_spi_v2_abort(spi_handle_t *p_spi)
Abort ongoing transfer (blocking mode).
gr55xx_ll_spi.h
Header file containing functions prototypes of SPI LL library.
hal_spi_v2_msp_deinit
void hal_spi_v2_msp_deinit(spi_handle_t *p_spi)
De-initialize the SPI MSP.
hal_spi_v2_receive_32bit_dma
hal_status_t hal_spi_v2_receive_32bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length)
Receive an amount of data in DMA mode with 32bit data width. if set inst to SPI_XFER_INST_NONE or set...
gr55xx_hal_dma.h
Header file containing functions prototypes of DMA HAL library.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_spi_v2_irq_handler
void hal_spi_v2_irq_handler(spi_handle_t *p_spi)
Handle SPI interrupt request.
hal_spi_v2_transmit_8bit_toggle
hal_status_t hal_spi_v2_transmit_8bit_toggle(spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in blocking mode with 8bit data width, and CS Signal will be assert/de-ass...
hal_spi_v2_transmit_receive_8bit
hal_status_t hal_spi_v2_transmit_receive_8bit(spi_handle_t *p_spi, uint8_t *tx_data, uint32_t tx_length, uint8_t *rx_data, uint32_t rx_length, uint32_t timeout)
Transmit Then Receive an amount of data in blocking mode with 8bit data width. This Function works at...
hal_spi_v2_get_error
uint32_t hal_spi_v2_get_error(spi_handle_t *p_spi)
Return the SPI error code.
hal_spi_v2_transmit_32bit_dma
hal_status_t hal_spi_v2_transmit_32bit_dma(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_tx_data, uint32_t length)
Transmit an amount of data in DMA mode with 32bit data width. if set inst to SPI_XFER_INST_NONE or se...
hal_spi_v2_receive_32bit
hal_status_t hal_spi_v2_receive_32bit(spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout)
Receive an amount of data in blocking mode with 32bit data width. if set inst to SPI_XFER_INST_NONE o...
hal_spi_v2_error_callback
void hal_spi_v2_error_callback(spi_handle_t *p_spi)
SPI error callback.
hal_spi_v2_resume_reg
hal_status_t hal_spi_v2_resume_reg(spi_handle_t *p_spi)
Restore some registers related to SPI configuration after sleep. This function must be used in conjun...
hal_spi_v2_msp_init
void hal_spi_v2_msp_init(spi_handle_t *p_spi)
Initialize the SPI MSP.
hal_spi_v2_get_tx_fifo_threshold
uint32_t hal_spi_v2_get_tx_fifo_threshold(spi_handle_t *p_spi)
Get the TX FIFO threshold.
hal_spi_v2_abort_cplt_callback
void hal_spi_v2_abort_cplt_callback(spi_handle_t *p_spi)
SPI Abort Completed callback.
hal_spi_v2_set_timeout
void hal_spi_v2_set_timeout(spi_handle_t *p_spi, uint32_t timeout)
Set the SPI internal process timeout value.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_spi_v2_set_rx_delay
void hal_spi_v2_set_rx_delay(spi_handle_t *p_spi, uint32_t rx_delay)
set receive sample delay
hal_spi_v2_tx_rx_cplt_callback
void hal_spi_v2_tx_rx_cplt_callback(spi_handle_t *p_spi)
Tx and Rx Transfer completed callback.