2018-07-12 15:55:38 +00:00
|
|
|
//swi2c.h
|
2017-08-17 13:23:34 +00:00
|
|
|
#ifndef SWI2C_H
|
|
|
|
#define SWI2C_H
|
|
|
|
|
2018-07-12 15:55:38 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif //defined(__cplusplus)
|
|
|
|
|
2017-08-17 13:23:34 +00:00
|
|
|
//initialize
|
2018-07-12 15:55:38 +00:00
|
|
|
extern void swi2c_init(void);
|
2017-08-17 13:23:34 +00:00
|
|
|
|
|
|
|
//check device address acknowledge
|
2018-07-12 15:55:38 +00:00
|
|
|
extern uint8_t swi2c_check(uint8_t dev_addr);
|
2017-08-17 13:23:34 +00:00
|
|
|
|
|
|
|
//read write functions - 8bit address (most i2c chips)
|
|
|
|
#ifdef SWI2C_A8
|
2018-07-12 15:55:38 +00:00
|
|
|
extern uint8_t swi2c_readByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte);
|
|
|
|
extern uint8_t swi2c_writeByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte);
|
2017-08-17 13:23:34 +00:00
|
|
|
#endif //SWI2C_A8
|
|
|
|
|
|
|
|
//read write functions - 16bit address (e.g. serial eeprom AT24C256)
|
|
|
|
#ifdef SWI2C_A16
|
2018-07-12 15:55:38 +00:00
|
|
|
extern uint8_t swi2c_readByte_A16(uint8_t dev_addr, uint16_t addr, uint8_t* pbyte);
|
|
|
|
extern uint8_t swi2c_writeByte_A16(uint8_t dev_addr, uint16_t addr, uint8_t* pbyte);
|
2017-08-17 13:23:34 +00:00
|
|
|
#endif //SWI2C_A16
|
|
|
|
|
2018-07-12 15:55:38 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif //defined(__cplusplus)
|
|
|
|
|
2017-08-17 13:23:34 +00:00
|
|
|
#endif //SWI2C_H
|