SAM Serial Peripheral Interface Driver.
Copyright (c) 2012-2020 Microchip Technology Inc. and its subsidiaries.
#include <compiler.h>
#include <port.h>
#include <sercom.h>
#include <pinmux.h>
#include <string.h>
#include <conf_spi.h>
#include <sercom_interrupt.h>
Data Structures | |
struct | spi_config |
SPI configuration structure. More... | |
struct | spi_master_config |
SPI Master configuration structure. More... | |
struct | spi_module |
SERCOM SPI driver software device instance structure. More... | |
struct | spi_slave_config |
SPI slave configuration structure. More... | |
struct | spi_slave_inst |
SPI peripheral slave instance structure. More... | |
struct | spi_slave_inst_config |
SPI peripheral slave configuration structure. More... | |
Macros | |
#define | PINMUX_DEFAULT 0 |
Default pinmux. More... | |
#define | PINMUX_UNUSED 0xFFFFFFFF |
Unused pinmux. More... | |
#define | SPI_TIMEOUT 10000 |
SPI timeout value. More... | |
Driver Feature Definition | |
Define SERCOM SPI features set according to different device family. | |
#define | FEATURE_SPI_SLAVE_SELECT_LOW_DETECT |
SPI slave select low detection. More... | |
#define | FEATURE_SPI_HARDWARE_SLAVE_SELECT |
Slave select can be controlled by hardware. More... | |
#define | FEATURE_SPI_ERROR_INTERRUPT |
SPI with error detect feature. More... | |
#define | FEATURE_SPI_SYNC_SCHEME_VERSION_2 |
SPI sync scheme version 2. More... | |
Typedefs | |
typedef void(* | spi_callback_t )(struct spi_module *const module) |
Type of the callback functions. More... | |
Functions | |
static bool | spi_is_syncing (struct spi_module *const module) |
Determines if the SPI module is currently synchronizing to the bus. More... | |
enum status_code | spi_set_baudrate (struct spi_module *const module, uint32_t baudrate) |
Set the baudrate of the SPI module. More... | |
Driver Initialization and Configuration | |
static void | spi_get_config_defaults (struct spi_config *const config) |
Initializes an SPI configuration structure to default values. More... | |
static void | spi_slave_inst_get_config_defaults (struct spi_slave_inst_config *const config) |
Initializes an SPI peripheral slave device configuration structure to default values. More... | |
static void | spi_attach_slave (struct spi_slave_inst *const slave, const struct spi_slave_inst_config *const config) |
Attaches an SPI peripheral slave. More... | |
enum status_code | spi_init (struct spi_module *const module, Sercom *const hw, const struct spi_config *const config) |
Initializes the SERCOM SPI module. More... | |
Enable/Disable | |
static void | spi_enable (struct spi_module *const module) |
Enables the SERCOM SPI module. More... | |
static void | spi_disable (struct spi_module *const module) |
Disables the SERCOM SPI module. More... | |
void | spi_reset (struct spi_module *const module) |
Resets the SPI module. More... | |
Lock/Unlock | |
static enum status_code | spi_lock (struct spi_module *const module) |
Attempt to get lock on driver instance. More... | |
static void | spi_unlock (struct spi_module *const module) |
Unlock driver instance. More... | |
Ready to Write/Read | |
static bool | spi_is_write_complete (struct spi_module *const module) |
Checks if the SPI in master mode has shifted out last data, or if the master has ended the transfer in slave mode. More... | |
static bool | spi_is_ready_to_write (struct spi_module *const module) |
Checks if the SPI module is ready to write data. More... | |
static bool | spi_is_ready_to_read (struct spi_module *const module) |
Checks if the SPI module is ready to read data. More... | |
Read/Write | |
static enum status_code | spi_write (struct spi_module *module, uint16_t tx_data) |
Transfers a single SPI character. More... | |
enum status_code | spi_write_buffer_wait (struct spi_module *const module, const uint8_t *tx_data, uint16_t length) |
Sends a buffer of length SPI characters. More... | |
static enum status_code | spi_read (struct spi_module *const module, uint16_t *rx_data) |
Reads last received SPI character. More... | |
enum status_code | spi_read_buffer_wait (struct spi_module *const module, uint8_t *rx_data, uint16_t length, uint16_t dummy) |
Reads buffer of length SPI characters. More... | |
enum status_code | spi_transceive_wait (struct spi_module *const module, uint16_t tx_data, uint16_t *rx_data) |
Sends and reads a single SPI character. More... | |
enum status_code | spi_transceive_buffer_wait (struct spi_module *const module, uint8_t *tx_data, uint8_t *rx_data, uint16_t length) |
Sends and receives a buffer of length SPI characters. More... | |
enum status_code | spi_select_slave (struct spi_module *const module, struct spi_slave_inst *const slave, bool select) |
Selects slave device. More... | |