no-OS
Classes | Macros | Functions | Variables
spi_engine.h File Reference
#include <stdint.h>
#include "xilinx_spi.h"
#include "spi_engine_private.h"
#include "axi_dmac.h"
Include dependency graph for spi_engine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  spi_engine_init_param
 Structure containing the init parameters needed by the SPI engine. More...
 
struct  spi_engine_desc
 Structure representing an SPI engine device. More...
 
struct  spi_engine_offload_init_param
 Structure containing the init parameters needed by the offload module. More...
 
struct  spi_engine_offload_message
 Structure representing an offload message. More...
 

Macros

#define OFFLOAD_DISABLED   0x00
 
#define OFFLOAD_TX_EN   NO_OS_BIT(0)
 
#define OFFLOAD_RX_EN   NO_OS_BIT(1)
 
#define OFFLOAD_TX_RX_EN   OFFLOAD_TX_EN | OFFLOAD_RX_EN
 
#define SPI_ENGINE_MSG_QUEUE_END   0xFFFFFFFF
 
#define WRITE(no_bytes)
 
#define READ(no_bytes)
 
#define WRITE_READ(no_bytes)
 
#define SLEEP(time)   SPI_ENGINE_CMD_SLEEP(time & 0xF)
 
#define CS_HIGH   SPI_ENGINE_CMD_ASSERT(0x03, 0xFF)
 
#define CS_LOW   SPI_ENGINE_CMD_ASSERT(0x03, 0x00)
 

Functions

int32_t spi_engine_write (struct spi_engine_desc *desc, uint32_t reg_addr, uint32_t reg_data)
 Write SPI Engine's axi registers. More...
 
int32_t spi_engine_read (struct spi_engine_desc *desc, uint32_t reg_addr, uint32_t *reg_data)
 Read SPI Engine's axi registers. More...
 
int32_t spi_engine_init (struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
 Initialize the spi engine. More...
 
int32_t spi_engine_write_and_read (struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
 Write/read on the spi interface. More...
 
int32_t spi_engine_remove (struct no_os_spi_desc *desc)
 Free the resources allocated by no_os_spi_init(). More...
 
int32_t spi_engine_offload_init (struct no_os_spi_desc *desc, const struct spi_engine_offload_init_param *param)
 Initialize the SPI engine's offload module. More...
 
int32_t spi_engine_offload_transfer (struct no_os_spi_desc *desc, struct spi_engine_offload_message msg, uint32_t no_samples)
 Initiate a SPI transfer in offload mode. More...
 
int32_t spi_engine_set_transfer_width (struct no_os_spi_desc *desc, uint8_t data_wdith)
 Set width of the transfered word over SPI. More...
 
void spi_engine_set_speed (struct no_os_spi_desc *desc, uint32_t speed_hz)
 Set SPI engine clock frequency. More...
 

Variables

const struct no_os_spi_platform_ops xil_spi_ops
 Spi engine platform specific SPI platform ops structure. More...
 

Macro Definition Documentation

◆ CS_HIGH

#define CS_HIGH   SPI_ENGINE_CMD_ASSERT(0x03, 0xFF)

◆ CS_LOW

#define CS_LOW   SPI_ENGINE_CMD_ASSERT(0x03, 0x00)

◆ OFFLOAD_DISABLED

#define OFFLOAD_DISABLED   0x00

◆ OFFLOAD_RX_EN

#define OFFLOAD_RX_EN   NO_OS_BIT(1)

◆ OFFLOAD_TX_EN

#define OFFLOAD_TX_EN   NO_OS_BIT(0)

◆ OFFLOAD_TX_RX_EN

#define OFFLOAD_TX_RX_EN   OFFLOAD_TX_EN | OFFLOAD_RX_EN

◆ READ

#define READ (   no_bytes)
Value:

◆ SLEEP

#define SLEEP (   time)    SPI_ENGINE_CMD_SLEEP(time & 0xF)

◆ SPI_ENGINE_MSG_QUEUE_END

#define SPI_ENGINE_MSG_QUEUE_END   0xFFFFFFFF

◆ WRITE

#define WRITE (   no_bytes)
Value:

◆ WRITE_READ

#define WRITE_READ (   no_bytes)
Value:

Function Documentation

◆ spi_engine_init()

int32_t spi_engine_init ( struct no_os_spi_desc **  desc,
const struct no_os_spi_init_param param 
)

Initialize the spi engine.

Parameters
descDecriptor containing SPI interface parameters
paramStructure containing the spi init parameters
Returns
int32_t - 0 if the transfer finished
  • -1 if the memory allocation failed
Here is the caller graph for this function:

◆ spi_engine_offload_init()

int32_t spi_engine_offload_init ( struct no_os_spi_desc desc,
const struct spi_engine_offload_init_param param 
)

Initialize the SPI engine's offload module.

Parameters
descDecriptor containing SPI interface parameters
paramStructure containing the offload init parameters
Returns
int32_t This function allways returns 0
Here is the caller graph for this function:

◆ spi_engine_offload_transfer()

int32_t spi_engine_offload_transfer ( struct no_os_spi_desc desc,
struct spi_engine_offload_message  msg,
uint32_t  no_samples 
)

Initiate a SPI transfer in offload mode.

Parameters
descDecriptor containing SPI interface parameters
msgOffload message that get's to be transferred
no_samplesNumber of time the messages will be transferred
Returns
int32_t This function allways returns 0
Here is the caller graph for this function:

◆ spi_engine_read()

int32_t spi_engine_read ( struct spi_engine_desc desc,
uint32_t  reg_addr,
uint32_t *  reg_data 
)

Read SPI Engine's axi registers.

Parameters
descDecriptor containing SPI Engine's parameters
reg_addrThe address of the SPI Engine's axi register from where the data where the data will be read
reg_dataPointer where the read that will be stored
Returns
int32_t This function allways returns 0
Here is the caller graph for this function:

◆ spi_engine_remove()

int32_t spi_engine_remove ( struct no_os_spi_desc desc)

Free the resources allocated by no_os_spi_init().

Parameters
descDecriptor containing SPI interface parameters
Returns
int32_t This function allways returns 0

◆ spi_engine_set_speed()

void spi_engine_set_speed ( struct no_os_spi_desc desc,
uint32_t  speed_hz 
)

Set SPI engine clock frequency.

Parameters
descDecriptor containing SPI Engine's parameters
speed_hzSPI engine transfer speed
Here is the caller graph for this function:

◆ spi_engine_set_transfer_width()

int32_t spi_engine_set_transfer_width ( struct no_os_spi_desc desc,
uint8_t  data_wdith 
)

Set width of the transfered word over SPI.

Parameters
descDecriptor containing SPI interface parameters
data_wdithThe desired data width The supported values are:
  • 8
  • 16
  • 24
  • 32
Here is the caller graph for this function:

◆ spi_engine_write()

int32_t spi_engine_write ( struct spi_engine_desc desc,
uint32_t  reg_addr,
uint32_t  reg_data 
)

Write SPI Engine's axi registers.

Parameters
descDecriptor containing SPI Engine's parameters
reg_addrThe address of the SPI Engine's axi register where the data will be written
reg_dataData that will be written
Returns
int32_t This function allways returns 0
Here is the caller graph for this function:

◆ spi_engine_write_and_read()

int32_t spi_engine_write_and_read ( struct no_os_spi_desc desc,
uint8_t *  data,
uint16_t  bytes_number 
)

Write/read on the spi interface.

Parameters
descDecriptor containing SPI interface parameters
dataPointer to data buffer
bytes_numberNumber of bytes to transfer
Returns
int32_t - 0 if the transfer finished
  • -1 if the memory allocation or transfer failed

Variable Documentation

◆ xil_spi_ops

const struct no_os_spi_platform_ops xil_spi_ops

Spi engine platform specific SPI platform ops structure.

Spi engine platform specific SPI platform ops structure.

SPI_ENGINE_INSTRUCTION_TRANSFER_RW
#define SPI_ENGINE_INSTRUCTION_TRANSFER_RW
Definition: spi_engine_private.h:103
SPI_ENGINE_INSTRUCTION_TRANSFER_W
#define SPI_ENGINE_INSTRUCTION_TRANSFER_W
Definition: spi_engine_private.h:101
SPI_ENGINE_INSTRUCTION_TRANSFER_R
#define SPI_ENGINE_INSTRUCTION_TRANSFER_R
Definition: spi_engine_private.h:102
SPI_ENGINE_INST_TRANSFER
#define SPI_ENGINE_INST_TRANSFER
Definition: spi_engine_private.h:72