项目作者: jack-greenberg

项目描述 :
I2C Library written in pure AVR C.
高级语言: C
项目地址: git://github.com/jack-greenberg/i2c2.git
创建时间: 2020-04-10T04:14:12Z
项目社区:https://github.com/jack-greenberg/i2c2

开源协议:

下载


I2C2

A light-weight I2C library written in C.

Installation

  1. $ git clone https://github.com/jack-greenberg/i2c2.git
  2. $ cd i2c2
  3. $ make

Usage

Edit i2c.h to update the SDA and SCL macros to match the pins on your MCU.

  1. #define SDA PB2
  2. #define SCL PB3

Then, in your file, you can use the functions.

  1. int main(void) {
  2. init_I2C(BITRATE_STD); // Initializes timer and interrupts at 100kHz (use BITRATE_FULL for 400kHz)
  3. start_I2C(0x41, 0x81, WRITE); // Sends start condition and transmits address and register of secondary address
  4. transmit_I2C('H');
  5. transmit_I2C('e');
  6. // ...
  7. transmit_I2C('d');
  8. stop_I2C();
  9. return 0;
  10. }

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

To-Do

  • Transmit from primary to secondary
  • Implement break when read_ACK_NACK() returns NACK
  • Read from secondary on primary
    • Implement repeated start
    • read_I2C()
    • send_ACK()
    • send_NACK()
  • Set up clearer guidelines about timers
  • Allow for using Timer0 or Timer1
  • Add documentation of results from Analog Discovery
  • Add more details to Usage
  • Make Makefile more flexible

License

MIT