gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
SPI Peripheral

The SPI peripheral is used for synchronous serial communication with other devices. More...

Enumerations

enum  spi_dopo_t { SPI_DOPO_0_SCK_1 = 0 , SPI_DOPO_2_SCK_3 , SPI_DOPO_3_SCK_1 , SPI_DOPO_0_SCK_3 }
 
enum  spi_dipo_t {
  SPI_DIPO_0 = 0 , SPI_DIPO_1 , SPI_DIPO_2 , SPI_DIPO_3 ,
  SPI_DIPO_NONE = 0xff
}
 

Functions

void spi_init (uint32_t baud)
 Initializes the SPI SERCOM as a controller for a board with a defined SPI_SERCOM.
 
void spi_enable (void)
 Enables the SPI SERCOM for a board with a defined SPI_SERCOM.
 
uint8_t spi_transfer (uint8_t data)
 Transfers a byte over SPI for a board with a defined SPI_SERCOM.
 
void spi_disable (void)
 Disables the SPI SERCOM for a board with a defined SPI_SERCOM.
 
void spi_init_instance (uint8_t sercom, spi_dopo_t dopo, spi_dipo_t dipo, uint32_t baud)
 Initializes a specific SERCOM instance as an SPI controller.
 
void spi_enable_instance (uint8_t sercom)
 Enables a specific SERCOM instance for SPI.
 
uint8_t spi_transfer_instance (uint8_t sercom, uint8_t data)
 Transfers a byte over SPI.
 
void spi_disable_instance (uint8_t sercom)
 Disables a specific SERCOM instance for SPI.
 

Detailed Description

The SPI peripheral is used for synchronous serial communication with other devices.

Gossamer's SPI implementation only supports SPI controller mode, not peripheral mode. Your DOPO pin in this case is COPI/MOSI, and your DIPO pin is CIPO/MISO.

Function Documentation

◆ spi_disable_instance()

void spi_disable_instance ( uint8_t  sercom)

Disables a specific SERCOM instance for SPI.

Parameters
sercomThe SERCOM instance to disable.

◆ spi_enable_instance()

void spi_enable_instance ( uint8_t  sercom)

Enables a specific SERCOM instance for SPI.

Parameters
sercomThe SERCOM instance to enable.

◆ spi_init()

void spi_init ( uint32_t  baud)

Initializes the SPI SERCOM as a controller for a board with a defined SPI_SERCOM.

Parameters
baudThe desired baud rate

◆ spi_init_instance()

void spi_init_instance ( uint8_t  sercom,
spi_dopo_t  dopo,
spi_dipo_t  dipo,
uint32_t  baud 
)

Initializes a specific SERCOM instance as an SPI controller.

Parameters
sercomThe SERCOM instance to initialize.
dopoThe data out pinout.
See also
spi_dopo_t
Parameters
dipoThe data in pinout.
See also
spi_dipo_t
Parameters
baudThe desired baud rate

◆ spi_transfer()

uint8_t spi_transfer ( uint8_t  data)

Transfers a byte over SPI for a board with a defined SPI_SERCOM.

Parameters
dataThe byte to send.
Returns
The byte received.

◆ spi_transfer_instance()

uint8_t spi_transfer_instance ( uint8_t  sercom,
uint8_t  data 
)

Transfers a byte over SPI.

Parameters
sercomThe SERCOM instance to use.
dataThe byte to send.
Returns
The byte received.

FIXME: Do we need to disable this check for a transmit-only SPI?