SAM Serial Peripheral Interface Driver.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include "spi_interrupt.h"
Functions | |
void | _spi_interrupt_handler (uint8_t instance) |
static void | _spi_read (struct spi_module *const module) |
static void | _spi_read_buffer (struct spi_module *const module, uint8_t *rx_data, uint16_t length) |
static void | _spi_read_dummy (struct spi_module *const module) |
static void | _spi_transceive_buffer (struct spi_module *const module, uint8_t *tx_data, uint8_t *rx_data, uint16_t length) |
static void | _spi_write (struct spi_module *const module) |
static void | _spi_write_buffer (struct spi_module *const module, uint8_t *tx_data, uint16_t length) |
static void | _spi_write_dummy (struct spi_module *const module) |
void | spi_abort_job (struct spi_module *const module) |
Aborts an ongoing job. More... | |
enum status_code | spi_read_buffer_job (struct spi_module *const module, uint8_t *rx_data, uint16_t length, uint16_t dummy) |
Asynchronous buffer read. More... | |
void | spi_register_callback (struct spi_module *const module, spi_callback_t callback_func, enum spi_callback callback_type) |
Registers a SPI callback function. More... | |
enum status_code | spi_transceive_buffer_job (struct spi_module *const module, uint8_t *tx_data, uint8_t *rx_data, uint16_t length) |
Asynchronous buffer write and read. More... | |
void | spi_unregister_callback (struct spi_module *const module, enum spi_callback callback_type) |
Unregisters a SPI callback function. More... | |
enum status_code | spi_write_buffer_job (struct spi_module *const module, uint8_t *tx_data, uint16_t length) |
Asynchronous buffer write. More... | |
Variables | |
uint16_t | dummy_write |
void _spi_interrupt_handler | ( | uint8_t | instance | ) |
Handles interrupts as they occur, and it will run callback functions which are registered and enabled.
[in] | instance | ID of the SERCOM instance calling the interrupt handler. |
References _sercom_instances, _spi_read(), _spi_read_dummy(), _spi_write(), _spi_write_dummy(), CONF_SPI_MASTER_ENABLE, CONF_SPI_SLAVE_ENABLE, SPI_CALLBACK_BUFFER_RECEIVED, SPI_CALLBACK_BUFFER_TRANSCEIVED, SPI_CALLBACK_BUFFER_TRANSMITTED, SPI_CALLBACK_ERROR, SPI_CALLBACK_SLAVE_TRANSMISSION_COMPLETE, SPI_INTERRUPT_FLAG_DATA_REGISTER_EMPTY, SPI_INTERRUPT_FLAG_RX_COMPLETE, SPI_INTERRUPT_FLAG_TX_COMPLETE, SPI_MODE_MASTER, SPI_MODE_SLAVE, STATUS_ERR_OVERFLOW, STATUS_OK, and UNUSED.
Referenced by spi_init().
|
static |
Reads a character from the Data register to the RX buffer.
[in,out] | module | Pointer to SPI software instance struct |
References SPI_CHARACTER_SIZE_9BIT.
Referenced by _spi_interrupt_handler().
|
static |
Setup SPI to read a buffer with a given length
[in] | module | Pointer to SPI software instance struct |
[in] | rx_data | Pointer to data to be received |
[in] | length | Length of data buffer |
References Assert, SPI_INTERRUPT_FLAG_DATA_REGISTER_EMPTY, SPI_INTERRUPT_FLAG_RX_COMPLETE, SPI_INTERRUPT_FLAG_TX_COMPLETE, SPI_MODE_MASTER, SPI_MODE_SLAVE, and STATUS_BUSY.
Referenced by spi_read_buffer_job().
|
static |
Writes a dummy character from the to the Data register.
[in,out] | module | Pointer to SPI software instance struct |
References UNUSED.
Referenced by _spi_interrupt_handler().
|
static |
Starts transceive of buffers with a given length
[in] | module | Pointer to SPI software instance struct |
[in] | rx_data | Pointer to data to be received |
[in] | tx_data | Pointer to data to be transmitted |
[in] | length | Length of data buffer |
References Assert, SPI_INTERRUPT_FLAG_DATA_REGISTER_EMPTY, SPI_INTERRUPT_FLAG_RX_COMPLETE, SPI_INTERRUPT_FLAG_TX_COMPLETE, SPI_MODE_SLAVE, and STATUS_BUSY.
Referenced by spi_transceive_buffer_job().
|
static |
Writes a character from the TX buffer to the Data register.
[in,out] | module | Pointer to SPI software instance struct |
References SPI_CHARACTER_SIZE_9BIT.
Referenced by _spi_interrupt_handler().
|
static |
Starts write of a buffer with a given length
[in] | module | Pointer to SPI software instance struct |
[in] | tx_data | Pointer to data to be transmitted |
[in] | length | Length of data buffer |
References Assert, SPI_INTERRUPT_FLAG_DATA_REGISTER_EMPTY, SPI_INTERRUPT_FLAG_RX_COMPLETE, SPI_INTERRUPT_FLAG_TX_COMPLETE, SPI_MODE_SLAVE, and STATUS_BUSY.
Referenced by spi_write_buffer_job().
|
static |
Writes a dummy character to the Data register.
[in,out] | module | Pointer to SPI software instance struct |
References dummy_write.
Referenced by _spi_interrupt_handler().
uint16_t dummy_write |
Dummy byte to send when reading in master mode.
Referenced by _spi_write_dummy(), and spi_read_buffer_job().