i2c.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef I2C_H
  2. #define I2C_H
  3. /**** I2C bitbanging support ****/
  4. // clock line port
  5. //#define SCLPORT PORTB // i2c clock port
  6. #define SCLDDR DDRC // i2c clock port direction
  7. #define SCLPIN PINC
  8. // data line port
  9. //#define SDAPORT PORTB // i2c data port
  10. #define SDADDR DDRC // i2c data port direction
  11. #define SDAPIN PINC // i2c data port input
  12. // pin assignments
  13. #define SCL _BV(PC0) // i2c clock pin
  14. #define SDA _BV(PC1) // i2c data pin
  15. // defines and constants
  16. #define READ 0x01 // I2C READ bit
  17. // functions
  18. // initialize I2C interface pins
  19. //void i2cInit(void);
  20. // send I2C data to <device> register
  21. void i2cSend(unsigned char reg, unsigned char length, unsigned char *data, unsigned char device);
  22. // receive I2C data from <device> register
  23. void i2cReceive(unsigned char reg, unsigned char length, unsigned char *data, unsigned char device);
  24. unsigned char i2cPutbyte(unsigned char b);
  25. unsigned char i2cGetbyte(unsigned char notlast);
  26. void istart(void);
  27. void istop(void);
  28. #endif