Elisa3
|
#include <avr\io.h>
#include <avr\interrupt.h>
#include <inttypes.h>
#include <compat/twi.h>
#include "twimaster.h"
#include "usart.h"
Defines | |
#define | cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) |
#define | sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) |
#define | F_CPU 8000000UL |
#define | SCL_CLOCK 440000L |
Functions | |
void | i2c_close () |
void | i2c_init (void) |
initialize the I2C master interace. Need to be called only once | |
unsigned char | i2c_start (unsigned char address) |
Issues a start condition and sends address and transfer direction. | |
void | i2c_start_wait (unsigned char address) |
Issues a start condition and sends address and transfer direction. | |
unsigned char | i2c_rep_start (unsigned char address) |
Issues a repeated start condition and sends address and transfer direction. | |
void | i2c_stop (void) |
Terminates the data transfer and releases the I2C bus. | |
unsigned char | i2c_write (unsigned char data) |
Send one byte to I2C device. | |
unsigned char | i2c_readAck (void) |
read one byte from the I2C device, request more data from device | |
unsigned char | i2c_readNak (void) |
read one byte from the I2C device, read is followed by a stop condition |
#define cbi | ( | sfr, | |
bit | |||
) | (_SFR_BYTE(sfr) &= ~_BV(bit)) |
#define F_CPU 8000000UL |
#define sbi | ( | sfr, | |
bit | |||
) | (_SFR_BYTE(sfr) |= _BV(bit)) |
#define SCL_CLOCK 440000L |
void i2c_close | ( | ) |
void i2c_init | ( | void | ) |
initialize the I2C master interace. Need to be called only once
void |
unsigned char i2c_readAck | ( | void | ) |
read one byte from the I2C device, request more data from device
unsigned char i2c_readNak | ( | void | ) |
read one byte from the I2C device, read is followed by a stop condition
unsigned char i2c_rep_start | ( | unsigned char | addr | ) |
Issues a repeated start condition and sends address and transfer direction.
addr | address and transfer direction of I2C device |
0 | device accessible |
1 | failed to access device |
unsigned char i2c_start | ( | unsigned char | addr | ) |
Issues a start condition and sends address and transfer direction.
addr | address and transfer direction of I2C device |
0 | device accessible |
1 | failed to access device |
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
addr | address and transfer direction of I2C device |
void i2c_stop | ( | void | ) |
Terminates the data transfer and releases the I2C bus.
void |
unsigned char i2c_write | ( | unsigned char | data | ) |
Send one byte to I2C device.
data | byte to be transfered |
0 | write successful |
1 | write failed |