Data Structures | Macros | Typedefs | Enumerations | Functions
gr55xx_hal_spi.h File Reference

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

`#include "gr55xx_ll_spi.h"`
`#include "gr55xx_hal_def.h"`

Go to the source code of this file.

## Data Structures
struct | _spi_init
| SPI init Structure definition. More...
struct | _spi_handle
| SPI handle Structure definition. More...
struct | _hal_spi_callback
| HAL_SPI Callback function definition. More...

## Macros
#define | SPI_DIRECTION_FULL_DUPLEX LL_SSI_FULL_DUPLEX
#define | SPI_DIRECTION_SIMPLEX_TX LL_SSI_SIMPLEX_TX
#define | SPI_DIRECTION_SIMPLEX_RX LL_SSI_SIMPLEX_RX
#define | SPI_DIRECTION_READ_EEPROM LL_SSI_READ_EEPROM
#define | HAL_SPI_ERROR_NONE ((uint32_t)0x00000000)
#define | HAL_SPI_ERROR_TIMEOUT ((uint32_t)0x00000001)
#define | HAL_SPI_ERROR_TRANSFER ((uint32_t)0x00000002)
#define | HAL_SPI_ERROR_DMA ((uint32_t)0x00000004)
#define | HAL_SPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008)
#define | SPI_DATASIZE_4BIT LL_SSI_DATASIZE_4BIT
#define | SPI_DATASIZE_5BIT LL_SSI_DATASIZE_5BIT
#define | SPI_DATASIZE_6BIT LL_SSI_DATASIZE_6BIT
#define | SPI_DATASIZE_7BIT LL_SSI_DATASIZE_7BIT
#define | SPI_DATASIZE_8BIT LL_SSI_DATASIZE_8BIT
#define | SPI_DATASIZE_9BIT LL_SSI_DATASIZE_9BIT
#define | SPI_DATASIZE_10BIT LL_SSI_DATASIZE_10BIT
#define | SPI_DATASIZE_11BIT LL_SSI_DATASIZE_11BIT
#define | SPI_DATASIZE_12BIT LL_SSI_DATASIZE_12BIT
#define | SPI_DATASIZE_13BIT LL_SSI_DATASIZE_13BIT
#define | SPI_DATASIZE_14BIT LL_SSI_DATASIZE_14BIT
#define | SPI_DATASIZE_15BIT LL_SSI_DATASIZE_15BIT
#define | SPI_DATASIZE_16BIT LL_SSI_DATASIZE_16BIT
#define | SPI_DATASIZE_17BIT LL_SSI_DATASIZE_17BIT
#define | SPI_DATASIZE_18BIT LL_SSI_DATASIZE_18BIT
#define | SPI_DATASIZE_19BIT LL_SSI_DATASIZE_19BIT
#define | SPI_DATASIZE_20BIT LL_SSI_DATASIZE_20BIT
#define | SPI_DATASIZE_21BIT LL_SSI_DATASIZE_21BIT
#define | SPI_DATASIZE_22BIT LL_SSI_DATASIZE_22BIT
#define | SPI_DATASIZE_23BIT LL_SSI_DATASIZE_23BIT
#define | SPI_DATASIZE_24BIT LL_SSI_DATASIZE_24BIT
#define | SPI_DATASIZE_25BIT LL_SSI_DATASIZE_25BIT
#define | SPI_DATASIZE_26BIT LL_SSI_DATASIZE_26BIT
#define | SPI_DATASIZE_27BIT LL_SSI_DATASIZE_27BIT
#define | SPI_DATASIZE_28BIT LL_SSI_DATASIZE_28BIT
#define | SPI_DATASIZE_29BIT LL_SSI_DATASIZE_29BIT
#define | SPI_DATASIZE_30BIT LL_SSI_DATASIZE_30BIT
#define | SPI_DATASIZE_31BIT LL_SSI_DATASIZE_31BIT
#define | SPI_DATASIZE_32BIT LL_SSI_DATASIZE_32BIT
#define | SPI_POLARITY_LOW LL_SSI_SCPOL_LOW
#define | SPI_POLARITY_HIGH LL_SSI_SCPOL_HIGH
#define | SPI_PHASE_1EDGE LL_SSI_SCPHA_1EDGE
#define | SPI_PHASE_2EDGE LL_SSI_SCPHA_2EDGE
#define | SPI_TIMODE_DISABLE ((uint32_t)0x00000000)
#define | SPI_TIMODE_ENABLE LL_SSI_PROTOCOL_TI
#define | SPI_SLAVE_SELECT_0 LL_SSI_SLAVE0
#define | SPI_SLAVE_SELECT_1 LL_SSI_SLAVE1
#define | SPI_SLAVE_SELECT_ALL (LL_SSI_SLAVE0 | LL_SSI_SLAVE1)
#define | SPI_TX_FIFO_LEVEL_MAX 8
#define | SPI_RX_FIFO_LEVEL_MAX 8
#define | SPI_FLAG_DCOL LL_SSI_SR_DCOL
#define | SPI_FLAG_TXE LL_SSI_SR_TXE
#define | SPI_FLAG_RFF LL_SSI_SR_RFF
#define | SPI_FLAG_RFNE LL_SSI_SR_RFNE
#define | SPI_FLAG_TFE LL_SSI_SR_TFE
#define | SPI_FLAG_TFNF LL_SSI_SR_TFNF
#define | SPI_FLAG_BUSY LL_SSI_SR_BUSY
#define | SPI_IT_MST LL_SSI_IS_MST
#define | SPI_IT_RXF LL_SSI_IS_RXF
#define | SPI_IT_RXO LL_SSI_IS_RXO
#define | SPI_IT_RXU LL_SSI_IS_RXU
#define | SPI_IT_TXO LL_SSI_IS_TXO
#define | SPI_IT_TXE LL_SSI_IS_TXE
#define | HAL_SPI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
#define | __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_SPI_STATE_RESET)
| Reset SPI handle states. More...
#define | __HAL_SPI_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->SSI_EN, SSI_SSIEN_EN)
| Enable the specified SPI peripheral. More...
#define | __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->SSI_EN, SSI_SSIEN_EN)
| Disable the specified SPI peripheral. More...
#define | __HAL_SPI_ENABLE_DMATX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_TDMAE)
| Enable the SPI DMA TX Request. More...
#define | __HAL_SPI_ENABLE_DMARX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_RDMAE)
| Enable the SPI DMA RX Request. More...
#define | __HAL_SPI_DISABLE_DMATX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_TDMAE)
| Disable the SPI DMA TX Request. More...
#define | __HAL_SPI_DISABLE_DMARX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_RDMAE)
| Disable the SPI DMA RX Request. More...
#define | __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INTMASK, (__INTERRUPT__))
| Enable the specified SPI interrupts. More...
#define | __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INTMASK, (__INTERRUPT__))
| Disable the specified SPI interrupts. More...
#define | __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BITS((__HANDLE__)->p_instance->INTSTAT, (__INTERRUPT__)) == (__INTERRUPT__))
| Check whether the specified SPI interrupt source is enabled or not. More...
#define | __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
| Check whether the specified SPI flag is set or not. More...
#define | __HAL_SPI_CLEAR_FLAG(__HANDLE__, __FLAG__) READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__))
| Clear the specified SPI flag. More...
#define | IS_SPI_DIRECTION(__MODE__)
| Check if SPI Direction Mode is valid. More...
#define | IS_SPI_DATASIZE(__DATASIZE__)
| Check if SPI Data Size is valid. More...
#define | IS_SPI_CPOL(__CPOL__)
| Check if SPI Clock Polarity is valid. More...
#define | IS_SPI_CPHA(__CPHA__)
| Check if SPI Clock Phase is valid. More...
#define | IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) ((__PRESCALER__) <= 0xFFFF)
| Check if SPI BaudRate Prescaler is valid. More...
#define | IS_SPI_TIMODE(__MODE__)
| Check if SPI TI Mode is valid. More...
#define | IS_SPI_SLAVE(__SLAVE__)
| Check if SPI Slave Select is valid. More...
#define | IS_SPI_RX_SAMPLE_DLY(__DLY__) (((__DLY__) >= 0) && ((__DLY__) <= 7))
| Check if SPI Receive Sample Delay Value is valid. More...
#define | IS_SPI_FIFO_THRESHOLD(__THR__) (((__THR__) >= 0) && ((__THR__) <= 7))
| Check if SPI FIFO Threshold is valid. More...

## Typedefs
typedef struct _spi_init | spi_init_t
| SPI init Structure definition.
typedef struct _spi_handle | spi_handle_t
| SPI handle Structure definition.
typedef struct _hal_spi_callback | hal_spi_callback_t
| HAL_SPI Callback function definition.

## Enumerations
enum | hal_spi_state_t { HAL_SPI_STATE_RESET = 0x00, HAL_SPI_STATE_READY = 0x01, HAL_SPI_STATE_BUSY = 0x02, HAL_SPI_STATE_BUSY_TX = 0x12, HAL_SPI_STATE_BUSY_RX = 0x22, HAL_SPI_STATE_BUSY_TX_RX = 0x32, HAL_SPI_STATE_ABORT = 0x08, HAL_SPI_STATE_ERROR = 0x04 }
| HAL SPI State Enumerations definition. More...

## Functions
hal_status_t | hal_spi_init (spi_handle_t *p_spi)
| Initialize the SPI according to the specified parameters in the spi_init_t and initialize the associated handle. More...
hal_status_t | hal_spi_deinit (spi_handle_t *p_spi)
| De-initialize the SPI peripheral. More...
void | hal_spi_msp_init (spi_handle_t *p_spi)
| Initialize the SPI MSP. More...
void | hal_spi_msp_deinit (spi_handle_t *p_spi)
| De-initialize the SPI MSP. More...
hal_status_t | hal_spi_transmit (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout)
| Transmit an amount of data in blocking mode. More...
hal_status_t | hal_spi_receive (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout)
| Receive an amount of data in blocking mode. More...
hal_status_t | hal_spi_transmit_receive (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length, uint32_t timeout)
| Transmit and Receive an amount of data in blocking mode. More...
hal_status_t | hal_spi_read_eeprom (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data, uint32_t timeout)
| Read an amount of data from EEPROM in blocking mode. More...
hal_status_t | hal_spi_transmit_it (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
| Transmit an amount of data in non-blocking mode with Interrupt. More...
hal_status_t | hal_spi_receive_it (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
| Receive an amount of data in non-blocking mode with Interrupt. More...
hal_status_t | hal_spi_transmit_receive_it (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length)
| Transmit and Receive an amount of data in non-blocking mode with Interrupt. More...
hal_status_t | hal_spi_read_eeprom_it (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data)
| Read an amount of data from EEPROM in non-blocking mode with Interrupt. More...
hal_status_t | hal_spi_transmit_dma (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
| Transmit an amount of data in non-blocking mode with DMA. More...
hal_status_t | hal_spi_receive_dma (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
| Receive an amount of data in non-blocking mode with DMA. More...
hal_status_t | hal_spi_transmit_receive_dma (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length)
| Transmit and Receive an amount of data in non-blocking mode with DMA. More...
hal_status_t | hal_spi_read_eeprom_dma (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data)
| Read an amount of data from EEPROM in non-blocking mode with DMA. More...
hal_status_t | hal_spi_abort (spi_handle_t *p_spi)
| Abort ongoing transfer (blocking mode). More...
hal_status_t | hal_spi_abort_it (spi_handle_t *p_spi)
| Abort ongoing transfer (Interrupt mode). More...
void | hal_spi_irq_handler (spi_handle_t *p_spi)
| Handle SPI interrupt request. More...
void | hal_spi_tx_cplt_callback (spi_handle_t *p_spi)
| Tx Transfer completed callback. More...
void | hal_spi_rx_cplt_callback (spi_handle_t *p_spi)
| Rx Transfer completed callback. More...
void | hal_spi_tx_rx_cplt_callback (spi_handle_t *p_spi)
| Tx and Rx Transfer completed callback. More...
void | hal_spi_error_callback (spi_handle_t *p_spi)
| SPI error callback. More...
void | hal_spi_abort_cplt_callback (spi_handle_t *p_spi)
| SPI Abort Completed callback. More...
hal_spi_state_t | hal_spi_get_state (spi_handle_t *p_spi)
| Return the SPI handle state. More...
uint32_t | hal_spi_get_error (spi_handle_t *p_spi)
| Return the SPI error code. More...
void | hal_spi_set_timeout (spi_handle_t *p_spi, uint32_t timeout)
| Set the SPI internal process timeout value. More...
hal_status_t | hal_spi_set_tx_fifo_threshold (spi_handle_t *p_spi, uint32_t threshold)
| Set the TX FIFO threshold. More...
hal_status_t | hal_spi_set_rx_fifo_threshold (spi_handle_t *p_spi, uint32_t threshold)
| Set the RX FIFO threshold. More...
uint32_t | hal_spi_get_tx_fifo_threshold (spi_handle_t *p_spi)
| Get the TX FIFO threshold. More...
uint32_t | hal_spi_get_rx_fifo_threshold (spi_handle_t *p_spi)
| Get the RX FIFO threshold. More...
hal_status_t | hal_spi_suspend_reg (spi_handle_t *p_spi)
| Suspend some registers related to SPI configuration before sleep. More...
hal_status_t | hal_spi_resume_reg (spi_handle_t *p_spi)
| Restore some registers related to SPI configuration after sleep. This function must be used in conjunction with the hal_spi_suspend_reg(). More...

## Detailed Description

Header file containing functions prototypes of SPI 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.