Main Page   Modules   Data Structures   File List   Data Fields   Globals  

i2c.h File Reference

I2C interface using AVR Two-Wire Interface (TWI) hardware. More...

#include <avr/twi.h>
#include "global.h"
#include "i2cconf.h"

Go to the source code of this file.

Defines

#define TWCR_CMD_MASK   0x0F
#define TWSR_STATUS_MASK   0xF8
#define I2C_OK   0x00
#define I2C_ERROR_NODEV   0x01

Enumerations

enum  eI2cStateType {
  I2C_IDLE = 0, I2C_BUSY = 1, I2C_MASTER_TX = 2, I2C_MASTER_RX = 3,
  I2C_SLAVE_TX = 4, I2C_SLAVE_RX = 5
}

Functions

void i2cInit (void)
 Initialize I2C (TWI) interface.

void i2cSetBitrate (u16 bitrateKHz)
 Set the I2C transaction bitrate (in KHz).

void i2cSetLocalDeviceAddr (u08 deviceAddr, u08 genCallEn)
 Set the local (AVR processor's) I2C device address.

void i2cSetSlaveReceiveHandler (void(*i2cSlaveRx_func)(u08 receiveDataLength, u08 *recieveData))
 Set the user function which handles receiving (incoming) data as a slave.

void i2cSetSlaveTransmitHandler (u08(*i2cSlaveTx_func)(u08 transmitDataLengthMax, u08 *transmitData))
 Set the user function which handles transmitting (outgoing) data as a slave.

void i2cSendStart (void)
 Send an I2C start condition in Master mode.

void i2cSendStop (void)
 Send an I2C stop condition in Master mode.

void i2cWaitForComplete (void)
 Wait for current I2C operation to complete.

void i2cSendByte (u08 data)
 Send an (address|R/W) combination or a data byte over I2C.

void i2cReceiveByte (u08 ackFlag)
 Receive a data byte over I2C.

u08 i2cGetReceivedByte (void)
 Pick up the data that was received with i2cReceiveByte().

u08 i2cGetStatus (void)
 Get current I2c bus status from TWSR.

void i2cMasterSend (u08 deviceAddr, u08 length, u08 *data)
 send I2C data to a device on the bus

void i2cMasterReceive (u08 deviceAddr, u08 length, u08 *data)
 receive I2C data from a device on the bus

u08 i2cMasterSendNI (u08 deviceAddr, u08 length, u08 *data)
 send I2C data to a device on the bus (non-interrupt based)

u08 i2cMasterReceiveNI (u08 deviceAddr, u08 length, u08 *data)
 receive I2C data from a device on the bus (non-interrupt based)

eI2cStateType i2cGetState (void)
 Get the current high-level state of the I2C interface.


Detailed Description

I2C interface using AVR Two-Wire Interface (TWI) hardware.

Definition in file i2c.h.


Generated on Sun Feb 22 19:12:31 2004 for Procyon AVRlib by doxygen1.3-rc2