#include <I2c.h>
Public Member Functions | |
void | init (void) |
unsigned char | readByte (void) |
unsigned char | readByteWithoutAck (void) |
void | sendStart (void) |
void | sendStop (void) |
void | writeByte (unsigned char _byte) |
Definition at line 11 of file I2c.h.
void I2c::init | ( | void | ) |
unsigned char I2c::readByte | ( | void | ) |
Definition at line 55 of file I2c.c.
Referenced by Ram::readBytes().
00056 { 00057 00058 TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA); // 00059 while(!(TWCR & (1<<TWINT))); // wait till ready 00060 return TWDR; // data is in TWDR 00061 00062 }
unsigned char I2c::readByteWithoutAck | ( | void | ) |
Definition at line 67 of file I2c.c.
Referenced by Ram::readBytes().
00068 { 00069 00070 TWCR = (1 << TWINT) | (1 << TWEN); // 00071 while(!(TWCR & (1<<TWINT))); // wait till ready 00072 return TWDR; // data is in TWDR 00073 00074 }
void I2c::sendStart | ( | void | ) |
Definition at line 19 of file I2c.c.
Referenced by Ram::readBytes(), and Ram::writeBytes().
00020 { 00021 00022 TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); // start condition 00023 while(!(TWCR & (1<<TWINT))); // wait for acknowledge 00024 00025 }
void I2c::sendStop | ( | void | ) |
Definition at line 31 of file I2c.c.
Referenced by Ram::readBytes(), and Ram::writeBytes().
00032 { 00033 00034 TWCR = (1 << TWINT) | (1 << TWSTO) | (1 << TWEN); // stop condition =0; 00035 00036 }
void I2c::writeByte | ( | unsigned char | _byte | ) |
Definition at line 42 of file I2c.c.
Referenced by Ram::readBytes(), and Ram::writeBytes().
00043 { 00044 00045 //TWDR = 0x90; // Byte 00046 TWDR = _byte; // Byte 00047 TWCR = (1 << TWINT) | (1 << TWEN); // send 00048 while(!(TWCR & (1<<TWINT))); // wait until ready 00049 00050 }