Skip to content

File syn_soft_spi.c

FileList > drivers > syn_soft_spi.c

Go to the source code of this file

  • #include "../util/syn_assert.h"
  • #include "syn_gpio.h"
  • #include "syn_soft_spi.h"

Public Functions

Type Name
void syn_soft_spi_deselect (SYN_SoftSPI * spi)
Deassert chip select (drive inactive).
void syn_soft_spi_init (SYN_SoftSPI * spi, SYN_GPIO_Pin sck, SYN_GPIO_Pin mosi, SYN_GPIO_Pin miso, SYN_SPIMode mode, uint32_t delay_loops)
Initialize the soft SPI pins.
void syn_soft_spi_select (SYN_SoftSPI * spi)
Assert chip select (drive active).
void syn_soft_spi_set_cs (SYN_SoftSPI * spi, SYN_GPIO_Pin cs_pin, bool active_low)
Set an optional chip select pin.
uint8_t syn_soft_spi_transfer (const SYN_SoftSPI * spi, uint8_t data)
Transfer a single byte (read and write simultaneously).
void syn_soft_spi_transfer_bulk (SYN_SoftSPI * spi, const uint8_t * tx, uint8_t * rx, size_t len)
Transfer multiple bytes.

Public Static Functions

Type Name
void spi_delay (const SYN_SoftSPI * spi)

Public Functions Documentation

function syn_soft_spi_deselect

Deassert chip select (drive inactive).

void syn_soft_spi_deselect (
    SYN_SoftSPI * spi
) 

Parameters:

  • spi Soft SPI instance.

function syn_soft_spi_init

Initialize the soft SPI pins.

void syn_soft_spi_init (
    SYN_SoftSPI * spi,
    SYN_GPIO_Pin sck,
    SYN_GPIO_Pin mosi,
    SYN_GPIO_Pin miso,
    SYN_SPIMode mode,
    uint32_t delay_loops
) 

Parameters:

  • spi Pointer to SPI instance.
  • sck SCK pin.
  • mosi MOSI pin.
  • miso MISO pin.
  • mode SPI Mode (0-3).
  • delay_loops Number of iterations for a half-clock delay.

function syn_soft_spi_select

Assert chip select (drive active).

void syn_soft_spi_select (
    SYN_SoftSPI * spi
) 

Parameters:

  • spi Soft SPI instance.

function syn_soft_spi_set_cs

Set an optional chip select pin.

void syn_soft_spi_set_cs (
    SYN_SoftSPI * spi,
    SYN_GPIO_Pin cs_pin,
    bool active_low
) 

When set, syn_soft_spi_select/deselect can be used to assert/deassert CS.

Parameters:

  • spi SPI instance.
  • cs_pin Chip select GPIO pin.
  • active_low true if CS is active-low (most common).

function syn_soft_spi_transfer

Transfer a single byte (read and write simultaneously).

uint8_t syn_soft_spi_transfer (
    const SYN_SoftSPI * spi,
    uint8_t data
) 

Parameters:

  • spi Pointer to SPI instance.
  • data Byte to write out on MOSI.

Returns:

Byte read in from MISO.


function syn_soft_spi_transfer_bulk

Transfer multiple bytes.

void syn_soft_spi_transfer_bulk (
    SYN_SoftSPI * spi,
    const uint8_t * tx,
    uint8_t * rx,
    size_t len
) 

Parameters:

  • spi Pointer to SPI instance.
  • tx Buffer to transmit (can be NULL if rx-only).
  • rx Buffer to receive into (can be NULL if tx-only).
  • len Number of bytes to transfer.

Public Static Functions Documentation

function spi_delay

static void spi_delay (
    const SYN_SoftSPI * spi
) 


The documentation for this class was generated from the following file src/syntropic/drivers/syn_soft_spi.c