no-OS
no_os_i2c.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef _NO_OS_I2C_H_
41 #define _NO_OS_I2C_H_
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <stdint.h>
48 
49 /******************************************************************************/
50 /*************************** Types Declarations *******************************/
51 /******************************************************************************/
52 
59 
66  uint32_t device_id;
68  uint32_t max_speed_hz;
70  uint8_t slave_address;
74  void *extra;
75 };
76 
83  uint32_t device_id;
85  uint32_t max_speed_hz;
87  uint8_t slave_address;
91  void *extra;
92 };
93 
101  int32_t (*i2c_ops_init)(struct no_os_i2c_desc **,
102  const struct no_os_i2c_init_param *);
104  int32_t (*i2c_ops_write)(struct no_os_i2c_desc *, uint8_t *, uint8_t, uint8_t);
106  int32_t (*i2c_ops_read)(struct no_os_i2c_desc *, uint8_t *, uint8_t, uint8_t);
108  int32_t (*i2c_ops_remove)(struct no_os_i2c_desc *);
109 };
110 
111 /******************************************************************************/
112 /************************ Functions Declarations ******************************/
113 /******************************************************************************/
114 
115 /* Initialize the I2C communication peripheral. */
116 int32_t no_os_i2c_init(struct no_os_i2c_desc **desc,
117  const struct no_os_i2c_init_param *param);
118 
119 /* Free the resources allocated by no_os_i2c_init(). */
120 int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc);
121 
122 /* Write data to a slave device. */
123 int32_t no_os_i2c_write(struct no_os_i2c_desc *desc,
124  uint8_t *data,
125  uint8_t bytes_number,
126  uint8_t stop_bit);
127 
128 /* Read data from a slave device. */
129 int32_t no_os_i2c_read(struct no_os_i2c_desc *desc,
130  uint8_t *data,
131  uint8_t bytes_number,
132  uint8_t stop_bit);
133 
134 #endif // _NO_OS_I2C_H_
no_os_i2c_write
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:85
no_os_i2c_init
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:51
no_os_i2c_platform_ops::i2c_ops_read
int32_t(* i2c_ops_read)(struct no_os_i2c_desc *, uint8_t *, uint8_t, uint8_t)
Definition: no_os_i2c.h:106
no_os_i2c_init_param::slave_address
uint8_t slave_address
Definition: no_os_i2c.h:70
no_os_i2c_remove
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:70
no_os_i2c_platform_ops::i2c_ops_write
int32_t(* i2c_ops_write)(struct no_os_i2c_desc *, uint8_t *, uint8_t, uint8_t)
Definition: no_os_i2c.h:104
no_os_i2c_desc::device_id
uint32_t device_id
Definition: no_os_i2c.h:83
no_os_i2c_init_param::extra
void * extra
Definition: no_os_i2c.h:74
no_os_i2c_desc::slave_address
uint8_t slave_address
Definition: no_os_i2c.h:87
no_os_i2c_init_param::max_speed_hz
uint32_t max_speed_hz
Definition: no_os_i2c.h:68
no_os_i2c_desc::max_speed_hz
uint32_t max_speed_hz
Definition: no_os_i2c.h:85
no_os_i2c_platform_ops
Structure holding I2C function pointers that point to the platform specific function.
Definition: no_os_i2c.h:99
no_os_i2c_platform_ops::i2c_ops_init
int32_t(* i2c_ops_init)(struct no_os_i2c_desc **, const struct no_os_i2c_init_param *)
Definition: no_os_i2c.h:101
no_os_i2c_desc::platform_ops
const struct no_os_i2c_platform_ops * platform_ops
Definition: no_os_i2c.h:89
no_os_i2c_desc
Structure holding I2C descriptor.
Definition: no_os_i2c.h:81
no_os_i2c_read
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:104
no_os_i2c_platform_ops::i2c_ops_remove
int32_t(* i2c_ops_remove)(struct no_os_i2c_desc *)
Definition: no_os_i2c.h:108
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
no_os_i2c_init_param::platform_ops
const struct no_os_i2c_platform_ops * platform_ops
Definition: no_os_i2c.h:72
no_os_i2c_desc::extra
void * extra
Definition: no_os_i2c.h:91
no_os_i2c_init_param::device_id
uint32_t device_id
Definition: no_os_i2c.h:66