swi2c.h 935 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //swi2c.h
  2. #ifndef SWI2C_H
  3. #define SWI2C_H
  4. #include <inttypes.h>
  5. #include "config.h"
  6. #if defined(__cplusplus)
  7. extern "C" {
  8. #endif //defined(__cplusplus)
  9. //initialize
  10. extern void swi2c_init(void);
  11. //deinit pins
  12. extern void swi2c_disable(void);
  13. //check device address acknowledge
  14. extern uint8_t swi2c_check(uint8_t dev_addr);
  15. //read write functions - 8bit address (most i2c chips)
  16. #ifdef SWI2C_A8
  17. extern uint8_t swi2c_readByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte);
  18. extern uint8_t swi2c_writeByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte);
  19. #endif //SWI2C_A8
  20. //read write functions - 16bit address (e.g. serial eeprom AT24C256)
  21. #ifdef SWI2C_A16
  22. extern uint8_t swi2c_readByte_A16(uint8_t dev_addr, uint16_t addr, uint8_t* pbyte);
  23. extern uint8_t swi2c_writeByte_A16(uint8_t dev_addr, uint16_t addr, uint8_t* pbyte);
  24. #endif //SWI2C_A16
  25. #if defined(__cplusplus)
  26. }
  27. #endif //defined(__cplusplus)
  28. #endif //SWI2C_H