Classes | 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"`
Include dependency graph for gr55xx_hal_spi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
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
| Full Duplex: Transmit & Receive More...
#define | SPI_DIRECTION_SIMPLEX_TX LL_SSI_SIMPLEX_TX
| Simplex Tx: Transmit only More...
#define | SPI_DIRECTION_SIMPLEX_RX LL_SSI_SIMPLEX_RX
| Simplex Rx: Receive only More...
#define | SPI_DIRECTION_READ_EEPROM LL_SSI_READ_EEPROM
| Read EEPROM More...
#define | HAL_SPI_ERROR_NONE ((uint32_t)0x00000000)
| No error More...
#define | HAL_SPI_ERROR_TIMEOUT ((uint32_t)0x00000001)
| Timeout error More...
#define | HAL_SPI_ERROR_TRANSFER ((uint32_t)0x00000002)
| Transfer error More...
#define | HAL_SPI_ERROR_DMA ((uint32_t)0x00000004)
| DMA transfer error. More...
#define | HAL_SPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008)
| Invalid parameters error. More...
#define | SPI_DATASIZE_4BIT LL_SSI_DATASIZE_4BIT
| 4-bit serial data transfer More...
#define | SPI_DATASIZE_5BIT LL_SSI_DATASIZE_5BIT
| 5-bit serial data transfer More...
#define | SPI_DATASIZE_6BIT LL_SSI_DATASIZE_6BIT
| 6-bit serial data transfer More...
#define | SPI_DATASIZE_7BIT LL_SSI_DATASIZE_7BIT
| 7-bit serial data transfer More...
#define | SPI_DATASIZE_8BIT LL_SSI_DATASIZE_8BIT
| 8-bit serial data transfer More...
#define | SPI_DATASIZE_9BIT LL_SSI_DATASIZE_9BIT
| 9-bit serial data transfer More...
#define | SPI_DATASIZE_10BIT LL_SSI_DATASIZE_10BIT
| 10-bit serial data transfer More...
#define | SPI_DATASIZE_11BIT LL_SSI_DATASIZE_11BIT
| 11-bit serial data transfer More...
#define | SPI_DATASIZE_12BIT LL_SSI_DATASIZE_12BIT
| 12-bit serial data transfer More...
#define | SPI_DATASIZE_13BIT LL_SSI_DATASIZE_13BIT
| 13-bit serial data transfer More...
#define | SPI_DATASIZE_14BIT LL_SSI_DATASIZE_14BIT
| 14-bit serial data transfer More...
#define | SPI_DATASIZE_15BIT LL_SSI_DATASIZE_15BIT
| 15-bit serial data transfer More...
#define | SPI_DATASIZE_16BIT LL_SSI_DATASIZE_16BIT
| 16-bit serial data transfer More...
#define | SPI_DATASIZE_17BIT LL_SSI_DATASIZE_17BIT
| 17-bit serial data transfer More...
#define | SPI_DATASIZE_18BIT LL_SSI_DATASIZE_18BIT
| 18-bit serial data transfer More...
#define | SPI_DATASIZE_19BIT LL_SSI_DATASIZE_19BIT
| 19-bit serial data transfer More...
#define | SPI_DATASIZE_20BIT LL_SSI_DATASIZE_20BIT
| 20-bit serial data transfer More...
#define | SPI_DATASIZE_21BIT LL_SSI_DATASIZE_21BIT
| 21-bit serial data transfer More...
#define | SPI_DATASIZE_22BIT LL_SSI_DATASIZE_22BIT
| 22-bit serial data transfer More...
#define | SPI_DATASIZE_23BIT LL_SSI_DATASIZE_23BIT
| 23-bit serial data transfer More...
#define | SPI_DATASIZE_24BIT LL_SSI_DATASIZE_24BIT
| 24-bit serial data transfer More...
#define | SPI_DATASIZE_25BIT LL_SSI_DATASIZE_25BIT
| 25-bit serial data transfer More...
#define | SPI_DATASIZE_26BIT LL_SSI_DATASIZE_26BIT
| 26-bit serial data transfer More...
#define | SPI_DATASIZE_27BIT LL_SSI_DATASIZE_27BIT
| 27-bit serial data transfer More...
#define | SPI_DATASIZE_28BIT LL_SSI_DATASIZE_28BIT
| 28-bit serial data transfer More...
#define | SPI_DATASIZE_29BIT LL_SSI_DATASIZE_29BIT
| 29-bit serial data transfer More...
#define | SPI_DATASIZE_30BIT LL_SSI_DATASIZE_30BIT
| 30-bit serial data transfer More...
#define | SPI_DATASIZE_31BIT LL_SSI_DATASIZE_31BIT
| 31-bit serial data transfer More...
#define | SPI_DATASIZE_32BIT LL_SSI_DATASIZE_32BIT
| 32-bit serial data transfer More...
#define | SPI_POLARITY_LOW LL_SSI_SCPOL_LOW
| Inactive state of CLK is low More...
#define | SPI_POLARITY_HIGH LL_SSI_SCPOL_HIGH
| Inactive state of CLK is high. More...
#define | SPI_PHASE_1EDGE LL_SSI_SCPHA_1EDGE
| CLK toggles at start of first data bit More...
#define | SPI_PHASE_2EDGE LL_SSI_SCPHA_2EDGE
| CLK toggles in middle of first data bit. More...
#define | SPI_TIMODE_DISABLE ((uint32_t)0x00000000)
| SPI TI mode disable. More...
#define | SPI_TIMODE_ENABLE LL_SSI_PROTOCOL_TI
| SPI TI mode enable More...
#define | SPI_SLAVE_SELECT_0 LL_SSI_SLAVE0
| SPIM Select Slave 0 More...
#define | SPI_SLAVE_SELECT_1 LL_SSI_SLAVE1
| SPIM Select Slave 1 More...
#define | SPI_SLAVE_SELECT_ALL (LL_SSI_SLAVE0 | LL_SSI_SLAVE1)
| SPIM Select All Slave More...
#define | SPI_TX_FIFO_LEVEL_MAX 8
| SPI TX FIFO Level Max Value. More...
#define | SPI_RX_FIFO_LEVEL_MAX 8
| SPI RX FIFO Level Max Value. More...
#define | SPI_FLAG_DCOL LL_SSI_SR_DCOL
| Data collision error flag More...
#define | SPI_FLAG_TXE LL_SSI_SR_TXE
| Transmission error flag More...
#define | SPI_FLAG_RFF LL_SSI_SR_RFF
| Rx FIFO full flag More...
#define | SPI_FLAG_RFNE LL_SSI_SR_RFNE
| Rx FIFO not empty flag More...
#define | SPI_FLAG_TFE LL_SSI_SR_TFE
| Tx FIFO empty flag More...
#define | SPI_FLAG_TFNF LL_SSI_SR_TFNF
| Tx FIFO not full flag More...
#define | SPI_FLAG_BUSY LL_SSI_SR_BUSY
| Busy flag More...
#define | SPI_IT_MST LL_SSI_IS_MST
| Multi-Master Contention Interrupt flag More...
#define | SPI_IT_RXF LL_SSI_IS_RXF
| Receive FIFO Full Interrupt flag More...
#define | SPI_IT_RXO LL_SSI_IS_RXO
| Receive FIFO Overflow Interrupt flag More...
#define | SPI_IT_RXU LL_SSI_IS_RXU
| Receive FIFO Underflow Interrupt flag More...
#define | SPI_IT_TXO LL_SSI_IS_TXO
| Transmit FIFO Overflow Interrupt flag More...
#define | SPI_IT_TXE LL_SSI_IS_TXE
| Transmit FIFO Empty Interrupt flag More...
#define | HAL_SPI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
| 5s More...
#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. More...
typedef struct _spi_handle | spi_handle_t
| SPI handle Structure definition. More...
typedef struct _hal_spi_callback | hal_spi_callback_t
| HAL_SPI Callback function definition. More...

## 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. More...
hal_status_t | hal_spi_transmit_with_ia (spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout)
| Transmit an amount of data in non-blocking mode with polling. More...
hal_status_t | hal_spi_transmit_dma_with_ia (spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length)
| Transmit an amount of data in non-blocking mode with DMA. 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.

Definition in file gr55xx_hal_spi.h.