Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
i2c.h
Go to the documentation of this file.
1
34#ifndef _I2C_HXX_
35#define _I2C_HXX_
36
37#if defined (__linux__)
38 #include <linux/i2c.h>
39#elif defined (__FreeRTOS__) || defined(ESP_PLATFORM)
40 #include <stdint.h>
42 struct i2c_msg
43 {
44 uint16_t addr;
45 uint16_t flags;
46 #define I2C_M_RD 0x0001
47 uint16_t len;
48 uint8_t *buf;
49 };
50
51 #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
52
54 union i2c_smbus_data {
55 uint8_t byte;
56 uint16_t word;
57 uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
58 /* and one more for user-space compatibility */
59 };
60
61/* i2c_smbus_xfer read or write markers */
62#define I2C_SMBUS_READ 1
63#define I2C_SMBUS_WRITE 0
64
65/* SMBus transaction types (size parameter in the above functions)
66 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
67#define I2C_SMBUS_QUICK 0
68#define I2C_SMBUS_BYTE 1
69#define I2C_SMBUS_BYTE_DATA 2
70#define I2C_SMBUS_WORD_DATA 3
71#define I2C_SMBUS_PROC_CALL 4
72#define I2C_SMBUS_BLOCK_DATA 5
73#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
74#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
75#define I2C_SMBUS_I2C_BLOCK_DATA 8
76#else
77 #error I2C drivers not supported on this OS
78#endif
79
80#endif /* _I2C_HXX_ */