TWIM driver for SAM.
This file defines a useful set of functions for the TWIM on SAM4L devices.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | twim_config |
Input parameters when initializing the TWIM module mode. More... | |
struct | twim_package |
Information concerning the data transmission. More... | |
Macros | |
#define | TWIM_IER_NAK_MASK (TWIM_IER_ANAK | TWIM_IER_DNAK) |
Interrupt Enable Register Mask for No Acknowledgements. More... | |
#define | TWIM_IER_STD_MASK (TWIM_IER_ANAK | TWIM_IER_ARBLST) |
Frequently used Interrupt Enable Register Mask. More... | |
#define | TWIM_LOW_POWER_ENABLE 1 |
Enable TWIM Low Power Transfer in default. More... | |
#define | TWIM_SCR_NAK_MASK (TWIM_SCR_ANAK | TWIM_SCR_DNAK) |
Status Clear Register Mask for No Acknowledgements. More... | |
#define | TWIM_SR_NAK_MASK (TWIM_SR_ANAK | TWIM_SR_DNAK) |
Status Register Mask for No Acknowledgements. More... | |
#define | TWIM_SR_STD_MASK (TWIM_SR_ANAK | TWIM_SR_ARBLST) |
Frequently used Status Clear Register Mask. More... | |
TWI transfer speed definitions | |
#define | TWI_STD_MODE_SPEED ( 100000 /* kbit/s */) |
TWI Standard Mode. More... | |
#define | TWI_FAST_MODE_SPEED ( 400000 /* kbit/s */) |
TWI Fast Mode. More... | |
#define | TWI_FAST_MODE_PLUS_SPEED (1000000 /* kbit/s */) |
TWI Fast Mode Plus. More... | |
#define | TWI_HIGH_SPEED_MODE_SPEED (3400000 /* kbit/s */) |
TWI High Speed Mode. More... | |
TWI Driver Compatibility | |
Codes for SAM devices using TWI modules can easily be ported to SAM devices with TWIM module | |
#define | twi_options_t struct twim_config |
#define | twi_package_t struct twim_package |
#define | twi_master_init twim_set_config |
#define | twi_probe twim_probe |
Typedefs | |
typedef void(* | twim_callback_t )(Twim *) |
Functions | |
status_code_t | twi_master_read (Twim *twim, struct twim_package *package) |
Read multiple bytes from a TWI compatible slave device. More... | |
status_code_t | twi_master_write (Twim *twim, struct twim_package *package) |
Write multiple bytes to a TWI compatible slave device. More... | |
void | twim_clear_status (Twim *twim, uint32_t clear_status) |
Clear the current status of the TWIM. More... | |
void | twim_default_callback (Twim *twim) |
TWIM default callback function. More... | |
static void | twim_disable (Twim *twim) |
Disable Master Mode of the TWI. More... | |
void | twim_disable_interrupt (Twim *twim, uint32_t interrupt_source) |
Disable the TWIM interrupts and clear their status. More... | |
static void | twim_enable (Twim *twim) |
Enable Master Mode of the TWI. More... | |
void | twim_enable_interrupt (Twim *twim, uint32_t interrupt_source) |
Enable the TWIM interrupts. More... | |
uint32_t | twim_get_interrupt_mask (Twim *twim) |
Get the TWIM interrupt mask. More... | |
uint32_t | twim_get_status (Twim *twim) |
Information about the current status of the TWIM. More... | |
void | twim_pdca_transfer_prepare (Twim *twim, twi_package_t *package, bool read) |
Set TWIM for PDCA transfer. More... | |
status_code_t | twim_probe (Twim *twim, uint32_t chip_addr) |
Test if a chip answers for a given TWI address. More... | |
void | twim_set_callback (Twim *twim, uint32_t interrupt_source, twim_callback_t callback, uint8_t irq_level) |
Set callback for TWIM. More... | |
status_code_t | twim_set_config (Twim *twim, struct twim_config *config) |
Initialize the TWIM module. More... | |
status_code_t | twim_set_hsmode_speed (Twim *twim, uint32_t speed, uint32_t clk, uint8_t cycles) |
Set the TWI bus speed in conjunction with the clock frequency in high speed mode. More... | |
status_code_t | twim_set_speed (Twim *twim, uint32_t speed, uint32_t clk, uint8_t cycles) |
Set the TWI bus speed in conjunction with the clock frequency. More... | |
enum | twim_transfer_status { TWI_SUCCESS = 0, TWI_INVALID_ARGUMENT = -1, TWI_ARBITRATION_LOST = -2, TWI_NO_CHIP_FOUND = -3, TWI_RECEIVE_NACK = -4, TWI_SEND_NACK = -5, TWI_INVALID_CLOCK_DIV = -6 } |
Status Codes for TWI Transfer. More... | |
typedef enum twim_transfer_status | twim_transfer_status_t |