XCORE SDK
XCORE Software Development Kit
Modules | Classes | Typedefs | Functions
rtos_spi_master_driver

Modules

 rtos_spi_master_driver_core
 
 rtos_spi_master_driver_rpc
 

Classes

struct  rtos_spi_master_struct
 
struct  rtos_spi_master_device_struct
 

Typedefs

typedef struct rtos_spi_master_struct rtos_spi_master_t
 
typedef struct rtos_spi_master_device_struct rtos_spi_master_device_t
 

Functions

void rtos_spi_master_start (rtos_spi_master_t *spi_master_ctx, unsigned priority)
 
void rtos_spi_master_init (rtos_spi_master_t *bus_ctx, xclock_t clock_block, port_t cs_port, port_t sclk_port, port_t mosi_port, port_t miso_port)
 
void rtos_spi_master_device_init (rtos_spi_master_device_t *dev_ctx, rtos_spi_master_t *bus_ctx, uint32_t cs_pin, int cpol, int cpha, spi_master_source_clock_t source_clock, uint32_t clock_divisor, spi_master_sample_delay_t miso_sample_delay, uint32_t miso_pad_delay, uint32_t cs_to_clk_delay_ticks, uint32_t clk_to_cs_delay_ticks, uint32_t cs_to_cs_delay_ticks)
 

Detailed Description

The public API for using the RTOS SPI master driver.

Typedef Documentation

◆ rtos_spi_master_device_t

Typedef to the RTOS SPI device instance struct.

◆ rtos_spi_master_t

Typedef to the RTOS SPI master driver instance struct.

Function Documentation

◆ rtos_spi_master_device_init()

void rtos_spi_master_device_init ( rtos_spi_master_device_t dev_ctx,
rtos_spi_master_t bus_ctx,
uint32_t  cs_pin,
int  cpol,
int  cpha,
spi_master_source_clock_t  source_clock,
uint32_t  clock_divisor,
spi_master_sample_delay_t  miso_sample_delay,
uint32_t  miso_pad_delay,
uint32_t  cs_to_clk_delay_ticks,
uint32_t  clk_to_cs_delay_ticks,
uint32_t  cs_to_cs_delay_ticks 
)

Initialize a SPI device. Multiple SPI devices may be initialized per RTOS SPI master driver instance. Each must be on a unique pin of the interface's chip select port. This must only be called by the tile that owns the driver instance. It may be called either before or after starting the RTOS, but must be called before calling rtos_spi_master_start() or any of the core SPI master driver functions with this instance.

Parameters
dev_ctxA pointer to the SPI device instance to initialize.
bus_ctxA pointer to the SPI master driver instance to attach the device to.
cs_pinThe bit number of the chip select port that is connected to the device's chip select pin.
cpolThe clock polarity required by the device.
cphaThe clock phase required by the device.
source_clockThe source clock to derive SCLK from. See spi_master_source_clock_t.
clock_divisorThe value to divide the source clock by. The frequency of SCLK will be set to:
  • (F_src) / (4 * clock_divisor) when clock_divisor > 0
  • (F_src) / (2) when clock_divisor = 0 Where F_src is the frequency of the source clock.
miso_sample_delayWhen to sample MISO. See spi_master_sample_delay_t.
miso_pad_delayThe number of core clock cycles to delay sampling the MISO pad during a transaction. This allows for more fine grained adjustment of sampling time. The value may be between 0 and 5.
cs_to_clk_delay_ticksThe minimum number of reference clock ticks between assertion of chip select and the first clock edge.
clk_to_cs_delay_ticksThe minimum number of reference clock ticks between the last clock edge and de-assertion of chip select.
cs_to_cs_delay_ticksThe minimum number of reference clock ticks between transactions, which is between de-assertion of chip select and the end of one transaction, and its re-assertion at the beginning of the next.

◆ rtos_spi_master_init()

void rtos_spi_master_init ( rtos_spi_master_t bus_ctx,
xclock_t  clock_block,
port_t  cs_port,
port_t  sclk_port,
port_t  mosi_port,
port_t  miso_port 
)

Initializes an RTOS SPI master driver instance. This must only be called by the tile that owns the driver instance. It may be called either before or after starting the RTOS, but must be called before calling rtos_spi_master_start() or any of the core SPI master driver functions with this instance.

Parameters
bus_ctxA pointer to the SPI master driver instance to initialize.
clock_blockThe clock block to use for the SPI master interface.
cs_portThe SPI interface's chip select port. This may be a multi-bit port.
sclk_portThe SPI interface's SCLK port. Must be a 1-bit port.
mosi_portThe SPI interface's MOSI port. Must be a 1-bit port.
miso_portThe SPI interface's MISO port. Must be a 1-bit port.

◆ rtos_spi_master_start()

void rtos_spi_master_start ( rtos_spi_master_t spi_master_ctx,
unsigned  priority 
)

Starts an RTOS SPI master driver instance. This must only be called by the tile that owns the driver instance. It may be called either before or after starting the RTOS, but must be called before any of the core SPI master driver functions are called with this instance.

rtos_spi_master_init() must be called on this SPI master driver instance prior to calling this.

Parameters
spi_master_ctxA pointer to the SPI master driver instance to start.
priorityThe priority of the task that gets created by the driver to handle the SPI master interface.