Fork of the espurna firmware for `mhsw` switches
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.

42 lines
1.3 KiB

  1. /*
  2. I2C MODULE
  3. Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. #pragma once
  6. #if I2C_SUPPORT
  7. #if I2C_USE_BRZO
  8. #include <brzo_i2c.h>
  9. #else
  10. #include <Wire.h>
  11. #endif
  12. void i2c_wakeup(uint8_t address);
  13. uint8_t i2c_write_buffer(uint8_t address, uint8_t * buffer, size_t len);
  14. uint8_t i2c_write_uint8(uint8_t address, uint8_t value);
  15. uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value);
  16. uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value1, uint8_t value2);
  17. uint8_t i2c_write_uint16(uint8_t address, uint16_t value);
  18. uint8_t i2c_write_uint16(uint8_t address, uint8_t reg, uint16_t value);
  19. uint8_t i2c_read_uint8(uint8_t address);
  20. uint8_t i2c_read_uint8(uint8_t address, uint8_t reg);
  21. uint16_t i2c_read_uint16(uint8_t address);
  22. uint16_t i2c_read_uint16(uint8_t address, uint8_t reg);
  23. uint16_t i2c_read_uint16_le(uint8_t address, uint8_t reg);
  24. int16_t i2c_read_int16(uint8_t address, uint8_t reg);
  25. int16_t i2c_read_int16_le(uint8_t address, uint8_t reg);
  26. void i2c_read_buffer(uint8_t address, uint8_t * buffer, size_t len);
  27. void i2cScan();
  28. void i2cClearBus();
  29. bool i2cGetLock(unsigned char address);
  30. bool i2cReleaseLock(unsigned char address);
  31. unsigned char i2cFindAndLock(size_t size, unsigned char * addresses);
  32. #endif // I2C_SUPPORT == 1