740 #define TWIHS_SR_TXRDY
(TWIHS_SR) Transmit Holding Register Ready (cleared by writing TWIHS_THR)
void * buffer
Where to find the data to be transferred.
#define I2C_FAST_MODE_SPEED
__IO uint32_t TWIHS_SMBTR
(Twihs Offset: 0x38) SMBus Timing Register
void twihs_write_byte(Twihs *p_twihs, uint8_t uc_byte)
Sends a byte of data to one of the TWIHS slaves on the bus.
#define TWIHS_CR_MSDIS
(TWIHS_CR) TWIHS Master Mode Disabled
#define TWIHS_SMR_SADR(value)
__I uint32_t TWIHS_SR
(Twihs Offset: 0x20) Status Register
#define TWIHS_CR_STOP
(TWIHS_CR) Send a STOP Condition
uint8_t twihs_read_byte(Twihs *p_twihs)
Reads a byte from the TWIHS bus.
void twihs_set_filter(Twihs *p_twihs, uint32_t ul_filter)
Set the filter for TWIHS.
#define TWIHS_MMR_IADRSZ_Pos
__I uint32_t TWIHS_RHR
(Twihs Offset: 0x30) Receive Holding Register
void twihs_read_write_protection_status(Twihs *p_twihs, uint32_t *p_status)
Read the write protection status.
__I uint32_t TWIHS_IMR
(Twihs Offset: 0x2C) Interrupt Mask Register
Information concerning the data transmission.
__O uint32_t TWIHS_IER
(Twihs Offset: 0x24) Interrupt Enable Register
void twihs_slave_init(Twihs *p_twihs, uint32_t ul_device_addr)
Initialize TWIHS slave mode.
void twihs_set_write_protection(Twihs *p_twihs, bool flag)
Enables/Disables write protection mode.
static uint32_t twihs_mk_addr(const uint8_t *addr, int len)
#define TWIHS_SMR_MASK(value)
uint32_t master_clk
MCK for TWIHS.
void twihs_set_slave_addr(Twihs *p_twihs, uint32_t ul_device_addr)
Set TWIHS slave address.
uint32_t addr_length
Length of the TWIHS data address segment (1-3 bytes).
__O uint32_t TWIHS_CR
(Twihs Offset: 0x00) Control Register
__IO uint32_t TWIHS_CWGR
(Twihs Offset: 0x10) Clock Waveform Generator Register
#define TWIHS_SWMR_SADR1(value)
#define TWIHS_WPMR_WPKEY_PASSWD
(TWIHS_WPMR) Writing any other value in this field aborts the write operation of the WPEN bit...
#define TWIHS_CWGR_CLDIV(value)
__IO uint32_t TWIHS_SWMR
(Twihs Offset: 0x4C) SleepWalking Matching Register
#define TWIHS_SR_NACK
(TWIHS_SR) Not Acknowledged (cleared on read)
#define TWIHS_MMR_IADRSZ_Msk
(TWIHS_MMR) Internal Device Address Size
uint32_t twihs_probe(Twihs *p_twihs, uint8_t uc_slave_addr)
Test if a chip answers a given I2C address.
#define TWIHS_MMR_DADR(value)
uint32_t twihs_set_speed(Twihs *p_twihs, uint32_t ul_speed, uint32_t ul_mck)
Set the I2C bus speed in conjunction with the clock frequency.
uint32_t twihs_master_init(Twihs *p_twihs, const twihs_options_t *p_opt)
Initialize TWIHS master mode.
#define TWIHS_SR_TXCOMP
(TWIHS_SR) Transmission Completed (cleared by writing TWIHS_THR)
__IO uint32_t TWIHS_SMR
(Twihs Offset: 0x08) Slave Mode Register
#define TWIHS_CR_SVDIS
(TWIHS_CR) TWIHS Slave Mode Disabled
#define TWIHS_WPMR_WPEN
(TWIHS_WPMR) Write Protection Enable
void twihs_enable_interrupt(Twihs *p_twihs, uint32_t ul_sources)
Enable TWIHS interrupts.
uint32_t twihs_get_interrupt_mask(Twihs *p_twihs)
Read TWIHS interrupt mask.
#define TWIHS_CR_START
(TWIHS_CR) Send a START Condition
__O uint32_t TWIHS_THR
(Twihs Offset: 0x34) Transmit Holding Register
#define TWIHS_CR_SWRST
(TWIHS_CR) Software Reset
#define TWIHS_SR_EOSACC
(TWIHS_SR) End Of Slave Access (cleared on read)
void twihs_reset(Twihs *p_twihs)
Reset TWIHS.
uint32_t twihs_get_interrupt_status(Twihs *p_twihs)
Get TWIHS interrupt status.
#define TWIHS_SR_GACC
(TWIHS_SR) General Call Access (cleared on read)
#define LOW_LEVEL_TIME_LIMIT
#define TWIHS_SR_SVREAD
(TWIHS_SR) Slave Read
#define TWIHS_RECEIVE_NACK
Two-Wire Interface High Speed (TWIHS) driver for SAM.
__IO uint32_t TWIHS_MMR
(Twihs Offset: 0x04) Master Mode Register
__I uint32_t TWIHS_WPSR
(Twihs Offset: 0xE8) Write Protection Status Register
uint32_t twihs_slave_read(Twihs *p_twihs, uint8_t *p_data)
Read data from master.
#define TWIHS_CWGR_CHDIV(value)
__IO uint32_t TWIHS_WPMR
(Twihs Offset: 0xE4) Write Protection Mode Register
#define TWIHS_ERROR_TIMEOUT
#define TWIHS_CLK_DIV_MIN
#define TWIHS_CR_MSEN
(TWIHS_CR) TWIHS Master Mode Enabled
#define TWIHS_SWMR_DATAM(value)
Twihs hardware registers.
USBInterfaceDescriptor data
uint32_t length
How many bytes do we want to transfer.
#define TWIHS_SWMR_SADR3(value)
__IO uint32_t TWIHS_IADR
(Twihs Offset: 0x0C) Internal Address Register
#define TWIHS_SWMR_SADR2(value)
void twihs_smbus_set_timing(Twihs *p_twihs, uint32_t ul_timing)
Set the prescaler, TLOW:SEXT, TLOW:MEXT and clock high max cycles for SMBUS mode. ...
#define TWIHS_INVALID_ARGUMENT
uint32_t twihs_master_read(Twihs *p_twihs, twihs_packet_t *p_packet)
Read multiple bytes from a TWIHS compatible slave device.
__O uint32_t TWIHS_IDR
(Twihs Offset: 0x28) Interrupt Disable Register
uint32_t twihs_slave_write(Twihs *p_twihs, uint8_t *p_data)
Write data to TWIHS bus.
void twihs_set_alternative_command(Twihs *p_twihs, uint32_t ul_alt_cmd)
Set length/direction/PEC for alternative command mode.
uint8_t chip
TWIHS chip address to communicate with.
void twihs_disable_slave_mode(Twihs *p_twihs)
Disable TWIHS slave mode.
#define TWIHS_CR_SVEN
(TWIHS_CR) TWIHS Slave Mode Enabled
#define TWIHS_CLK_CALC_ARGU
uint32_t speed
The baud rate of the TWIHS bus.
void twihs_disable_interrupt(Twihs *p_twihs, uint32_t ul_sources)
Disable TWIHS interrupts.
__IO uint32_t TWIHS_FILTR
(Twihs Offset: 0x44) Filter Register
void twihs_enable_slave_mode(Twihs *p_twihs)
Enable TWIHS slave mode.
#define TWIHS_SR_RXRDY
(TWIHS_SR) Receive Holding Register Ready (cleared by reading TWIHS_RHR)
Input parameters when initializing the TWIHS module mode.
#define TWIHS_MMR_MREAD
(TWIHS_MMR) Master Read Direction
uint32_t twihs_master_write(Twihs *p_twihs, twihs_packet_t *p_packet)
Write multiple bytes to a TWIHS compatible slave device.
Pdc * twihs_get_pdc_base(Twihs *p_twihs)
Get TWIHS PDC base address.
#define TWIHS_SUCCESS
Return codes for TWIHS APIs.
#define Assert(expr)
This macro is used to test fatal errors.
uint8_t addr[3]
TWIHS address/commands to issue to the other chip (node).
#define TWIHS_CWGR_CKDIV(value)
#define TWIHS_SR_SVACC
(TWIHS_SR) Slave Access
void twihs_disable_master_mode(Twihs *p_twihs)
Disable TWIHS master mode.
#define TWIHS_CLK_DIV_MAX
#define TWIHS_CLK_DIVIDER
void twihs_enable_master_mode(Twihs *p_twihs)
Enable TWIHS master mode.
void twihs_mask_slave_addr(Twihs *p_twihs, uint32_t ul_mask)
A mask can be applied on the slave device address in slave mode in order to allow multiple address an...