no-OS
Functions | Variables
spi_engine.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sleep.h>
#include <inttypes.h>
#include "axi_dmac.h"
#include "no_os_axi_io.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
#include "no_os_util.h"
#include "spi_engine.h"
Include dependency graph for spi_engine.c:

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_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...
 
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_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_remove (struct no_os_spi_desc *desc)
 Free the resources allocated by no_os_spi_init(). More...
 

Variables

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

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

◆ spi_eng_platform_ops

const struct no_os_spi_platform_ops spi_eng_platform_ops
Initial value:
= {
.init = &spi_engine_init,
.write_and_read = &spi_engine_write_and_read,
.remove = &spi_engine_remove
}

Spi engine platform specific SPI platform ops structure.

SPI engine platform ops structure.

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.
Definition: spi_engine.c:624
spi_engine_remove
int32_t spi_engine_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: spi_engine.c:895
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.
Definition: spi_engine.c:693