Functions

i2c.c File Reference

#include "i2c.h"
#include <util/delay_basic.h>
#include <util/delay.h>

Functions

void i2c_timerproc (void)
uint8_t read_i2c_device (uint8_t address, uint8_t rbytes, uint8_t *rdata)
 Read 1 or more bytes from an I2C device to memory.
uint8_t write_i2c_device (uint8_t address, uint8_t wbytes, uint8_t *wdata)
 Write 1 or more bytes to an I2C device from memory.
uint8_t write_read_i2c_device (uint8_t address, uint8_t wbytes, uint8_t *wdata, uint8_t rbytes, uint8_t *rdata)
 Write 1 or more bytes to an I2C device followed by a read without releasing the bus.

Function Documentation

void i2c_timerproc ( void   ) 
uint8_t read_i2c_device ( uint8_t  address,
uint8_t  bytes,
uint8_t *  rdata 
)

Read 1 or more bytes from an I2C device to memory.

Parameters:
address Address if I2C device. The bottom bit is set to enforce an I2C read.
bytes Number of bytes to be returned.
*rdata Pointer to location to store values returned.
Returns:
returns error code generated from I2C transaction, or 0 for success
uint8_t write_i2c_device ( uint8_t  address,
uint8_t  bytes,
uint8_t *  wdata 
)

Write 1 or more bytes to an I2C device from memory.

Parameters:
address Address if I2C device. The bottom bit is cleared to enforce an I2C write.
bytes Number of data bytes to be sent.
*wdata Pointer to location in memory of first byte of set of data.
Returns:
returns error code generated from I2C transaction, or 0 for success
uint8_t write_read_i2c_device ( uint8_t  address,
uint8_t  wbytes,
uint8_t *  wdata,
uint8_t  rbytes,
uint8_t *  rdata 
)

Write 1 or more bytes to an I2C device followed by a read without releasing the bus.

Parameters:
address Address if I2C device. The bottom bit is manipulated as appropriate for R/W
wbytes Number of bytes to write.
*wdata Pointer to location in memory of first byte to write.
rbytes Number of bytes to read.
*rdata Pointer to location in memory of first byte of set of data.
Returns:
returns error code generated from I2C transaction, or 0 for success