21 #define BOARD_ID_TWI ID_TWIHS0 22 #define BOARD_TWI TWIHS0 23 #define TWI_CLK 400000 46 int i2cRead(uint8_t chip_addr, uint32_t address, uint8_t address_len,
void *
data, uint32_t len)
51 packet_rx.
chip = chip_addr;
55 packet_rx.
addr[0] = address >> 16;
56 packet_rx.
addr[1] = address >> 8;
57 packet_rx.
addr[2] = address;
59 else if(address_len == 2)
61 packet_rx.
addr[0] = address >> 8;
62 packet_rx.
addr[1] = address;
64 else if(address_len == 1)
66 packet_rx.
addr[0] = address;
83 int i2cWrite(uint8_t chip_addr, uint32_t address, uint8_t address_len,
void *
data, uint32_t len)
88 packet_tx.
chip = chip_addr;
92 packet_tx.
addr[0] = address >> 16;
93 packet_tx.
addr[1] = address >> 8;
94 packet_tx.
addr[2] = address;
96 else if(address_len == 2)
98 packet_tx.
addr[0] = address >> 8;
99 packet_tx.
addr[1] = address;
101 else if(address_len == 1)
103 packet_tx.
addr[0] = address;
void * buffer
Where to find the data to be transferred.
int i2cWrite(uint8_t chip_addr, uint32_t address, uint8_t address_len, void *data, uint32_t len)
Information concerning the data transmission.
uint32_t master_clk
MCK for TWIHS.
uint32_t addr_length
Length of the TWIHS data address segment (1-3 bytes).
uint32_t pmc_enable_periph_clk(uint32_t ul_id)
Enable the specified peripheral clock.
#define ioport_set_pin_peripheral_mode(pin, mode)
uint32_t twihs_master_init(Twihs *p_twihs, const twihs_options_t *p_opt)
Initialize TWIHS master mode.
static uint32_t sysclk_get_peripheral_hz(void)
Retrieves the current rate in Hz of the peripheral clocks.
int i2cRead(uint8_t chip_addr, uint32_t address, uint8_t address_len, void *data, uint32_t len)
USBInterfaceDescriptor data
uint32_t length
How many bytes do we want to transfer.
uint32_t twihs_master_read(Twihs *p_twihs, twihs_packet_t *p_packet)
Read multiple bytes from a TWIHS compatible slave device.
uint8_t chip
TWIHS chip address to communicate with.
uint32_t speed
The baud rate of the TWIHS bus.
Autogenerated API include file for the Atmel Software Framework (ASF)
Input parameters when initializing the TWIHS module mode.
uint32_t twihs_master_write(Twihs *p_twihs, twihs_packet_t *p_packet)
Write multiple bytes to a TWIHS compatible slave device.
#define TWIHS_SUCCESS
Return codes for TWIHS APIs.
uint8_t addr[3]
TWIHS address/commands to issue to the other chip (node).