TWIS driver for SAM.
This file defines a useful set of functions for the TWIS on SAM4L devices.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | twis_callback |
struct | twis_config |
Input parameters when initializing the TWIS module mode. More... | |
struct | twis_dev_inst |
TWI slave driver software instance structure. More... | |
Macros | |
#define | TWIS_WAIT_TIMEOUT 1000 |
Typedefs | |
typedef struct twis_callback | twis_callback_t |
typedef enum twis_interrupt_source | twis_interrupt_source_t |
TWIS interrupt source type. More... | |
Enumerations | |
enum | twis_interrupt_source { TWIS_INTERRUPT_RX_BUFFER_READY = TWIS_IER_RXRDY, TWIS_INTERRUPT_TX_BUFFER_READY = TWIS_IER_TXRDY, TWIS_INTERRUPT_TRANS_COMP = TWIS_IER_TCOMP, TWIS_INTERRUPT_UNDER_RUN = TWIS_IER_URUN, TWIS_INTERRUPT_OVER_RUN = TWIS_IER_ORUN, TWIS_INTERRUPT_NAK_RECEIVED = TWIS_IER_NAK, TWIS_INTERRUPT_SMBUS_TIMEOUT = TWIS_IER_SMBTOUT, TWIS_INTERRUPT_SMBUS_PEC_ERROR = TWIS_IER_SMBPECERR, TWIS_INTERRUPT_BUS_ERROR = TWIS_IER_BUSERR, TWIS_INTERRUPT_SLAVEADR_MATCH = TWIS_IER_SAM, TWIS_INTERRUPT_GENCALL_MATCH = TWIS_IER_GCM, TWIS_INTERRUPT_SMBUS_HHADR_MATCH = TWIS_IER_SMBHHM, TWIS_INTERRUPT_SMBUS_DEFADR_MATCH = TWIS_IER_SMBDAM, TWIS_INTERRUPT_STOP_RECEIVED = TWIS_IER_STO, TWIS_INTERRUPT_RESTART_RECEIVED = TWIS_IER_REP, TWIS_INTERRUPT_BYTE_TRANS_FINISHED = TWIS_IER_BTF, TWIS_INTERRUPT_ERRORS, TWIS_INTERRUPT_ALL = ~0UL } |
TWIS interrupt source type. More... | |
Functions | |
static void | twis_clear_status (struct twis_dev_inst *const dev_inst, uint32_t clear_status) |
Clear the current status of the TWIS. More... | |
void | twis_disable (struct twis_dev_inst *const dev_inst) |
Disable TWIS Module. More... | |
static void | twis_disable_interrupt (struct twis_dev_inst *const dev_inst, twis_interrupt_source_t interrupt_source) |
Disable the TWIS interrupts. More... | |
void | twis_enable (struct twis_dev_inst *const dev_inst) |
Enable TWIS Module. More... | |
static void | twis_enable_interrupt (struct twis_dev_inst *const dev_inst, twis_interrupt_source_t interrupt_source) |
Enable the TWIS interrupts. More... | |
void | twis_get_config_defaults (struct twis_config *const cfg) |
Get the TWIS master default configurations. More... | |
static uint32_t | twis_get_interrupt_mask (struct twis_dev_inst *const dev_inst) |
Get the TWIS interrupt mask. More... | |
static uint8_t | twis_get_smbus_pec (struct twis_dev_inst *const dev_inst) |
Get the calculated PEC value. More... | |
static uint8_t | twis_get_smbus_transfer_nb (struct twis_dev_inst *const dev_inst) |
Get the progress of the transfer in SMBus mode. More... | |
static uint32_t | twis_get_status (struct twis_dev_inst *const dev_inst) |
Information about the current status of the TWIS. More... | |
enum status_code | twis_init (struct twis_dev_inst *const dev_inst, Twis *const twis, struct twis_config *config) |
Initialize the TWI Slave Module. More... | |
static enum status_code | twis_read (struct twis_dev_inst *const dev_inst, uint8_t *data) |
Get the last byte data received from TWI bus. More... | |
static void | twis_send_data_ack (struct twis_dev_inst *const dev_inst) |
Enable ACK transfer in Slave Receiver Mode. More... | |
static void | twis_send_data_nack (struct twis_dev_inst *const dev_inst) |
Enable NACK transfer in Slave Receiver Mode. More... | |
void | twis_set_callback (struct twis_dev_inst *const dev_inst, twis_interrupt_source_t source, twis_callback_t callback, uint8_t irq_level) |
Set callback for TWIS. More... | |
static void | twis_set_smbus_transfer_nb (struct twis_dev_inst *const dev_inst, uint8_t nb, bool increment) |
Set the total number of data bytes in the transmission. More... | |
static enum status_code | twis_write (struct twis_dev_inst *const dev_inst, uint8_t byte) |
Write one byte data to TWI bus. More... | |