gr55xx_hal_dspi.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_hal_dspi.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of DSPI 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_DSPI DSPI
47 * @brief DSPI HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_DSPI_H__
53 #define __GR55xx_HAL_DSPI_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_dspi.h"
61 #include "gr55xx_hal_def.h"
62 #include "gr55xx_hal_pwr_mgmt.h"
63
64 /* Exported types ------------------------------------------------------------*/
65 /** @addtogroup HAL_DSPI_ENUMERATIONS Enumerations
66 * @{
67 */
68
69 /** @defgroup HAL_DSPI_state HAL DSPI state
70 * @{
71 */
72
73 /**
74 * @brief HAL DSPI State Enumerations definition
75 */
76 typedef enum
77 {
78 HAL_DSPI_STATE_RESET = 0x00, /**< Peripheral not initialized */
79 HAL_DSPI_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
80 HAL_DSPI_STATE_BUSY = 0x02, /**< Peripheral in indirect mode and busy */
81 HAL_DSPI_STATE_BUSY_INDIRECT_TX = 0x12, /**< Peripheral in indirect mode with transmission ongoing */
82 HAL_DSPI_STATE_ABORT = 0x08, /**< Peripheral with abort request ongoing */
83 HAL_DSPI_STATE_ERROR = 0x04 /**< Peripheral in error */
84
85 } hal_dspi_state_t;
86
87 /** @} */
88
89 /** @} */
90
91 /** @addtogroup HAL_DSPI_STRUCTURES Structures
92 * @{
93 */
94
95 /** @defgroup DSPI_Configuration DSPI Configuration
96 * @{
97 */
98
99 /**
100 * @brief QSPI init Structure definition
101 */
102 typedef struct _dspi_init_t
103 {
104 uint32_t data_size; /**< Specifies the DSPI data width.
105 This parameter can be a value of @ref QSPI_Data_Size Data Width.*/
106
107 uint32_t baud_rate; /**< Specifies the BaudRate prescaler value which will be used to configure the transmit and receive SCK clock.
108 This parameter can be one even value between 0 and 7 @ref DSPI_Clock_Sel Clock Select.*/
109
110 uint32_t dspi_mode; /**< Specifies the DSPI interface mode.
111 This parameter can be a value of @ref DSPI_Interface_Mode DSPI Interface Mode.*/
112 } dspi_init_t;
113
114 /** @} */
115
116 /** @defgroup DSPI_handle DSPI handle
117 * @{
118 */
119
120 /**
121 * @brief DSPI handle Structure definition
122 */
123 typedef struct _dspi_handle
124 {
125 dspi_regs_t *p_instance; /**< DSPI registers base address */
126
127 dspi_init_t init; /**< DSPI communication parameters */
128
129 uint8_t *p_tx_buffer; /**< Pointer to DSPI Tx transfer Buffer */
130
131 __IO uint32_t tx_xfer_size; /**< DSPI Tx Transfer size */
132
133 __IO uint32_t tx_xfer_count; /**< DSPI Tx Transfer Counter */
134
135 void (*write_fifo)(struct _dspi_handle *p_dspi); /**< Pointer to DSPI Tx transfer FIFO write function */
136
137 dma_handle_t *p_dmatx; /**< DSPI Tx DMA Handle parameters */
138
139 __IO hal_lock_t lock; /**< Locking object */
140
141 __IO hal_dspi_state_t state; /**< DSPI communication state */
142
143 __IO uint32_t error_code; /**< DSPI Error code */
144
145 uint32_t timeout; /**< Timeout for the DSPI memory access */
146
147 periph_device_number_t dspi_number; /**< DSPI used for Sleep management */
148
149 uint32_t retention[3]; /**< DSPI important register information. */
150 } dspi_handle_t;
151 /** @} */
152
153 /** @defgroup DSPI_Command DSPI command
154 * @{
155 */
156
157 /**
158 * @brief DSPI command Structure definition
159 */
160 typedef struct _dspi_command_t
161 {
162 uint32_t instruction; /**< Specifies the Instruction to be sent.
163 This parameter can be a value (8-bit, 16bit, 32 bit). */
164
165 uint32_t instruction_size; /**< Specifies the Instruction Size.
166 This parameter can be a value of @ref DSPI_Instruction_Size. */
167
168 uint32_t data_size; /**< Specifies the DSPI data width.
169 This parameter can be a value of @ref QSPI_Data_Size. */
170
171 uint32_t length; /**< Specifies the number of data to transfer. (This is the number of bytes).
172 This parameter can be any value between 0 and 0xFFFFFFFF (0 means undefined length
173 until end of memory). */
174
175 } dspi_command_t;
176 /** @} */
177
178 /** @} */
179
180 /** @addtogroup HAL_DSPI_CALLBACK_STRUCTURES Callback Structures
181 * @{
182 */
183
184 /** @defgroup HAL_DSPI_Callback Callback
185 * @{
186 */
187
188 /**
189 * @brief HAL_DSPI Callback function definition
190 */
191
192 typedef struct _hal_dspi_callback
193 {
194 void (*dspi_msp_init)(dspi_handle_t *p_dspi); /**< DSPI init MSP callback */
195 void (*dspi_msp_deinit)(dspi_handle_t *p_dspi); /**< DSPI de-init MSP callback */
196 void (*dspi_abort_callback)(dspi_handle_t *p_dspi); /**< DSPI abort callback */
197 void (*dspi_error_callback)(dspi_handle_t *p_dspi); /**< DSPI error callback */
198 void (*dspi_tx_cplt_callback)(dspi_handle_t *p_dspi); /**< DSPI tx transfer completed callback */
199 } hal_dspi_callback_t;
200
201 /** @} */
202
203 /** @} */
204
205 /**
206 * @defgroup HAL_DSPI_MACRO Defines
207 * @{
208 */
209
210 /* Exported constants --------------------------------------------------------*/
211 /** @defgroup DSPI_Exported_Constants DSPI Exported Constants
212 * @{
213 */
214
215 /** @defgroup DSPI_Error_Code DSPI Error Code
216 * @{
217 */
218 #define HAL_DSPI_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
219 #define HAL_DSPI_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
220 #define HAL_DSPI_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
221 #define HAL_DSPI_ERROR_DMA ((uint32_t)0x00000004) /**< DMA transfer error */
222 #define HAL_DSPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameter error */
223 /** @} */
224
225 /** @defgroup DSPI_Clock_Sel Clock Select
226 * @{
227 */
228 #define DSPI_BAUD_RATE_2P1PCLK LL_DSPI_BAUD_RATE_2P1PCLK /**< DSPI Baud rate fPCLK / 2 */
229 #define DSPI_BAUD_RATE_4P1PCLK LL_DSPI_BAUD_RATE_4P1PCLK /**< DSPI Baud rate fPCLK / 4 */
230 #define DSPI_BAUD_RATE_8P1PCLK LL_DSPI_BAUD_RATE_8P1PCLK /**< DSPI Baud rate fPCLK / 8 */
231 #define DSPI_BAUD_RATE_16P1PCLK LL_DSPI_BAUD_RATE_16P1PCLK /**< DSPI Baud rate fPCLK / 16 */
232 #define DSPI_BAUD_RATE_32P1PCLK LL_DSPI_BAUD_RATE_32P1PCLK /**< DSPI Baud rate fPCLK / 32 */
233 #define DSPI_BAUD_RATE_64P1PCLK LL_DSPI_BAUD_RATE_64P1PCLK /**< DSPI Baud rate fPCLK / 64 */
234 #define DSPI_BAUD_RATE_128P1PCLK LL_DSPI_BAUD_RATE_128P1PCLK /**< DSPI Baud rate fPCLK / 128 */
235 #define DSPI_BAUD_RATE_256P1PCLK LL_DSPI_BAUD_RATE_256PCLK /**< DSPI Baud rate fPCLK / 256 */
236
237 /** @} */
238
239 /** @defgroup DSPI_Interface_Mode DSPI Interface mode
240 * @{
241 */
242 #define DSPI_PROT_MODE_3W1L LL_DSPI_PROT_MODE_3W1L /**< DSPI 3-Wire 1-Lane Interface */
243 #define DSPI_PROT_MODE_4W1L LL_DSPI_PROT_MODE_4W1L /**< DSPI 4-Wire 1-Lane Interface */
244 #define DSPI_PROT_MODE_4W2L LL_DSPI_PROT_MODE_4W2L /**< DSPI 4-Wire 2-Lane Interface */
245 /** @} */
246
247 /** @defgroup DSPI_Instruction_Size DSPI Instruction Size
248 * @{
249 */
250 #define DSPI_INSTSIZE_08_BITS ((uint32_t)0x01) /**< 8-bit Instruction */
251 #define DSPI_INSTSIZE_16_BITS ((uint32_t)0x02) /**< 16-bit Instruction */
252 #define DSPI_INSTSIZE_32_BITS ((uint32_t)0x03) /**< 32-bit Instruction */
253 /** @} */
254
255 /** @defgroup DSPI_Data_Size Data Width
256 * @{
257 */
258 #define DSPI_DATASIZE_04_BITS LL_DSPI_DATASIZE_4BIT /**< Data length for DSPI transfer: 4 bits */
259 #define DSPI_DATASIZE_05_BITS LL_DSPI_DATASIZE_5BIT /**< Data length for DSPI transfer: 5 bits */
260 #define DSPI_DATASIZE_06_BITS LL_DSPI_DATASIZE_6BIT /**< Data length for DSPI transfer: 6 bits */
261 #define DSPI_DATASIZE_07_BITS LL_DSPI_DATASIZE_7BIT /**< Data length for DSPI transfer: 7 bits */
262 #define DSPI_DATASIZE_08_BITS LL_DSPI_DATASIZE_8BIT /**< Data length for DSPI transfer: 8 bits */
263 #define DSPI_DATASIZE_09_BITS LL_DSPI_DATASIZE_9BIT /**< Data length for DSPI transfer: 9 bits */
264 #define DSPI_DATASIZE_10_BITS LL_DSPI_DATASIZE_10BIT /**< Data length for DSPI transfer: 10 bits */
265 #define DSPI_DATASIZE_11_BITS LL_DSPI_DATASIZE_11BIT /**< Data length for DSPI transfer: 11 bits */
266 #define DSPI_DATASIZE_12_BITS LL_DSPI_DATASIZE_12BIT /**< Data length for DSPI transfer: 12 bits */
267 #define DSPI_DATASIZE_13_BITS LL_DSPI_DATASIZE_13BIT /**< Data length for DSPI transfer: 13 bits */
268 #define DSPI_DATASIZE_14_BITS LL_DSPI_DATASIZE_14BIT /**< Data length for DSPI transfer: 14 bits */
269 #define DSPI_DATASIZE_15_BITS LL_DSPI_DATASIZE_15BIT /**< Data length for DSPI transfer: 15 bits */
270 #define DSPI_DATASIZE_16_BITS LL_DSPI_DATASIZE_16BIT /**< Data length for DSPI transfer: 16 bits */
271 #define DSPI_DATASIZE_17_BITS LL_DSPI_DATASIZE_17BIT /**< Data length for DSPI transfer: 17 bits */
272 #define DSPI_DATASIZE_18_BITS LL_DSPI_DATASIZE_18BIT /**< Data length for DSPI transfer: 18 bits */
273 #define DSPI_DATASIZE_19_BITS LL_DSPI_DATASIZE_19BIT /**< Data length for DSPI transfer: 19 bits */
274 #define DSPI_DATASIZE_20_BITS LL_DSPI_DATASIZE_20BIT /**< Data length for DSPI transfer: 20 bits */
275 #define DSPI_DATASIZE_21_BITS LL_DSPI_DATASIZE_21BIT /**< Data length for DSPI transfer: 21 bits */
276 #define DSPI_DATASIZE_22_BITS LL_DSPI_DATASIZE_22BIT /**< Data length for DSPI transfer: 22 bits */
277 #define DSPI_DATASIZE_23_BITS LL_DSPI_DATASIZE_23BIT /**< Data length for DSPI transfer: 23 bits */
278 #define DSPI_DATASIZE_24_BITS LL_DSPI_DATASIZE_24BIT /**< Data length for DSPI transfer: 24 bits */
279 #define DSPI_DATASIZE_25_BITS LL_DSPI_DATASIZE_25BIT /**< Data length for DSPI transfer: 25 bits */
280 #define DSPI_DATASIZE_26_BITS LL_DSPI_DATASIZE_26BIT /**< Data length for DSPI transfer: 26 bits */
281 #define DSPI_DATASIZE_27_BITS LL_DSPI_DATASIZE_27BIT /**< Data length for DSPI transfer: 27 bits */
282 #define DSPI_DATASIZE_28_BITS LL_DSPI_DATASIZE_28BIT /**< Data length for DSPI transfer: 28 bits */
283 #define DSPI_DATASIZE_29_BITS LL_DSPI_DATASIZE_29BIT /**< Data length for DSPI transfer: 29 bits */
284 #define DSPI_DATASIZE_30_BITS LL_DSPI_DATASIZE_30BIT /**< Data length for DSPI transfer: 30 bits */
285 #define DSPI_DATASIZE_31_BITS LL_DSPI_DATASIZE_31BIT /**< Data length for DSPI transfer: 31 bits */
286 #define DSPI_DATASIZE_32_BITS LL_DSPI_DATASIZE_32BIT /**< Data length for DSPI transfer: 32 bits */
287
288 /** @} */
289
290 /** @defgroup DSPI_Flags DSPI Flags
291 * @{
292 */
293 #define DSPI_FLAG_FFE LL_DSPI_SR_FFE /**< Frame format error flag */
294 #define DSPI_FLAG_OVR LL_DSPI_SR_OVR /**< Rx overrun flag */
295 #define DSPI_FLAG_MODE LL_DSPI_SR_MODF /**< Mode fault flag */
296 #define DSPI_FLAG_RFNE LL_DSPI_SR_RFNE /**< Rx FIFO not empty flag */
297 #define DSPI_FLAG_TFE LL_DSPI_SR_TFE /**< Tx FIFO empty flag */
298 #define DSPI_FLAG_BUSY LL_DSPI_SR_BUSY /**< Busy flag */
299 /** @} */
300
301 /** @defgroup DSPI_Interrupts DSPI Interrupts
302 * @{
303 */
304 #define DSPI_IT_RXNE LL_DSPI_IM_RXNE /**< Receive FIFO not empty Interrupt */
305 #define DSPI_IT_ERR LL_DSPI_IM_ER /**< Error Interrupt */
306 #define DSPI_IT_TXE LL_DSPI_IM_TXE /**< Transmit FIFO Empty Interrupt */
307 /** @} */
308
309 /** @defgroup DSPI_RX_FIFO_Threshold DSPI rx FIFO threshold
310 * @{
311 */
312 #define DSPI_RX_FIFO_TH_1P2 LL_DSPI_FRXTH_1P2 /**< FIFO level is 1/2 (8 bytes) */
313 #define DSPI_RX_FIFO_TH_1P4 LL_DSPI_FRXTH_1P4 /**< FIFO level is 1/4 (4 bytes) */
314 #define DSPI_RX_FIFO_TH_1P8 LL_DSPI_FRXTH_1P8 /**< FIFO level is 1/8 (2 bytes) */
315 #define DSPI_RX_FIFO_TH_1P16 LL_DSPI_FRXTH_1P16 /**< FIFO level is 1/16 (1 bytes) */
316 /** @} */
317
318
319 /** @defgroup DSPI_Data_mode DSPI Data mode
320 * @{
321 */
322 #define DSPI_TRANSPORT_DATA LL_DSPI_DCX_DATA /**< Transport data */
323 #define DSPI_TRANSPORT_CMD LL_DSPI_DCX_CMD /**< Transport cmd */
324 /** @} */
325
326
327 /** @defgroup DSPI_Timeout_definition DSPI Timeout_definition
328 * @{
329 */
330 #define HAL_DSPI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
331 /** @} */
332
333 /** @} */
334
335 /* Exported macro ------------------------------------------------------------*/
336 /** @defgroup DSPI_Exported_Macros DSPI Exported Macros
337 * @{
338 */
339
340 /** @brief Reset DSPI handle states.
341 * @param __HANDLE__ DPI handle.
342 * @retval None
343 */
344 #define __HAL_DSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_DSPI_STATE_RESET)
345
346 /** @brief Enable the specified DSPI peripheral.
347 * @param __HANDLE__ Specifies the DSPI Handle.
348 * @retval None
349 */
350 #define __HAL_DSPI_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
351
352 /** @brief Disable the specified DSPI peripheral.
353 * @param __HANDLE__ Specifies the DSPI Handle.
354 * @retval None
355 */
356 #define __HAL_DSPI_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
357
358 /** @brief Enable the DSPI DMA TX Request.
359 * @param __HANDLE__ Specifies the DSPI Handle.
360 * @retval None
361 */
362 #define __HAL_DSPI_ENABLE_DMATX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
363
364 /** @brief Enable the DSPI DMA RX Request.
365 * @param __HANDLE__ Specifies the DSPI Handle.
366 * @retval None
367 */
368 #define __HAL_DSPI_ENABLE_DMARX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
369
370 /** @brief Disable the DSPI DMA TX Request.
371 * @param __HANDLE__ Specifies the DSPI Handle.
372 * @retval None
373 */
374 #define __HAL_DSPI_DISABLE_DMATX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
375
376 /** @brief Disable the DSPI DMA RX Request.
377 * @param __HANDLE__ Specifies the DSPI Handle.
378 * @retval None
379 */
380 #define __HAL_DSPI_DISABLE_DMARX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
381
382 /** @brief Enable the specified DSPI interrupts.
383 * @param __HANDLE__ Specifies the DSPI Handle.
384 * @param __INTERRUPT__ Specifies the interrupt source to enable.
385 * This parameter can be one of the following values:
386 * @arg @ref DSPI_IT_RXNE Receive FIFO not empty Interrupt enable
387 * @arg @ref DSPI_IT_TXE Transmit FIFO Empty Interrupt enable
388 * @arg @ref DSPI_IT_ERR Error Interrupt Interrupt enable
389 * @retval None
390 */
391 #define __HAL_DSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
392
393 /** @brief Disable the specified DSPI interrupts.
394 * @param __HANDLE__ Specifies the DSPI handle.
395 * @param __INTERRUPT__ Specifies the interrupt source to disable.
396 * This parameter can be one of the following values:
397 * @arg @ref DSPI_IT_RXNE Receive FIFO not empty Interrupt disable
398 * @arg @ref DSPI_IT_TXE Transmit FIFO Empty Interrupt disable
399 * @arg @ref DSPI_IT_ERR Error Interrupt Interrupt disable
400 * @retval None
401 */
402 #define __HAL_DSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
403
404 /** @brief Check whether the specified DSPI interrupt source is enabled or not.
405 * @param __HANDLE__ Specifies the DSPI Handle.
406 * @param __INTERRUPT__ Specifies the interrupt source to check.
407 * This parameter can be one of the following values:
408 * @arg @ref DSPI_IT_RXNE Receive FIFO not empty Interrupt disable
409 * @arg @ref DSPI_IT_TXE Transmit FIFO Empty Interrupt disable
410 * @arg @ref DSPI_IT_ERR Error Interrupt Interrupt disable
411 * @retval The new state of __IT__ (TRUE or FALSE).
412 */
413 #define __HAL_DSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__)) == (__INTERRUPT__))
414
415 /** @brief Check whether the specified DSPI flag is set or not.
416 * @param __HANDLE__ Specifies the DSPI Handle.
417 * @param __FLAG__ Specifies the flag to check.
418 * This parameter can be one of the following values:
419 * @arg @ref DSPI_FLAG_FFE Frame format error flag
420 * @arg @ref DSPI_FLAG_OVR Rx overrun flag
421 * @arg @ref DSPI_FLAG_MODE spi mode flag
422 * @arg @ref DSPI_FLAG_RFNE Rx FIFO not empty flag
423 * @arg @ref DSPI_FLAG_TFE Tx FIFO empty flag
424 * @arg @ref DSPI_FLAG_BUSY Busy flag
425 * @retval The new state of __FLAG__ (TRUE or FALSE).
426 */
427 #define __HAL_DSPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
428
429 /** @brief Flush the DSPI receiver FIFO.
430 * @param __HANDLE__ Specifies the DSPI Handle.
431 * @retval None
432 */
433 #define __HAL_DSPI_FLUSH_FIFO(__HANDLE__) ll_dspi_flush_fifo((__HANDLE__)->p_instance)
434
435 /** @brief Set the DSPI data transport type.
436 * @param __HANDLE__ Specifies the DSPI Handle.
437 * @param __TYPE__ Specifies the DSPI data transport type.
438 * @retval None
439 */
440 #define __HAL_DSPI_TRANSPORT_TYPE(__HANDLE__, __TYPE__) ll_dspi_set_dcx((__HANDLE__)->p_instance, (__TYPE__))
441
442 /** @} */
443
444 /* Private macros ------------------------------------------------------------*/
445 /** @defgroup DSPI_Private_Macro DSPI Private Macros
446 * @{
447 */
448
449 /** @brief Check if DSPI Clock Prescaler is valid.
450 * @param __PRESCALER__ DSPI Clock Prescaler.
451 * @retval SET (__PRESCALER__ is valid) or RESET (__PRESCALER__ is invalid)
452 */
453 #define IS_DSPI_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == DSPI_BAUD_RATE_2P1PCLK) || \
454 ((__PRESCALER__) == DSPI_BAUD_RATE_4P1PCLK) || \
455 ((__PRESCALER__) == DSPI_BAUD_RATE_8P1PCLK) || \
456 ((__PRESCALER__) == DSPI_BAUD_RATE_16P1PCLK) || \
457 ((__PRESCALER__) == DSPI_BAUD_RATE_32P1PCLK) || \
458 ((__PRESCALER__) == DSPI_BAUD_RATE_64P1PCLK) || \
459 ((__PRESCALER__) == DSPI_BAUD_RATE_128P1PCLK) || \
460 ((__PRESCALER__) == DSPI_BAUD_RATE_256P1PCLK))
461
462 /** @brief Check if DSPI Interface Mode is valid.
463 * @param __INTERFACEMODE__ QSPI Interface Mode.
464 * @retval SET (__INTERFACEMODE__ is valid) or RESET (__INTERFACEMODE__ is invalid)
465 */
466 #define IS_DSPI_INTERFACE_MODE(__INTERFACEMODE__) (((__INTERFACEMODE__) == DSPI_PROT_MODE_3W1L) || \
467 ((__INTERFACEMODE__) == DSPI_PROT_MODE_4W1L) || \
468 ((__INTERFACEMODE__) == DSPI_PROT_MODE_4W2L))
469
470 /** @brief Check if DSPI Instruction Size is valid.
471 * @param __INST_SIZE__ DSPI Instruction Size.
472 * @retval SET (__INST_SIZE__ is valid) or RESET (__INST_SIZE__ is invalid)
473 */
474 #define IS_DSPI_INSTRUCTION_SIZE(__INST_SIZE__) (((__INST_SIZE__) == DSPI_INSTSIZE_08_BITS) || \
475 ((__INST_SIZE__) == DSPI_INSTSIZE_16_BITS) || \
476 ((__INST_SIZE__) == DSPI_INSTSIZE_32_BITS))
477
478 /** @} */
479
480 /** @} */
481
482
483 /* Exported functions --------------------------------------------------------*/
484 /** @addtogroup HAL_DSPI_DRIVER_FUNCTIONS Functions
485 * @{
486 */
487
488 /** @addtogroup DSPI_Exported_Functions_Group1 Initialization and de-initialization functions
489 * @brief Initialization and de-initialization functions
490 *
491 @verbatim
492 ===============================================================================
493 ##### Initialization and de-initialization functions #####
494 ===============================================================================
495 [..] This subsection provides a set of functions allowing to initialize and
496 de-initialize the DSPIx peripheral:
497
498 (+) User must implement hal_dspi_msp_init() function in which he configures
499 all related peripherals resources (GPIO, DMA, IT and NVIC ).
500
501 (+) Call the function hal_dspi_init() to configure the selected device with
502 the selected configuration:
503 (++) baudrate
504 (++) dspi mode
505
506 (+) Call the function hal_dspi_deinit() to restore the default configuration
507 of the selected DSPIx peripheral.
508
509 @endverbatim
510 * @{
511 */
512
513 /**
514 ****************************************************************************************
515 * @brief Initialize the DSPI according to the specified parameters
516 * in the dspi_init_t and initialize the associated handle.
517 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
518 * @retval ::HAL_OK: Operation is OK.
519 * @retval ::HAL_ERROR: Parameter error or operation not supported.
520 * @retval ::HAL_BUSY: Driver is busy.
521 * @retval ::HAL_TIMEOUT: Timeout occurred.
522 ****************************************************************************************
523 */
524 hal_status_t hal_dspi_init(dspi_handle_t *p_dspi);
525
526 /**
527 ****************************************************************************************
528 * @brief De-initialize the DSPI peripheral.
529 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
530 * @retval ::HAL_OK: Operation is OK.
531 * @retval ::HAL_ERROR: Parameter error or operation not supported.
532 * @retval ::HAL_BUSY: Driver is busy.
533 * @retval ::HAL_TIMEOUT: Timeout occurred.
534 ****************************************************************************************
535 */
536 hal_status_t hal_dspi_deinit(dspi_handle_t *p_dspi);
537
538 /**
539 ****************************************************************************************
540 * @brief Initialize the DSPI MSP.
541 * @note This function should not be modified. When the callback is needed,
542 * the hal_dspi_msp_deinit can be implemented in the user file.
543 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
544 ****************************************************************************************
545 */
546 void hal_dspi_msp_init(dspi_handle_t *p_dspi);
547
548 /**
549 ****************************************************************************************
550 * @brief De-initialize the DSPI MSP.
551 * @note This function should not be modified. When the callback is needed,
552 * the hal_dspi_msp_deinit can be implemented in the user file.
553 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
554 ****************************************************************************************
555 */
556 void hal_dspi_msp_deinit(dspi_handle_t *p_dspi);
557
558 /** @} */
559
560 /** @defgroup DSPI_Exported_Functions_Group2 IO operation functions
561 * @brief Data transfers functions
562 *
563 @verbatim
564 ==============================================================================
565 ##### IO operation functions #####
566 ===============================================================================
567 [..]
568 This subsection provides a set of functions allowing to manage the DSPI
569 data transfers.
570
571 [..] The DSPI only supports master:
572
573 (#) There are two modes of transfer:
574 (++) Blocking mode: The communication is performed in polling mode.
575 The HAL status of all data processing is returned by the same function
576 after finishing transfer.
577 (++) No-Blocking mode: The communication is performed using Interrupts.
578 or DMA, These APIs return the HAL status.
579 The end of the data processing will be indicated through the
580 dedicated DSPI IRQ when using Interrupt mode or the DMA IRQ when
581 using DMA mode.
582 The hal_dspi_tx_cplt_callback() user callbacks
583 will be executed respectively at the end of the transmit or Receive process.
584 The hal_dspi_error_callback() user callback will be executed when a communication error is detected
585
586 (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
587 exist for 1 Line (simplex) and 2 Lines (full duplex) modes.
588
589 @endverbatim
590 * @{
591 */
592
593 /**
594 ****************************************************************************************
595 * @brief Transmit an amount of data with the specified instruction in blocking mode.
596 * @note This function is used only in Indirect Write Mode.
597 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
598 * @param[in] p_cmd: Pointer to a dspi_command_t structure that contains the instruction and address for data transfer.
599 * @param[in] p_data: Pointer to data buffer
600 * @param[in] timeout: Timeout duration
601 * @retval ::HAL_OK: Operation is OK.
602 * @retval ::HAL_ERROR: Parameter error or operation not supported.
603 * @retval ::HAL_BUSY: Driver is busy.
604 * @retval ::HAL_TIMEOUT: Timeout occurred.
605 ****************************************************************************************
606 */
607 hal_status_t hal_dspi_command_transmit(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout);
608
609 /**
610 ****************************************************************************************
611 * @brief Transmit only instruction in blocking mode.
612 * @note This function is used only in Indirect Write Mode.
613 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
614 * @param[in] p_cmd: Pointer to a dspi_command_t structure that contains the instruction and address for data transfer.
615 * @param[in] timeout: Timeout duration
616 * @retval ::HAL_OK: Operation is OK.
617 * @retval ::HAL_ERROR: Parameter error or operation not supported.
618 * @retval ::HAL_BUSY: Driver is busy.
619 * @retval ::HAL_TIMEOUT: Timeout occurred.
620 ****************************************************************************************
621 */
622 hal_status_t hal_dspi_command(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint32_t timeout);
623
624 /**
625 ****************************************************************************************
626 * @brief Transmit an amount of data in blocking mode.
627 * @note This function is used only in Indirect Write Mode.
628 * @param[in] p_qspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
629 * @param[in] p_data: Pointer to data buffer
630 * @param[in] length: Amount of data to be sent in bytes
631 * @param[in] timeout: Timeout duration
632 * @retval ::HAL_OK: Operation is OK.
633 * @retval ::HAL_ERROR: Parameter error or operation not supported.
634 * @retval ::HAL_BUSY: Driver is busy.
635 * @retval ::HAL_TIMEOUT: Timeout occurred.
636 ****************************************************************************************
637 */
638 hal_status_t hal_dspi_transmit(dspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length, uint32_t timeout);
639
640 /**
641 ****************************************************************************************
642 * @brief Transmit an amount of data with the specified instruction in non-blocking mode with Interrupt.
643 * @note This function is used only in Indirect Write Mode.
644 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
645 * @param[in] p_cmd: Pointer to a dspi_command_t structure that contains the instruction and address for data transfer.
646 * @param[in] p_data: Pointer to data buffer
647 * @retval ::HAL_OK: Operation is OK.
648 * @retval ::HAL_ERROR: Parameter error or operation not supported.
649 * @retval ::HAL_BUSY: Driver is busy.
650 * @retval ::HAL_TIMEOUT: Timeout occurred.
651 ****************************************************************************************
652 */
653 hal_status_t hal_dspi_command_transmit_it(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data);
654
655 /**
656 ****************************************************************************************
657 * @brief Transmit instruction in non-blocking mode with Interrupt.
658 * @note This function is used only in Indirect Write Mode.
659 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
660 * @param[in] p_cmd: Pointer to a dspi_command_t structure that contains the instruction and address for data transfer.
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_dspi_command_it(dspi_handle_t *p_dspi, dspi_command_t *p_cmd);
668
669 /**
670 ****************************************************************************************
671 * @brief Transmit an amount of data in non-blocking mode with Interrupt.
672 * @note This function is used only in Indirect Write Mode.
673 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
674 * @param[in] p_data: Pointer to data buffer
675 * @param[in] length: Amount of data to be sent in bytes
676 * @retval ::HAL_OK: Operation is OK.
677 * @retval ::HAL_ERROR: Parameter error or operation not supported.
678 * @retval ::HAL_BUSY: Driver is busy.
679 * @retval ::HAL_TIMEOUT: Timeout occurred.
680 ****************************************************************************************
681 */
682 hal_status_t hal_dspi_transmit_it(dspi_handle_t *p_dspi, uint8_t *p_data, uint32_t length);
683
684 /**
685 ****************************************************************************************
686 * @brief Transmit an amount of data with the specified instruction in non-blocking mode with DMA .
687 * @note This function is used only in Indirect Write Mode.
688 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
689 * @param[in] p_cmd: Pointer to a dspi_command_t structure that contains the instruction and address for data transfer.
690 * @param[in] p_data: Pointer to data buffer
691 * @retval ::HAL_OK: Operation is OK.
692 * @retval ::HAL_ERROR: Parameter error or operation not supported.
693 * @retval ::HAL_BUSY: Driver is busy.
694 * @retval ::HAL_TIMEOUT: Timeout occurred.
695 ****************************************************************************************
696 */
697 hal_status_t hal_dspi_command_transmit_dma(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data);
698
699 /**
700 ****************************************************************************************
701 * @brief Transmit an amount of data with the specified instruction in non-blocking mode with DMA SG or LLP.
702 * @note This function is used only in Indirect Write Mode.
703 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
704 * @param[in] p_cmd: Pointer to a dspi_command_t structure that contains the instruction and address for data transfer.
705 * @param[in] p_data: Pointer to data buffer
706 * @param[in] sg_llp_config: The config of source and destination's SG and LLP.
707 * @retval ::HAL_OK: Operation is OK.
708 * @retval ::HAL_ERROR: Parameter error or operation not supported.
709 * @retval ::HAL_BUSY: Driver is busy.
710 * @retval ::HAL_TIMEOUT: Timeout occurred.
711 ****************************************************************************************
712 */
713 hal_status_t hal_dspi_command_transmit_dma_sg_llp(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data,
714 dma_sg_llp_config_t *sg_llp_config);
715
716 /**
717 ****************************************************************************************
718 * @brief Transmit instruction in non-blocking mode with DMA.
719 * @note This function is used only in Indirect Write Mode.
720 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
721 * @param[in] p_cmd: Pointer to a dspi_command_t structure that contains the instruction and address for data transfer.
722 * @retval ::HAL_OK: Operation is OK.
723 * @retval ::HAL_ERROR: Parameter error or operation not supported.
724 * @retval ::HAL_BUSY: Driver is busy.
725 * @retval ::HAL_TIMEOUT: Timeout occurred.
726 ****************************************************************************************
727 */
728 hal_status_t hal_dspi_command_dma(dspi_handle_t *p_dspi, dspi_command_t *p_cmd);
729
730 /**
731 ****************************************************************************************
732 * @brief Transmit an amount of data in non-blocking mode with DMA.
733 * @note This function is used only in Indirect Write Mode.
734 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
735 * @param[in] p_data: Pointer to data buffer
736 * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
737 * @retval ::HAL_OK: Operation is OK.
738 * @retval ::HAL_ERROR: Parameter error or operation not supported.
739 * @retval ::HAL_BUSY: Driver is busy.
740 * @retval ::HAL_TIMEOUT: Timeout occurred.
741 ****************************************************************************************
742 */
743 hal_status_t hal_dspi_transmit_dma(dspi_handle_t *p_dspi, uint8_t *p_data, uint32_t length);
744
745 /**
746 ****************************************************************************************
747 * @brief Transmit an amount of data in non-blocking mode with DMA SG or LLP.
748 * @note This function is used only in Indirect Write Mode.
749 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
750 * @param[in] p_data: Pointer to data buffer
751 * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
752 * @param[in] sg_llp_config: The config of source and destination's SG and LLP.
753 * @retval ::HAL_OK: Operation is OK.
754 * @retval ::HAL_ERROR: Parameter error or operation not supported.
755 * @retval ::HAL_BUSY: Driver is busy.
756 * @retval ::HAL_TIMEOUT: Timeout occurred.
757 ****************************************************************************************
758 */
759 hal_status_t hal_dspi_transmit_dma_sg_llp(dspi_handle_t *p_dspi, uint8_t *p_data, uint32_t length,
760 dma_sg_llp_config_t *sg_llp_config);
761
762 /**
763 ****************************************************************************************
764 * @brief Abort the current transmission.
765 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
766 * @retval ::HAL_OK: Operation is OK.
767 * @retval ::HAL_ERROR: Parameter error or operation not supported.
768 * @retval ::HAL_BUSY: Driver is busy.
769 * @retval ::HAL_TIMEOUT: Timeout occurred.
770 ****************************************************************************************
771 */
772 hal_status_t hal_dspi_abort(dspi_handle_t *p_dspi);
773
774 /**
775 ****************************************************************************************
776 * @brief Abort the current transmission (non-blocking function)
777 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
778 * @retval ::HAL_OK: Operation is OK.
779 * @retval ::HAL_ERROR: Parameter error or operation not supported.
780 * @retval ::HAL_BUSY: Driver is busy.
781 * @retval ::HAL_TIMEOUT: Timeout occurred.
782 ****************************************************************************************
783 */
784 hal_status_t hal_dspi_abort_it(dspi_handle_t *p_dspi);
785
786 /** @} */
787
788 /** @addtogroup DSPI_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
789 * @brief IRQ Handler and Callbacks functions
790 * @{
791 */
792
793 /**
794 ****************************************************************************************
795 * @brief Handle DSPI interrupt request.
796 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
797 ****************************************************************************************
798 */
799 void hal_dspi_irq_handler(dspi_handle_t *p_dspi);
800
801 /**
802 ****************************************************************************************
803 * @brief Tx Transfer completed callback.
804 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
805 ****************************************************************************************
806 */
807 void hal_dspi_tx_cplt_callback(dspi_handle_t *p_dspi);
808
809 /**
810 ****************************************************************************************
811 * @brief DSPI error callback.
812 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
813 ****************************************************************************************
814 */
815 void hal_dspi_error_callback(dspi_handle_t *p_dspi);
816
817 /**
818 ****************************************************************************************
819 * @brief DSPI Abort callback.
820 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
821 ****************************************************************************************
822 */
823 void hal_dspi_abort_callback(dspi_handle_t *p_dspi);
824
825 /** @} */
826
827 /** @defgroup DSPI_Exported_Functions_Group3 Peripheral State and Errors functions
828 * @brief DSPI control functions
829 *
830 @verbatim
831 ===============================================================================
832 ##### Peripheral State and Errors functions #####
833 ===============================================================================
834 [..]
835 This subsection provides a set of functions allowing to control the DSPI.
836 (+) hal_dspi_get_state() API can be helpful to check in run-time the state of the DSPI peripheral.
837 (+) hal_dspi_get_error() check in run-time Errors occurring during communication.
838 @endverbatim
839 * @{
840 */
841
842 /**
843 ****************************************************************************************
844 * @brief Return the DSPI handle state.
845 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
846 *
847 * @retval ::HAL_DSPI_STATE_RESET: Peripheral not initialized.
848 * @retval ::HAL_DSPI_STATE_READY: Peripheral initialized and ready for use.
849 * @retval ::HAL_DSPI_STATE_BUSY: Peripheral in indirect mode and busy.
850 * @retval ::HAL_DSPI_STATE_BUSY_INDIRECT_TX: Peripheral in indirect mode with transmission ongoing.
851 * @retval ::HAL_DSPI_STATE_ABORT: Peripheral with abort request ongoing.
852 * @retval ::HAL_DSPI_STATE_ERROR: Peripheral in error.
853 ****************************************************************************************
854 */
855 hal_dspi_state_t hal_dspi_get_state(dspi_handle_t *p_dspi);
856
857 /**
858 ****************************************************************************************
859 * @brief Return the DSPI error code.
860 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
861 *
862 * @return DSPI error code in bitmap format
863 ****************************************************************************************
864 */
865 uint32_t hal_dspi_get_error(dspi_handle_t *p_dspi);
866
867 /**
868 ****************************************************************************************
869 * @brief Set the DSPI internal process timeout value.
870 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
871 * @param[in] timeout: Internal process timeout value.
872 *
873 * @retval ::HAL_OK: Operation is OK.
874 * @retval ::HAL_ERROR: Parameter error or operation not supported.
875 * @retval ::HAL_BUSY: Driver is busy.
876 * @retval ::HAL_TIMEOUT: Timeout occurred.
877 ****************************************************************************************
878 */
879 void hal_dspi_set_timeout(dspi_handle_t *p_dspi, uint32_t timeout);
880
881 /**
882 ****************************************************************************************
883 * @brief Set the DSPI transmission mode.
884 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration information for the specified DSPI module.
885 * @param[in] mode: The DSPI transmission mode. This parameter can be one of the following values:
886 * @arg @ref DSPI_PROT_MODE_3W1L
887 * @arg @ref DSPI_PROT_MODE_4W1L
888 * @arg @ref DSPI_PROT_MODE_4W2L
889 *
890 * @retval ::HAL_OK: Operation is OK.
891 * @retval ::HAL_ERROR: Parameter error or operation not supported.
892 * @retval ::HAL_BUSY: Driver is busy.
893 * @retval ::HAL_TIMEOUT: Timeout occurred.
894 ****************************************************************************************
895 */
896 hal_status_t hal_dspi_config_mode(dspi_handle_t *p_dspi, uint32_t mode);
897
898 /**
899 ****************************************************************************************
900 * @brief Suspend some registers related to DSPI configuration before sleep.
901 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration
902 * information for the specified DSPI module.
903 *
904 * @retval ::HAL_OK: Operation is OK.
905 * @retval ::HAL_ERROR: Parameter error or operation not supported.
906 * @retval ::HAL_BUSY: Driver is busy.
907 * @retval ::HAL_TIMEOUT: Timeout occurred.
908 ****************************************************************************************
909 */
910 hal_status_t hal_dspi_suspend_reg(dspi_handle_t *p_dspi);
911
912 /**
913 ****************************************************************************************
914 * @brief Restore some registers related to DSPI configuration after sleep.
915 * This function must be used in conjunction with the hal_dspi_suspend_reg().
916 * @param[in] p_dspi: Pointer to a DSPI handle which contains the configuration
917 * information for the specified DSPI module.
918 *
919 * @retval ::HAL_OK: Operation is OK.
920 * @retval ::HAL_ERROR: Parameter error or operation not supported.
921 * @retval ::HAL_BUSY: Driver is busy.
922 * @retval ::HAL_TIMEOUT: Timeout occurred.
923 ****************************************************************************************
924 */
925 hal_status_t hal_dspi_resume_reg(dspi_handle_t *p_dspi);
926
927 /** @} */
928
929 /** @} */
930
931 #ifdef __cplusplus
932 }
933 #endif
934
935 #endif /* __GR55xx_HAL_DSPI_H__ */
936
937 /** @} */
938
939 /** @} */
940
941 /** @} */
hal_dspi_msp_init
void hal_dspi_msp_init(dspi_handle_t *p_dspi)
Initialize the DSPI MSP.
hal_dspi_transmit_dma_sg_llp
hal_status_t hal_dspi_transmit_dma_sg_llp(dspi_handle_t *p_dspi, uint8_t *p_data, uint32_t length, dma_sg_llp_config_t *sg_llp_config)
Transmit an amount of data in non-blocking mode with DMA SG or LLP.
_hal_dspi_callback
HAL_DSPI Callback function definition.
Definition: gr55xx_hal_dspi.h:193
hal_dspi_error_callback
void hal_dspi_error_callback(dspi_handle_t *p_dspi)
DSPI error callback.
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_dspi_handle::init
dspi_init_t init
Definition: gr55xx_hal_dspi.h:127
HAL_DSPI_STATE_READY
@ HAL_DSPI_STATE_READY
Definition: gr55xx_hal_dspi.h:79
HAL_DSPI_STATE_BUSY
@ HAL_DSPI_STATE_BUSY
Definition: gr55xx_hal_dspi.h:80
_dspi_handle::retention
uint32_t retention[3]
Definition: gr55xx_hal_dspi.h:149
_dspi_command_t
DSPI command Structure definition.
Definition: gr55xx_hal_dspi.h:161
hal_dspi_command_dma
hal_status_t hal_dspi_command_dma(dspi_handle_t *p_dspi, dspi_command_t *p_cmd)
Transmit instruction in non-blocking mode with DMA.
_hal_dspi_callback::dspi_abort_callback
void(* dspi_abort_callback)(dspi_handle_t *p_dspi)
Definition: gr55xx_hal_dspi.h:196
_dspi_handle::error_code
__IO uint32_t error_code
Definition: gr55xx_hal_dspi.h:143
hal_dspi_command_transmit_it
hal_status_t hal_dspi_command_transmit_it(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data)
Transmit an amount of data with the specified instruction in non-blocking mode with Interrupt.
_dspi_handle::p_instance
dspi_regs_t * p_instance
Definition: gr55xx_hal_dspi.h:125
dspi_handle_t
struct _dspi_handle dspi_handle_t
DSPI handle Structure definition.
hal_dspi_callback_t
struct _hal_dspi_callback hal_dspi_callback_t
HAL_DSPI Callback function definition.
hal_dspi_state_t
hal_dspi_state_t
HAL DSPI State Enumerations definition.
Definition: gr55xx_hal_dspi.h:77
hal_dspi_resume_reg
hal_status_t hal_dspi_resume_reg(dspi_handle_t *p_dspi)
Restore some registers related to DSPI configuration after sleep. This function must be used in conju...
_dspi_init_t::data_size
uint32_t data_size
Definition: gr55xx_hal_dspi.h:104
_dspi_handle::dspi_number
periph_device_number_t dspi_number
Definition: gr55xx_hal_dspi.h:147
hal_dspi_command_it
hal_status_t hal_dspi_command_it(dspi_handle_t *p_dspi, dspi_command_t *p_cmd)
Transmit instruction in non-blocking mode with Interrupt.
HAL_DSPI_STATE_ABORT
@ HAL_DSPI_STATE_ABORT
Definition: gr55xx_hal_dspi.h:82
dspi_command_t
struct _dspi_command_t dspi_command_t
DSPI command Structure definition.
dma_sg_llp_config
LL DMA sg and llp config definition.
Definition: gr55xx_hal_dma.h:219
_dspi_handle::tx_xfer_count
__IO uint32_t tx_xfer_count
Definition: gr55xx_hal_dspi.h:133
hal_dspi_get_state
hal_dspi_state_t hal_dspi_get_state(dspi_handle_t *p_dspi)
Return the DSPI handle state.
hal_dspi_abort_callback
void hal_dspi_abort_callback(dspi_handle_t *p_dspi)
DSPI Abort callback.
HAL_DSPI_STATE_ERROR
@ HAL_DSPI_STATE_ERROR
Definition: gr55xx_hal_dspi.h:83
_dspi_command_t::length
uint32_t length
Definition: gr55xx_hal_dspi.h:171
hal_dspi_transmit_dma
hal_status_t hal_dspi_transmit_dma(dspi_handle_t *p_dspi, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with DMA.
hal_dspi_command_transmit_dma_sg_llp
hal_status_t hal_dspi_command_transmit_dma_sg_llp(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data, dma_sg_llp_config_t *sg_llp_config)
Transmit an amount of data with the specified instruction in non-blocking mode with DMA SG or LLP.
_hal_dspi_callback::dspi_tx_cplt_callback
void(* dspi_tx_cplt_callback)(dspi_handle_t *p_dspi)
Definition: gr55xx_hal_dspi.h:198
_dspi_init_t
QSPI init Structure definition.
Definition: gr55xx_hal_dspi.h:103
hal_dspi_command_transmit
hal_status_t hal_dspi_command_transmit(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout)
Transmit an amount of data with the specified instruction in blocking mode.
hal_dspi_abort_it
hal_status_t hal_dspi_abort_it(dspi_handle_t *p_dspi)
Abort the current transmission (non-blocking function)
_dspi_command_t::data_size
uint32_t data_size
Definition: gr55xx_hal_dspi.h:168
hal_dspi_irq_handler
void hal_dspi_irq_handler(dspi_handle_t *p_dspi)
Handle DSPI interrupt request.
_dspi_command_t::instruction_size
uint32_t instruction_size
Definition: gr55xx_hal_dspi.h:165
hal_dspi_transmit
hal_status_t hal_dspi_transmit(dspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in blocking mode.
HAL_DSPI_STATE_RESET
@ HAL_DSPI_STATE_RESET
Definition: gr55xx_hal_dspi.h:78
hal_dspi_tx_cplt_callback
void hal_dspi_tx_cplt_callback(dspi_handle_t *p_dspi)
Tx Transfer completed callback.
hal_dspi_command_transmit_dma
hal_status_t hal_dspi_command_transmit_dma(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint8_t *p_data)
Transmit an amount of data with the specified instruction in non-blocking mode with DMA .
_dspi_handle::p_dmatx
dma_handle_t * p_dmatx
Definition: gr55xx_hal_dspi.h:137
_dspi_handle::timeout
uint32_t timeout
Definition: gr55xx_hal_dspi.h:145
_dspi_init_t::baud_rate
uint32_t baud_rate
Definition: gr55xx_hal_dspi.h:107
_dspi_handle
DSPI handle Structure definition.
Definition: gr55xx_hal_dspi.h:124
_dspi_command_t::instruction
uint32_t instruction
Definition: gr55xx_hal_dspi.h:162
hal_dspi_init
hal_status_t hal_dspi_init(dspi_handle_t *p_dspi)
Initialize the DSPI according to the specified parameters in the dspi_init_t and initialize the assoc...
hal_dspi_command
hal_status_t hal_dspi_command(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint32_t timeout)
Transmit only instruction in blocking mode.
_dspi_handle::p_tx_buffer
uint8_t * p_tx_buffer
Definition: gr55xx_hal_dspi.h:129
hal_dspi_transmit_it
hal_status_t hal_dspi_transmit_it(dspi_handle_t *p_dspi, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with Interrupt.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
dspi_init_t
struct _dspi_init_t dspi_init_t
QSPI init Structure definition.
hal_dspi_config_mode
hal_status_t hal_dspi_config_mode(dspi_handle_t *p_dspi, uint32_t mode)
Set the DSPI transmission mode.
hal_dspi_get_error
uint32_t hal_dspi_get_error(dspi_handle_t *p_dspi)
Return the DSPI error code.
hal_dspi_deinit
hal_status_t hal_dspi_deinit(dspi_handle_t *p_dspi)
De-initialize the DSPI peripheral.
_dspi_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_dspi.h:139
_hal_dspi_callback::dspi_error_callback
void(* dspi_error_callback)(dspi_handle_t *p_dspi)
Definition: gr55xx_hal_dspi.h:197
gr55xx_hal_pwr_mgmt.h
This file contains all the functions prototypes for the HAL module driver.
_hal_dspi_callback::dspi_msp_init
void(* dspi_msp_init)(dspi_handle_t *p_dspi)
Definition: gr55xx_hal_dspi.h:194
_hal_dspi_callback::dspi_msp_deinit
void(* dspi_msp_deinit)(dspi_handle_t *p_dspi)
Definition: gr55xx_hal_dspi.h:195
gr55xx_ll_dspi.h
Header file containing functions prototypes of DSPI LL library.
hal_dspi_msp_deinit
void hal_dspi_msp_deinit(dspi_handle_t *p_dspi)
De-initialize the DSPI MSP.
hal_dspi_suspend_reg
hal_status_t hal_dspi_suspend_reg(dspi_handle_t *p_dspi)
Suspend some registers related to DSPI configuration before sleep.
_dspi_init_t::dspi_mode
uint32_t dspi_mode
Definition: gr55xx_hal_dspi.h:110
hal_dspi_set_timeout
void hal_dspi_set_timeout(dspi_handle_t *p_dspi, uint32_t timeout)
Set the DSPI internal process timeout value.
periph_device_number_t
periph_device_number_t
Peripheral Device ID definition NOTE:The order of enumeration is the order of recovery.
Definition: gr55xx_hal_pwr_mgmt.h:86
_dma_handle
DMA handle Structure definition.
Definition: gr55xx_hal_dma.h:277
_dspi_handle::tx_xfer_size
__IO uint32_t tx_xfer_size
Definition: gr55xx_hal_dspi.h:131
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_dspi_handle::write_fifo
void(* write_fifo)(struct _dspi_handle *p_dspi)
Definition: gr55xx_hal_dspi.h:135
_dspi_handle::state
__IO hal_dspi_state_t state
Definition: gr55xx_hal_dspi.h:141
HAL_DSPI_STATE_BUSY_INDIRECT_TX
@ HAL_DSPI_STATE_BUSY_INDIRECT_TX
Definition: gr55xx_hal_dspi.h:81
hal_dspi_abort
hal_status_t hal_dspi_abort(dspi_handle_t *p_dspi)
Abort the current transmission.