You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
567 B

6 years ago
  1. #ifndef I2C_H
  2. #define I2C_H
  3. #include <stdint.h>
  4. #ifndef F_CPU
  5. #define F_CPU 16000000UL
  6. #endif
  7. #define I2C_READ 1
  8. #define I2C_WRITE 0
  9. #define I2C_ACK 1
  10. #define I2C_NACK 0
  11. #define SLAVE_BUFFER_SIZE 0x10
  12. // i2c SCL clock frequency
  13. #define SCL_CLOCK 100000L
  14. extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
  15. void i2c_master_init(void);
  16. uint8_t i2c_master_start(uint8_t address);
  17. void i2c_master_stop(void);
  18. uint8_t i2c_master_write(uint8_t data);
  19. uint8_t i2c_master_read(int);
  20. void i2c_reset_state(void);
  21. void i2c_slave_init(uint8_t address);
  22. #endif