i2c.h
浏览该文件的文档.
1 /*
2  * Copyright (C) 2020-2021 Alibaba Group Holding Limited
3  */
4 
5 #ifndef AOS_I2C_H
6 #define AOS_I2C_H
7 
8 #include <aos/device.h>
9 
18 #define AOS_I2C_MCFG_TX ((uint32_t)0x0 << 0)
19 #define AOS_I2C_MCFG_RX ((uint32_t)0x1 << 0)
20 #define AOS_I2C_MCFG_ADDR_7 ((uint32_t)0x0 << 1)
21 #define AOS_I2C_MCFG_ADDR_10 ((uint32_t)0x1 << 1)
22 
23 typedef aos_dev_ref_t aos_i2c_ref_t;
24 
25 typedef struct {
26  uint32_t cfg;
27  uint16_t addr;
28  size_t count;
29  void *buf;
31 
32 #define AOS_I2C_MSG_INIT_VAL \
33  { \
34  .cfg = 0, \
35  .addr = 0, \
36  .count = 0, \
37  .buf = NULL, \
38  }
39 
40 #define aos_i2c_msg_init(x) do { *(x) = (aos_i2c_msg_t)AOS_I2C_MSG_INIT_VAL; } while (0)
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
66 aos_status_t aos_i2c_transfer(aos_i2c_ref_t *ref, const aos_i2c_msg_t *msgs, size_t num_msgs);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
74 #endif /* AOS_I2C_H */
aos_status_t aos_i2c_transfer(aos_i2c_ref_t *ref, const aos_i2c_msg_t *msgs, size_t num_msgs)
Synchronous I2C data transfer.
void aos_i2c_put(aos_i2c_ref_t *ref)
Release a I2C device.
aos_status_t aos_i2c_get(aos_i2c_ref_t *ref, uint32_t id)
Get a I2C device.
aos_dev_ref_t aos_i2c_ref_t
Definition: i2c.h:23
int32_t aos_status_t
Definition: kernel.h:185
uint16_t addr
Definition: i2c.h:27
void * buf
Definition: i2c.h:29
uint32_t cfg
Definition: i2c.h:26
size_t count
Definition: i2c.h:28