Go to the documentation of this file.
52 #ifndef __GR55xx_HAL_DSPI_H__
53 #define __GR55xx_HAL_DSPI_H__
205 #define HAL_DSPI_ERROR_NONE ((uint32_t)0x00000000)
206 #define HAL_DSPI_ERROR_TIMEOUT ((uint32_t)0x00000001)
207 #define HAL_DSPI_ERROR_TRANSFER ((uint32_t)0x00000002)
208 #define HAL_DSPI_ERROR_DMA ((uint32_t)0x00000004)
209 #define HAL_DSPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008)
215 #define DSPI_BAUD_RATE_2P1PCLK LL_DSPI_BAUD_RATE_2P1PCLK
216 #define DSPI_BAUD_RATE_4P1PCLK LL_DSPI_BAUD_RATE_4P1PCLK
217 #define DSPI_BAUD_RATE_8P1PCLK LL_DSPI_BAUD_RATE_8P1PCLK
218 #define DSPI_BAUD_RATE_16P1PCLK LL_DSPI_BAUD_RATE_16P1PCLK
219 #define DSPI_BAUD_RATE_32P1PCLK LL_DSPI_BAUD_RATE_32P1PCLK
220 #define DSPI_BAUD_RATE_64P1PCLK LL_DSPI_BAUD_RATE_64P1PCLK
221 #define DSPI_BAUD_RATE_128P1PCLK LL_DSPI_BAUD_RATE_128P1PCLK
222 #define DSPI_BAUD_RATE_256P1PCLK LL_DSPI_BAUD_RATE_256PCLK
229 #define DSPI_PROT_MODE_3W1L LL_DSPI_PROT_MODE_3W1L
230 #define DSPI_PROT_MODE_4W1L LL_DSPI_PROT_MODE_4W1L
231 #define DSPI_PROT_MODE_4W2L LL_DSPI_PROT_MODE_4W2L
237 #define DSPI_INSTSIZE_08_BITS ((uint32_t)0x01)
238 #define DSPI_INSTSIZE_16_BITS ((uint32_t)0x02)
239 #define DSPI_INSTSIZE_32_BITS ((uint32_t)0x03)
245 #define DSPI_DATASIZE_04_BITS LL_DSPI_DATASIZE_4BIT
246 #define DSPI_DATASIZE_05_BITS LL_DSPI_DATASIZE_5BIT
247 #define DSPI_DATASIZE_06_BITS LL_DSPI_DATASIZE_6BIT
248 #define DSPI_DATASIZE_07_BITS LL_DSPI_DATASIZE_7BIT
249 #define DSPI_DATASIZE_08_BITS LL_DSPI_DATASIZE_8BIT
250 #define DSPI_DATASIZE_09_BITS LL_DSPI_DATASIZE_9BIT
251 #define DSPI_DATASIZE_10_BITS LL_DSPI_DATASIZE_10BIT
252 #define DSPI_DATASIZE_11_BITS LL_DSPI_DATASIZE_11BIT
253 #define DSPI_DATASIZE_12_BITS LL_DSPI_DATASIZE_12BIT
254 #define DSPI_DATASIZE_13_BITS LL_DSPI_DATASIZE_13BIT
255 #define DSPI_DATASIZE_14_BITS LL_DSPI_DATASIZE_14BIT
256 #define DSPI_DATASIZE_15_BITS LL_DSPI_DATASIZE_15BIT
257 #define DSPI_DATASIZE_16_BITS LL_DSPI_DATASIZE_16BIT
258 #define DSPI_DATASIZE_17_BITS LL_DSPI_DATASIZE_17BIT
259 #define DSPI_DATASIZE_18_BITS LL_DSPI_DATASIZE_18BIT
260 #define DSPI_DATASIZE_19_BITS LL_DSPI_DATASIZE_19BIT
261 #define DSPI_DATASIZE_20_BITS LL_DSPI_DATASIZE_20BIT
262 #define DSPI_DATASIZE_21_BITS LL_DSPI_DATASIZE_21BIT
263 #define DSPI_DATASIZE_22_BITS LL_DSPI_DATASIZE_22BIT
264 #define DSPI_DATASIZE_23_BITS LL_DSPI_DATASIZE_23BIT
265 #define DSPI_DATASIZE_24_BITS LL_DSPI_DATASIZE_24BIT
266 #define DSPI_DATASIZE_25_BITS LL_DSPI_DATASIZE_25BIT
267 #define DSPI_DATASIZE_26_BITS LL_DSPI_DATASIZE_26BIT
268 #define DSPI_DATASIZE_27_BITS LL_DSPI_DATASIZE_27BIT
269 #define DSPI_DATASIZE_28_BITS LL_DSPI_DATASIZE_28BIT
270 #define DSPI_DATASIZE_29_BITS LL_DSPI_DATASIZE_29BIT
271 #define DSPI_DATASIZE_30_BITS LL_DSPI_DATASIZE_30BIT
272 #define DSPI_DATASIZE_31_BITS LL_DSPI_DATASIZE_31BIT
273 #define DSPI_DATASIZE_32_BITS LL_DSPI_DATASIZE_32BIT
280 #define DSPI_FLAG_FFE LL_DSPI_SR_FFE
281 #define DSPI_FLAG_OVR LL_DSPI_SR_OVR
282 #define DSPI_FLAG_MODE LL_DSPI_SR_MODF
283 #define DSPI_FLAG_RFNE LL_DSPI_SR_RFNE
284 #define DSPI_FLAG_TFE LL_DSPI_SR_TFE
285 #define DSPI_FLAG_BUSY LL_DSPI_SR_BUSY
291 #define DSPI_IT_RXNE LL_DSPI_IM_RXNE
292 #define DSPI_IT_ERR LL_DSPI_IM_ER
293 #define DSPI_IT_TXE LL_DSPI_IM_TXE
299 #define DSPI_RX_FIFO_TH_1P2 LL_DSPI_FRXTH_1P2
300 #define DSPI_RX_FIFO_TH_1P4 LL_DSPI_FRXTH_1P4
301 #define DSPI_RX_FIFO_TH_1P8 LL_DSPI_FRXTH_1P8
302 #define DSPI_RX_FIFO_TH_1P16 LL_DSPI_FRXTH_1P16
309 #define DSPI_TRANSPORT_DATA LL_DSPI_DCX_DATA
310 #define DSPI_TRANSPORT_CMD LL_DSPI_DCX_CMD
317 #define HAL_DSPI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
331 #define __HAL_DSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_DSPI_STATE_RESET)
337 #define __HAL_DSPI_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
343 #define __HAL_DSPI_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
349 #define __HAL_DSPI_ENABLE_DMATX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
355 #define __HAL_DSPI_ENABLE_DMARX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
361 #define __HAL_DSPI_DISABLE_DMATX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
367 #define __HAL_DSPI_DISABLE_DMARX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
378 #define __HAL_DSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
389 #define __HAL_DSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
400 #define __HAL_DSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__)) == (__INTERRUPT__))
414 #define __HAL_DSPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
420 #define __HAL_DSPI_FLUSH_FIFO(__HANDLE__) ll_dspi_flush_fifo((__HANDLE__)->p_instance)
427 #define __HAL_DSPI_TRANSPORT_TYPE(__HANDLE__, __TYPE__) ll_dspi_set_dcx((__HANDLE__)->p_instance, (__TYPE__))
440 #define IS_DSPI_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == DSPI_BAUD_RATE_2P1PCLK) || \
441 ((__PRESCALER__) == DSPI_BAUD_RATE_4P1PCLK) || \
442 ((__PRESCALER__) == DSPI_BAUD_RATE_8P1PCLK) || \
443 ((__PRESCALER__) == DSPI_BAUD_RATE_16P1PCLK) || \
444 ((__PRESCALER__) == DSPI_BAUD_RATE_32P1PCLK) || \
445 ((__PRESCALER__) == DSPI_BAUD_RATE_64P1PCLK) || \
446 ((__PRESCALER__) == DSPI_BAUD_RATE_128P1PCLK) || \
447 ((__PRESCALER__) == DSPI_BAUD_RATE_256P1PCLK))
453 #define IS_DSPI_INTERFACE_MODE(__INTERFACEMODE__) (((__INTERFACEMODE__) == DSPI_PROT_MODE_3W1L) || \
454 ((__INTERFACEMODE__) == DSPI_PROT_MODE_4W1L) || \
455 ((__INTERFACEMODE__) == DSPI_PROT_MODE_4W2L))
461 #define IS_DSPI_INSTRUCTION_SIZE(__INST_SIZE__) (((__INST_SIZE__) == DSPI_INSTSIZE_08_BITS) || \
462 ((__INST_SIZE__) == DSPI_INSTSIZE_16_BITS) || \
463 ((__INST_SIZE__) == DSPI_INSTSIZE_32_BITS))
@ HAL_DSPI_STATE_BUSY_INDIRECT_TX
hal_dspi_state_t
HAL DSPI State Enumerations definition.
void hal_dspi_msp_init(dspi_handle_t *p_dspi)
Initialize the DSPI MSP.
void(* dspi_msp_init)(dspi_handle_t *p_dspi)
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.
void hal_dspi_error_callback(dspi_handle_t *p_dspi)
DSPI error callback.
hal_lock_t
HAL Lock structures definition.
struct _dspi_callback dspi_callback_t
HAL_DSPI Callback function 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.
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.
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 .
void(* dspi_abort_callback)(dspi_handle_t *p_dspi)
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...
void(* dspi_msp_deinit)(dspi_handle_t *p_dspi)
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.
This file contains all the functions prototypes for the HAL module driver.
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.
HAL_DSPI Callback function definition.
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
void(* dspi_error_callback)(dspi_handle_t *p_dspi)
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_status_t hal_dspi_abort(dspi_handle_t *p_dspi)
Abort the current transmission.