35 #include <pios_i2c_priv.h>
37 #if defined(PIOS_INCLUDE_I2C)
39 #include <sys/ioctl.h>
40 #include <sys/types.h>
43 #include <linux/i2c.h>
44 #include <linux/i2c-dev.h>
46 #define PIOS_I2C_MAGIC 0x63324950
48 struct pios_i2c_adapter {
58 struct pios_i2c_adapter *dev;
60 dev = malloc(
sizeof(*dev));
66 *dev = (
struct pios_i2c_adapter) {
67 .magic = PIOS_I2C_MAGIC,
76 dev->fd = open(path, O_RDWR);
91 struct pios_i2c_adapter *dev = (
struct pios_i2c_adapter *)i2c_id;
101 struct i2c_msg msgs[num_txns];
103 for (
int i = 0;
i < num_txns;
i++) {
104 msgs[
i].addr = txn_list[
i].
addr;
108 msgs[
i].flags = I2C_M_RD;
110 msgs[
i].buf = txn_list[
i].
buf;
111 msgs[
i].len = txn_list[
i].
len;
114 struct i2c_rdwr_ioctl_data msgset = {
121 if (ioctl(dev->fd, I2C_RDWR, &msgset) < 0) {
Main PiOS header to include all the compiled in PiOS options.
Debug helper functions header.
bool PIOS_Mutex_Unlock(struct pios_mutex *mtx)
struct pios_mutex * PIOS_Mutex_Create(void)
int32_t PIOS_I2C_Init(pios_i2c_t *i2c_id, const char *path)
struct pios_i2c_adapter * pios_i2c_t
int32_t PIOS_I2C_Transfer(pios_i2c_t i2c_id, const struct pios_i2c_txn txn_list[], uint32_t num_txns)
static struct pios_mutex * lock
#define PIOS_Assert(test)
#define PIOS_MUTEX_TIMEOUT_MAX
bool PIOS_Mutex_Lock(struct pios_mutex *mtx, uint32_t timeout_ms)