gr55xx_hal_dspi.h File Reference

Header file containing functions prototypes of DSPI HAL library. More...

#include "gr55xx_ll_dspi.h"
#include "gr55xx_hal_def.h"
#include "gr55xx_hal_pwr_mgmt.h"

Go to the source code of this file.

Classes

struct  _dspi_init_t
 QSPI init Structure definition. More...
 
struct  _dspi_handle
 DSPI handle Structure definition. More...
 
struct  _dspi_command_t
 DSPI command Structure definition. More...
 
struct  _hal_dspi_callback
 HAL_DSPI Callback function definition. More...
 

Macros

#define HAL_DSPI_ERROR_NONE   ((uint32_t)0x00000000)
 
#define HAL_DSPI_ERROR_TIMEOUT   ((uint32_t)0x00000001)
 
#define HAL_DSPI_ERROR_TRANSFER   ((uint32_t)0x00000002)
 
#define HAL_DSPI_ERROR_DMA   ((uint32_t)0x00000004)
 
#define HAL_DSPI_ERROR_INVALID_PARAM   ((uint32_t)0x00000008)
 
#define DSPI_BAUD_RATE_2P1PCLK   LL_DSPI_BAUD_RATE_2P1PCLK
 
#define DSPI_BAUD_RATE_4P1PCLK   LL_DSPI_BAUD_RATE_4P1PCLK
 
#define DSPI_BAUD_RATE_8P1PCLK   LL_DSPI_BAUD_RATE_8P1PCLK
 
#define DSPI_BAUD_RATE_16P1PCLK   LL_DSPI_BAUD_RATE_16P1PCLK
 
#define DSPI_BAUD_RATE_32P1PCLK   LL_DSPI_BAUD_RATE_32P1PCLK
 
#define DSPI_BAUD_RATE_64P1PCLK   LL_DSPI_BAUD_RATE_64P1PCLK
 
#define DSPI_BAUD_RATE_128P1PCLK   LL_DSPI_BAUD_RATE_128P1PCLK
 
#define DSPI_BAUD_RATE_256P1PCLK   LL_DSPI_BAUD_RATE_256PCLK
 
#define DSPI_PROT_MODE_3W1L   LL_DSPI_PROT_MODE_3W1L
 
#define DSPI_PROT_MODE_4W1L   LL_DSPI_PROT_MODE_4W1L
 
#define DSPI_PROT_MODE_4W2L   LL_DSPI_PROT_MODE_4W2L
 
#define DSPI_INSTSIZE_08_BITS   ((uint32_t)0x01)
 
#define DSPI_INSTSIZE_16_BITS   ((uint32_t)0x02)
 
#define DSPI_INSTSIZE_32_BITS   ((uint32_t)0x03)
 
#define DSPI_DATASIZE_04_BITS   LL_DSPI_DATASIZE_4BIT
 
#define DSPI_DATASIZE_05_BITS   LL_DSPI_DATASIZE_5BIT
 
#define DSPI_DATASIZE_06_BITS   LL_DSPI_DATASIZE_6BIT
 
#define DSPI_DATASIZE_07_BITS   LL_DSPI_DATASIZE_7BIT
 
#define DSPI_DATASIZE_08_BITS   LL_DSPI_DATASIZE_8BIT
 
#define DSPI_DATASIZE_09_BITS   LL_DSPI_DATASIZE_9BIT
 
#define DSPI_DATASIZE_10_BITS   LL_DSPI_DATASIZE_10BIT
 
#define DSPI_DATASIZE_11_BITS   LL_DSPI_DATASIZE_11BIT
 
#define DSPI_DATASIZE_12_BITS   LL_DSPI_DATASIZE_12BIT
 
#define DSPI_DATASIZE_13_BITS   LL_DSPI_DATASIZE_13BIT
 
#define DSPI_DATASIZE_14_BITS   LL_DSPI_DATASIZE_14BIT
 
#define DSPI_DATASIZE_15_BITS   LL_DSPI_DATASIZE_15BIT
 
#define DSPI_DATASIZE_16_BITS   LL_DSPI_DATASIZE_16BIT
 
#define DSPI_DATASIZE_17_BITS   LL_DSPI_DATASIZE_17BIT
 
#define DSPI_DATASIZE_18_BITS   LL_DSPI_DATASIZE_18BIT
 
#define DSPI_DATASIZE_19_BITS   LL_DSPI_DATASIZE_19BIT
 
#define DSPI_DATASIZE_20_BITS   LL_DSPI_DATASIZE_20BIT
 
#define DSPI_DATASIZE_21_BITS   LL_DSPI_DATASIZE_21BIT
 
#define DSPI_DATASIZE_22_BITS   LL_DSPI_DATASIZE_22BIT
 
#define DSPI_DATASIZE_23_BITS   LL_DSPI_DATASIZE_23BIT
 
#define DSPI_DATASIZE_24_BITS   LL_DSPI_DATASIZE_24BIT
 
#define DSPI_DATASIZE_25_BITS   LL_DSPI_DATASIZE_25BIT
 
#define DSPI_DATASIZE_26_BITS   LL_DSPI_DATASIZE_26BIT
 
#define DSPI_DATASIZE_27_BITS   LL_DSPI_DATASIZE_27BIT
 
#define DSPI_DATASIZE_28_BITS   LL_DSPI_DATASIZE_28BIT
 
#define DSPI_DATASIZE_29_BITS   LL_DSPI_DATASIZE_29BIT
 
#define DSPI_DATASIZE_30_BITS   LL_DSPI_DATASIZE_30BIT
 
#define DSPI_DATASIZE_31_BITS   LL_DSPI_DATASIZE_31BIT
 
#define DSPI_DATASIZE_32_BITS   LL_DSPI_DATASIZE_32BIT
 
#define DSPI_FLAG_FFE   LL_DSPI_SR_FFE
 
#define DSPI_FLAG_OVR   LL_DSPI_SR_OVR
 
#define DSPI_FLAG_MODE   LL_DSPI_SR_MODF
 
#define DSPI_FLAG_RFNE   LL_DSPI_SR_RFNE
 
#define DSPI_FLAG_TFE   LL_DSPI_SR_TFE
 
#define DSPI_FLAG_BUSY   LL_DSPI_SR_BUSY
 
#define DSPI_IT_RXNE   LL_DSPI_IM_RXNE
 
#define DSPI_IT_ERR   LL_DSPI_IM_ER
 
#define DSPI_IT_TXE   LL_DSPI_IM_TXE
 
#define DSPI_RX_FIFO_TH_1P2   LL_DSPI_FRXTH_1P2
 
#define DSPI_RX_FIFO_TH_1P4   LL_DSPI_FRXTH_1P4
 
#define DSPI_RX_FIFO_TH_1P8   LL_DSPI_FRXTH_1P8
 
#define DSPI_RX_FIFO_TH_1P16   LL_DSPI_FRXTH_1P16
 
#define DSPI_TRANSPORT_DATA   LL_DSPI_DCX_DATA
 
#define DSPI_TRANSPORT_CMD   LL_DSPI_DCX_CMD
 
#define HAL_DSPI_TIMEOUT_DEFAULT_VALUE   ((uint32_t)5000)
 
#define __HAL_DSPI_RESET_HANDLE_STATE(__HANDLE__)   ((__HANDLE__)->state = HAL_DSPI_STATE_RESET)
 Reset DSPI handle states. More...
 
#define __HAL_DSPI_ENABLE(__HANDLE__)   SET_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
 Enable the specified DSPI peripheral. More...
 
#define __HAL_DSPI_DISABLE(__HANDLE__)   CLEAR_BITS((__HANDLE__)->p_instance->CTRL1, DSPI_CR1_EN)
 Disable the specified DSPI peripheral. More...
 
#define __HAL_DSPI_ENABLE_DMATX(__HANDLE__)   SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
 Enable the DSPI DMA TX Request. More...
 
#define __HAL_DSPI_ENABLE_DMARX(__HANDLE__)   SET_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
 Enable the DSPI DMA RX Request. More...
 
#define __HAL_DSPI_DISABLE_DMATX(__HANDLE__)   CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_TXDMAEN)
 Disable the DSPI DMA TX Request. More...
 
#define __HAL_DSPI_DISABLE_DMARX(__HANDLE__)   CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, DSPI_CR2_RXDMAEN)
 Disable the DSPI DMA RX Request. More...
 
#define __HAL_DSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__)   SET_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
 Enable the specified DSPI interrupts. More...
 
#define __HAL_DSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__)   CLEAR_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__))
 Disable the specified DSPI interrupts. More...
 
#define __HAL_DSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)   (READ_BITS((__HANDLE__)->p_instance->CTRL2, (__INTERRUPT__)) == (__INTERRUPT__))
 Check whether the specified DSPI interrupt source is enabled or not. More...
 
#define __HAL_DSPI_GET_FLAG(__HANDLE__, __FLAG__)   ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
 Check whether the specified DSPI flag is set or not. More...
 
#define __HAL_DSPI_FLUSH_FIFO(__HANDLE__)   ll_dspi_flush_fifo((__HANDLE__)->p_instance)
 Flush the DSPI receiver FIFO. More...
 
#define __HAL_DSPI_TRANSPORT_TYPE(__HANDLE__, __TYPE__)   ll_dspi_set_dcx((__HANDLE__)->p_instance, (__TYPE__))
 Set the DSPI data transport type. More...
 
#define IS_DSPI_CLOCK_PRESCALER(__PRESCALER__)
 Check if DSPI Clock Prescaler is valid. More...
 
#define IS_DSPI_INTERFACE_MODE(__INTERFACEMODE__)
 Check if DSPI Interface Mode is valid. More...
 
#define IS_DSPI_INSTRUCTION_SIZE(__INST_SIZE__)
 Check if DSPI Instruction Size is valid. More...
 

Typedefs

typedef struct _dspi_init_t dspi_init_t
 QSPI init Structure definition. More...
 
typedef struct _dspi_handle dspi_handle_t
 DSPI handle Structure definition. More...
 
typedef struct _dspi_command_t dspi_command_t
 DSPI command Structure definition. More...
 
typedef struct _hal_dspi_callback hal_dspi_callback_t
 HAL_DSPI Callback function definition. More...
 

Enumerations

enum  hal_dspi_state_t {
  HAL_DSPI_STATE_RESET = 0x00,
  HAL_DSPI_STATE_READY = 0x01,
  HAL_DSPI_STATE_BUSY = 0x02,
  HAL_DSPI_STATE_BUSY_INDIRECT_TX = 0x12,
  HAL_DSPI_STATE_ABORT = 0x08,
  HAL_DSPI_STATE_ERROR = 0x04
}
 HAL DSPI State Enumerations definition. More...
 

Functions

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 associated handle. More...
 
hal_status_t hal_dspi_deinit (dspi_handle_t *p_dspi)
 De-initialize the DSPI peripheral. More...
 
void hal_dspi_msp_init (dspi_handle_t *p_dspi)
 Initialize the DSPI MSP. More...
 
void hal_dspi_msp_deinit (dspi_handle_t *p_dspi)
 De-initialize the DSPI MSP. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 . More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
hal_status_t hal_dspi_abort (dspi_handle_t *p_dspi)
 Abort the current transmission. More...
 
hal_status_t hal_dspi_abort_it (dspi_handle_t *p_dspi)
 Abort the current transmission (non-blocking function) More...
 
void hal_dspi_irq_handler (dspi_handle_t *p_dspi)
 Handle DSPI interrupt request. More...
 
void hal_dspi_tx_cplt_callback (dspi_handle_t *p_dspi)
 Tx Transfer completed callback. More...
 
void hal_dspi_error_callback (dspi_handle_t *p_dspi)
 DSPI error callback. More...
 
void hal_dspi_abort_callback (dspi_handle_t *p_dspi)
 DSPI Abort callback. More...
 
hal_dspi_state_t hal_dspi_get_state (dspi_handle_t *p_dspi)
 Return the DSPI handle state. More...
 
uint32_t hal_dspi_get_error (dspi_handle_t *p_dspi)
 Return the DSPI error code. More...
 
void hal_dspi_set_timeout (dspi_handle_t *p_dspi, uint32_t timeout)
 Set the DSPI internal process timeout value. More...
 
hal_status_t hal_dspi_config_mode (dspi_handle_t *p_dspi, uint32_t mode)
 Set the DSPI transmission mode. More...
 
hal_status_t hal_dspi_suspend_reg (dspi_handle_t *p_dspi)
 Suspend some registers related to DSPI configuration before sleep. More...
 
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 conjunction with the hal_dspi_suspend_reg(). More...
 

Detailed Description

Header file containing functions prototypes of DSPI HAL library.

Author
BLE Driver Team
Attention
#####Copyright (c) 2019 GOODIX All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of GOODIX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file gr55xx_hal_dspi.h.