ECE 4760 Final Project
 All Files Functions Variables Enumerations Enumerator Macros
Macros | Functions
twimaster.c File Reference
#include <inttypes.h>
#include <compat/twi.h>
#include "i2cmaster.h"

Go to the source code of this file.

Macros

#define F_CPU   16000000UL
 
#define SCL_CLOCK   100000L
 

Functions

void i2c_init (void)
 initialize the I2C master interace. Need to be called only once More...
 
unsigned char i2c_start (unsigned char address)
 Issues a start condition and sends address and transfer direction. More...
 
void i2c_start_wait (unsigned char address)
 Issues a start condition and sends address and transfer direction. More...
 
unsigned char i2c_rep_start (unsigned char address)
 Issues a repeated start condition and sends address and transfer direction. More...
 
void i2c_stop (void)
 Terminates the data transfer and releases the I2C bus. More...
 
unsigned char i2c_write (unsigned char data)
 Send one byte to I2C device. More...
 
unsigned char i2c_readAck (void)
 read one byte from the I2C device, request more data from device More...
 
unsigned char i2c_readNak (void)
 read one byte from the I2C device, read is followed by a stop condition More...
 

Macro Definition Documentation

#define F_CPU   16000000UL

Definition at line 17 of file twimaster.c.

#define SCL_CLOCK   100000L

Definition at line 21 of file twimaster.c.

Function Documentation

void i2c_init ( void  )

initialize the I2C master interace. Need to be called only once

Parameters
void
Returns
none

Definition at line 27 of file twimaster.c.

unsigned char i2c_readAck ( void  )

read one byte from the I2C device, request more data from device

Returns
byte read from I2C device

Definition at line 180 of file twimaster.c.

unsigned char i2c_readNak ( void  )

read one byte from the I2C device, read is followed by a stop condition

Returns
byte read from I2C device

Definition at line 195 of file twimaster.c.

unsigned char i2c_rep_start ( unsigned char  addr)

Issues a repeated start condition and sends address and transfer direction.

Parameters
addraddress and transfer direction of I2C device
Return values
0device accessible
1failed to access device

Definition at line 128 of file twimaster.c.

unsigned char i2c_start ( unsigned char  addr)

Issues a start condition and sends address and transfer direction.

Parameters
addraddress and transfer direction of I2C device
Return values
0device accessible
1failed to access device

Definition at line 41 of file twimaster.c.

void i2c_start_wait ( unsigned char  addr)

Issues a start condition and sends address and transfer direction.

If device is busy, use ack polling to wait until device ready

Parameters
addraddress and transfer direction of I2C device
Returns
none

Definition at line 77 of file twimaster.c.

void i2c_stop ( void  )

Terminates the data transfer and releases the I2C bus.

Parameters
void
Returns
none

Definition at line 138 of file twimaster.c.

unsigned char i2c_write ( unsigned char  data)

Send one byte to I2C device.

Parameters
databyte to be transfered
Return values
0write successful
1write failed

Definition at line 156 of file twimaster.c.