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