|
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) |
|
The public API for using the RTOS SPI master driver.
◆ 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.
◆ 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_ctx | A pointer to the SPI device instance to initialize. |
bus_ctx | A pointer to the SPI master driver instance to attach the device to. |
cs_pin | The bit number of the chip select port that is connected to the device's chip select pin. |
cpol | The clock polarity required by the device. |
cpha | The clock phase required by the device. |
source_clock | The source clock to derive SCLK from. See spi_master_source_clock_t. |
clock_divisor | The 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_delay | When to sample MISO. See spi_master_sample_delay_t. |
miso_pad_delay | The 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_ticks | The minimum number of reference clock ticks between assertion of chip select and the first clock edge. |
clk_to_cs_delay_ticks | The minimum number of reference clock ticks between the last clock edge and de-assertion of chip select. |
cs_to_cs_delay_ticks | The 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_ctx | A pointer to the SPI master driver instance to initialize. |
clock_block | The clock block to use for the SPI master interface. |
cs_port | The SPI interface's chip select port. This may be a multi-bit port. |
sclk_port | The SPI interface's SCLK port. Must be a 1-bit port. |
mosi_port | The SPI interface's MOSI port. Must be a 1-bit port. |
miso_port | The SPI interface's MISO port. Must be a 1-bit port. |
◆ rtos_spi_master_start()
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_ctx | A pointer to the SPI master driver instance to start. |
priority | The priority of the task that gets created by the driver to handle the SPI master interface. |