m2mb API docs  25.21.002
m2mb API sets documentation
m2mb_i2c.h
Go to the documentation of this file.
1 /*===============================================================================================*/
2 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
31 #ifndef M2M_M2MB_I2C_API_H
32 #define M2M_M2MB_I2C_API_H
33 
34 
35 
36 /* Global declarations ==========================================================================*/
37 #ifndef NULL
38 #define NULL 0
39 #endif
40 
41 #define I2C_M_WR 0x0000 /* write data, from master to slave */
42 #define I2C_M_RD 0x0001 /* read data, from slave to master */
43 
44 /* Global enums ==============================================================================*/
45 
46 enum M2MB_I2C_IOCTL_REQUEST
47 {
48  M2MB_I2C_IOCTL_SET_CFG, /* set i2c device configuration */
49  M2MB_I2C_IOCTL_GET_CFG, /* get i2c device configuration */
50  M2MB_I2C_IOCTL_RDWR /* i2c combined format */
51 };
52 
53 /* Global typedefs ==============================================================================*/
54 
55 typedef struct
56 {
57  UINT16 flags; /* I2C_M_WR or I2C_M_RD*/
58  UINT16 len; /* msg length */
59  UINT8 *buf; /* msg data */
60 } M2MB_I2C_MSG;
61 
62 /* This is the structure as used in the I2C_RDWR ioctl call */
63 typedef struct
64 {
65  M2MB_I2C_MSG *msgs; /* pointers to i2c_msgs */
66  UINT32 nmsgs; /* number of i2c_msgs: 1 if only a write or a read operation is performed; 2 if both operations are performed */
68 
69 /* I2C device configuration struct */
70 typedef struct
71 {
72  UINT8 sdaPin;
73  UINT8 sclPin;
74  UINT8 registerId;
75  M2MB_I2C_RDWR_IOCTL_DATA *rw_param;
77 
78 /* Global functions =============================================================================*/
79 
80 /*-----------------------------------------------------------------------------------------------*/
104 /*-----------------------------------------------------------------------------------------------*/
105 
106 INT32 m2mb_i2c_open( const CHAR *path, INT32 flags, ... );
107 
108 
109 /*-----------------------------------------------------------------------------------------------*/
129 /*-----------------------------------------------------------------------------------------------*/
130 INT32 m2mb_i2c_close( INT32 fd );
131 
132 
133 /*-----------------------------------------------------------------------------------------------*/
213 /*-----------------------------------------------------------------------------------------------*/
214 INT32 m2mb_i2c_ioctl( INT32 fd, INT32 request, ... );
215 
216 
217 /*-----------------------------------------------------------------------------------------------*/
248 /*-----------------------------------------------------------------------------------------------*/
249 SSIZE_T m2mb_i2c_read( INT32 fd, void *buf, SIZE_T nbyte );
250 
251 
252 /*-----------------------------------------------------------------------------------------------*/
281 /*-----------------------------------------------------------------------------------------------*/
282 SSIZE_T m2mb_i2c_write( INT32 fd, const void *buf, SIZE_T nbyte );
283 
284 
285 #endif /* M2M_M2MB_I2C_API_H */
286 
m2mb_i2c_write
SSIZE_T m2mb_i2c_write(INT32 fd, const void *buf, SIZE_T nbyte)
write to an I2C device
m2mb_i2c_close
INT32 m2mb_i2c_close(INT32 fd)
close an I2C device
M2MB_I2C_RDWR_IOCTL_DATA
Definition: m2mb_i2c.h:63
M2MB_I2C_MSG
Definition: m2mb_i2c.h:55
m2mb_i2c_open
INT32 m2mb_i2c_open(const CHAR *path, INT32 flags,...)
open an I2C device
m2mb_i2c_ioctl
INT32 m2mb_i2c_ioctl(INT32 fd, INT32 request,...)
configure, read from and/or write to an I2C device
M2MB_I2C_CFG_T
Definition: m2mb_i2c.h:70
m2mb_i2c_read
SSIZE_T m2mb_i2c_read(INT32 fd, void *buf, SIZE_T nbyte)
read from an I2C device