|
Home Up I2C library Serial Interface
| |

|
The following source files and headers
were written by me, Chris Keeser on 6/4 - 6/11 2005.
Copyright Chris Keeser 2005.
Updated on 6/21/05 to allow SDA and SCK to be on different
ports
Updated on 7/16/05 to allow for clock stretching during
byte recieve. Can be enabled / disabled through
condition compilation. The I2Croutines.h header file
contains the conditional compile flag CLOCK_STRETCHING.
I2Croutines:
#defines in the
header file are used to set the specific port and pins.
 |
void i2cInit(void)
 |
Initializes the I2C interface pins |
|
 |
void start(void);
 |
i2c start condition generator |
|
 |
void restart(void);
 |
i2c restart condition generator |
|
 |
void sendByte(uint8_t);
 |
shifts out a byte, msb first, data
is latched in on the rising edge |
|
 |
uint8_t recieveByte(void);
 |
shifts in a byte, msb first, data
is latched in on the rising edge |
|
 |
void sendAck(void);
 |
Master Acknowledge generator |
|
 |
void sendNack(void);
 |
Master NO Acknowledge generator |
|
 |
uint8_t recieveAck(void);
 |
Checks for slave Acknowledge |
|
 |
void stop(void);
 |
i2c stop condition generator |
|
Test.c is a test program written to
demonstrate the use of the I2C functions. with
a serial port connected to uart1 on an atmega64
running at 7.4 Mhz (8 mhz internal RC oscillator
with chip running at 3.3 volts), an i2c eeprom
connected to a user specified port with pins sck and
sda (all defined by modifying the header file
I2C_routines.h) , a terminal open and running at
2400 baud, 8 data bits, 1 stop bit, no parity, type
a letter in the terminal and the avr will get the
first byte out of the eeprom, echo the typed
character back and send the byte from the eeprom.
also important to note is that the 8 mhz calibration
value needs to be stored in EEPROM location 0x000 in
the onboard eeprom for the serial port to work
properly.
|

|