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.

48 lines
1.5 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. #include "espurna.h"
  7. #if I2C_SUPPORT
  8. #if I2C_USE_BRZO
  9. #include <brzo_i2c.h>
  10. #else
  11. #include <Wire.h>
  12. #endif
  13. void i2c_wakeup(uint8_t address);
  14. uint8_t i2c_write_buffer(uint8_t address, uint8_t * buffer, size_t len);
  15. uint8_t i2c_write_uint8(uint8_t address, uint8_t value);
  16. uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value);
  17. uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value1, uint8_t value2);
  18. uint8_t i2c_write_uint16(uint8_t address, uint16_t value);
  19. uint8_t i2c_write_uint16(uint8_t address, uint8_t reg, uint16_t value);
  20. uint8_t i2c_read_uint8(uint8_t address);
  21. uint8_t i2c_read_uint8(uint8_t address, uint8_t reg);
  22. uint16_t i2c_read_uint16(uint8_t address);
  23. uint16_t i2c_read_uint16(uint8_t address, uint8_t reg);
  24. uint16_t i2c_read_uint16_le(uint8_t address, uint8_t reg);
  25. int16_t i2c_read_int16(uint8_t address, uint8_t reg);
  26. int16_t i2c_read_int16_le(uint8_t address, uint8_t reg);
  27. void i2c_read_buffer(uint8_t address, uint8_t * buffer, size_t len);
  28. void i2cScan();
  29. void i2cClearBus();
  30. bool i2cGetLock(unsigned char address);
  31. bool i2cReleaseLock(unsigned char address);
  32. unsigned char i2cFindAndLock(size_t size, unsigned char * addresses);
  33. unsigned char i2cFind(size_t size, unsigned char * addresses, unsigned char &start);
  34. unsigned char i2cFind(size_t size, unsigned char * addresses);
  35. void i2cSetup();
  36. #endif // I2C_SUPPORT == 1