swi2c.h 887 B

1234567891011121314151617181920212223242526272829303132333435
  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. //check device address acknowledge
  12. extern uint8_t swi2c_check(uint8_t dev_addr);
  13. //read write functions - 8bit address (most i2c chips)
  14. #ifdef SWI2C_A8
  15. extern uint8_t swi2c_readByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte);
  16. extern uint8_t swi2c_writeByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte);
  17. #endif //SWI2C_A8
  18. //read write functions - 16bit address (e.g. serial eeprom AT24C256)
  19. #ifdef SWI2C_A16
  20. extern uint8_t swi2c_readByte_A16(uint8_t dev_addr, uint16_t addr, uint8_t* pbyte);
  21. extern uint8_t swi2c_writeByte_A16(uint8_t dev_addr, uint16_t addr, uint8_t* pbyte);
  22. #endif //SWI2C_A16
  23. #if defined(__cplusplus)
  24. }
  25. #endif //defined(__cplusplus)
  26. #endif //SWI2C_H