Go to the documentation of this file.
52 #ifndef __GR55xx_HAL_DSPI_H__
53 #define __GR55xx_HAL_DSPI_H__
218 #define HAL_DSPI_ERROR_NONE ((uint32_t)0x00000000)
219 #define HAL_DSPI_ERROR_TIMEOUT ((uint32_t)0x00000001)
220 #define HAL_DSPI_ERROR_TRANSFER ((uint32_t)0x00000002)
221 #define HAL_DSPI_ERROR_DMA ((uint32_t)0x00000004)
222 #define HAL_DSPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008)
228 #define DSPI_BAUD_RATE_2P1PCLK LL_DSPI_BAUD_RATE_2P1PCLK
229 #define DSPI_BAUD_RATE_4P1PCLK LL_DSPI_BAUD_RATE_4P1PCLK
230 #define DSPI_BAUD_RATE_8P1PCLK LL_DSPI_BAUD_RATE_8P1PCLK
231 #define DSPI_BAUD_RATE_16P1PCLK LL_DSPI_BAUD_RATE_16P1PCLK
232 #define DSPI_BAUD_RATE_32P1PCLK LL_DSPI_BAUD_RATE_32P1PCLK
233 #define DSPI_BAUD_RATE_64P1PCLK LL_DSPI_BAUD_RATE_64P1PCLK
234 #define DSPI_BAUD_RATE_128P1PCLK LL_DSPI_BAUD_RATE_128P1PCLK
235 #define DSPI_BAUD_RATE_256P1PCLK LL_DSPI_BAUD_RATE_256PCLK
242 #define DSPI_PROT_MODE_3W1L LL_DSPI_PROT_MODE_3W1L
243 #define DSPI_PROT_MODE_4W1L LL_DSPI_PROT_MODE_4W1L
244 #define DSPI_PROT_MODE_4W2L LL_DSPI_PROT_MODE_4W2L
250 #define DSPI_INSTSIZE_08_BITS ((uint32_t)0x01)
251 #define DSPI_INSTSIZE_16_BITS ((uint32_t)0x02)
252 #define DSPI_INSTSIZE_32_BITS ((uint32_t)0x03)
258 #define DSPI_DATASIZE_04_BITS LL_DSPI_DATASIZE_4BIT
259 #define DSPI_DATASIZE_05_BITS LL_DSPI_DATASIZE_5BIT
260 #define DSPI_DATASIZE_06_BITS LL_DSPI_DATASIZE_6BIT
261 #define DSPI_DATASIZE_07_BITS LL_DSPI_DATASIZE_7BIT
262 #define DSPI_DATASIZE_08_BITS LL_DSPI_DATASIZE_8BIT
263 #define DSPI_DATASIZE_09_BITS LL_DSPI_DATASIZE_9BIT
264 #define DSPI_DATASIZE_10_BITS LL_DSPI_DATASIZE_10BIT
265 #define DSPI_DATASIZE_11_BITS LL_DSPI_DATASIZE_11BIT
266 #define DSPI_DATASIZE_12_BITS LL_DSPI_DATASIZE_12BIT
267 #define DSPI_DATASIZE_13_BITS LL_DSPI_DATASIZE_13BIT
268 #define DSPI_DATASIZE_14_BITS LL_DSPI_DATASIZE_14BIT
269 #define DSPI_DATASIZE_15_BITS LL_DSPI_DATASIZE_15BIT
270 #define DSPI_DATASIZE_16_BITS LL_DSPI_DATASIZE_16BIT
271 #define DSPI_DATASIZE_17_BITS LL_DSPI_DATASIZE_17BIT
272 #define DSPI_DATASIZE_18_BITS LL_DSPI_DATASIZE_18BIT
273 #define DSPI_DATASIZE_19_BITS LL_DSPI_DATASIZE_19BIT
274 #define DSPI_DATASIZE_20_BITS LL_DSPI_DATASIZE_20BIT
275 #define DSPI_DATASIZE_21_BITS LL_DSPI_DATASIZE_21BIT
276 #define DSPI_DATASIZE_22_BITS LL_DSPI_DATASIZE_22BIT
277 #define DSPI_DATASIZE_23_BITS LL_DSPI_DATASIZE_23BIT
278 #define DSPI_DATASIZE_24_BITS LL_DSPI_DATASIZE_24BIT
279 #define DSPI_DATASIZE_25_BITS LL_DSPI_DATASIZE_25BIT
280 #define DSPI_DATASIZE_26_BITS LL_DSPI_DATASIZE_26BIT
281 #define DSPI_DATASIZE_27_BITS LL_DSPI_DATASIZE_27BIT
282 #define DSPI_DATASIZE_28_BITS LL_DSPI_DATASIZE_28BIT
283 #define DSPI_DATASIZE_29_BITS LL_DSPI_DATASIZE_29BIT
284 #define DSPI_DATASIZE_30_BITS LL_DSPI_DATASIZE_30BIT
285 #define DSPI_DATASIZE_31_BITS LL_DSPI_DATASIZE_31BIT
286 #define DSPI_DATASIZE_32_BITS LL_DSPI_DATASIZE_32BIT
293 #define DSPI_FLAG_FFE LL_DSPI_SR_FFE
294 #define DSPI_FLAG_OVR LL_DSPI_SR_OVR
295 #define DSPI_FLAG_MODE LL_DSPI_SR_MODF
296 #define DSPI_FLAG_RFNE LL_DSPI_SR_RFNE
297 #define DSPI_FLAG_TFE LL_DSPI_SR_TFE
298 #define DSPI_FLAG_BUSY LL_DSPI_SR_BUSY
304 #define DSPI_IT_RXNE LL_DSPI_IM_RXNE
305 #define DSPI_IT_ERR LL_DSPI_IM_ER
306 #define DSPI_IT_TXE LL_DSPI_IM_TXE
312 #define DSPI_RX_FIFO_TH_1P2 LL_DSPI_FRXTH_1P2
313 #define DSPI_RX_FIFO_TH_1P4 LL_DSPI_FRXTH_1P4
314 #define DSPI_RX_FIFO_TH_1P8 LL_DSPI_FRXTH_1P8
315 #define DSPI_RX_FIFO_TH_1P16 LL_DSPI_FRXTH_1P16
322 #define DSPI_TRANSPORT_DATA LL_DSPI_DCX_DATA
323 #define DSPI_TRANSPORT_CMD LL_DSPI_DCX_CMD
330 #define HAL_DSPI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
344 #define __HAL_DSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_DSPI_STATE_RESET)
350 #define __HAL_DSPI_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
356 #define __HAL_DSPI_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
362 #define __HAL_DSPI_ENABLE_DMATX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
368 #define __HAL_DSPI_ENABLE_DMARX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
374 #define __HAL_DSPI_DISABLE_DMATX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
380 #define __HAL_DSPI_DISABLE_DMARX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
391 #define __HAL_DSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
402 #define __HAL_DSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
413 #define __HAL_DSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__)) == (__INTERRUPT__))
427 #define __HAL_DSPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
433 #define __HAL_DSPI_FLUSH_FIFO(__HANDLE__) ll_dspi_flush_fifo((__HANDLE__)->p_instance)
440 #define __HAL_DSPI_TRANSPORT_TYPE(__HANDLE__, __TYPE__) ll_dspi_set_dcx((__HANDLE__)->p_instance, (__TYPE__))
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))
466 #define IS_DSPI_INTERFACE_MODE(__INTERFACEMODE__) (((__INTERFACEMODE__) == DSPI_PROT_MODE_3W1L) || \
467 ((__INTERFACEMODE__) == DSPI_PROT_MODE_4W1L) || \
468 ((__INTERFACEMODE__) == DSPI_PROT_MODE_4W2L))
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))
void hal_dspi_msp_init(dspi_handle_t *p_dspi)
Initialize the DSPI MSP.
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 function definition.
void hal_dspi_error_callback(dspi_handle_t *p_dspi)
DSPI error callback.
hal_lock_t
HAL Lock structures definition.
DSPI command Structure definition.
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.
void(* dspi_abort_callback)(dspi_handle_t *p_dspi)
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.
struct _dspi_handle dspi_handle_t
DSPI handle Structure definition.
struct _hal_dspi_callback hal_dspi_callback_t
HAL_DSPI Callback function definition.
hal_dspi_state_t
HAL DSPI State Enumerations definition.
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...
periph_device_number_t dspi_number
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.
struct _dspi_command_t dspi_command_t
DSPI command Structure definition.
LL DMA sg and llp config definition.
__IO uint32_t tx_xfer_count
hal_dspi_state_t hal_dspi_get_state(dspi_handle_t *p_dspi)
Return the DSPI handle state.
void hal_dspi_abort_callback(dspi_handle_t *p_dspi)
DSPI Abort callback.
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_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.
void(* dspi_tx_cplt_callback)(dspi_handle_t *p_dspi)
QSPI init Structure definition.
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_status_t hal_dspi_abort_it(dspi_handle_t *p_dspi)
Abort the current transmission (non-blocking function)
void hal_dspi_irq_handler(dspi_handle_t *p_dspi)
Handle DSPI interrupt request.
uint32_t instruction_size
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.
void hal_dspi_tx_cplt_callback(dspi_handle_t *p_dspi)
Tx Transfer completed callback.
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 Structure definition.
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_status_t hal_dspi_command(dspi_handle_t *p_dspi, dspi_command_t *p_cmd, uint32_t timeout)
Transmit only instruction in blocking mode.
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 structures definition.
struct _dspi_init_t dspi_init_t
QSPI init Structure definition.
hal_status_t hal_dspi_config_mode(dspi_handle_t *p_dspi, uint32_t mode)
Set the DSPI transmission mode.
uint32_t hal_dspi_get_error(dspi_handle_t *p_dspi)
Return the DSPI error code.
hal_status_t hal_dspi_deinit(dspi_handle_t *p_dspi)
De-initialize the DSPI peripheral.
void(* dspi_error_callback)(dspi_handle_t *p_dspi)
This file contains all the functions prototypes for the HAL module driver.
void(* dspi_msp_init)(dspi_handle_t *p_dspi)
void(* dspi_msp_deinit)(dspi_handle_t *p_dspi)
Header file containing functions prototypes of DSPI LL library.
void hal_dspi_msp_deinit(dspi_handle_t *p_dspi)
De-initialize the DSPI MSP.
hal_status_t hal_dspi_suspend_reg(dspi_handle_t *p_dspi)
Suspend some registers related to DSPI configuration before sleep.
void hal_dspi_set_timeout(dspi_handle_t *p_dspi, uint32_t timeout)
Set the DSPI internal process timeout value.
periph_device_number_t
Peripheral Device ID definition NOTE:The order of enumeration is the order of recovery.
DMA handle Structure definition.
__IO uint32_t tx_xfer_size
This file contains HAL common definitions, enumeration, macros and structures definitions.
void(* write_fifo)(struct _dspi_handle *p_dspi)
__IO hal_dspi_state_t state
@ HAL_DSPI_STATE_BUSY_INDIRECT_TX
hal_status_t hal_dspi_abort(dspi_handle_t *p_dspi)
Abort the current transmission.