[RFC PATCH v2 2/5] i2c: add device config helpers


Vlad Dogaru <vlad.dogaru@...>
 

Add some macros that drivers and applications can use in describing I2C
clients.

Change-Id: Ic7af97804e88ed3b9d4f68f9ac358a425f4cc17c
Signed-off-by: Vlad Dogaru <vlad.dogaru(a)intel.com>
---
include/i2c.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/include/i2c.h b/include/i2c.h
index b772871..1f22363 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -411,6 +411,22 @@ static inline int i2c_resume(struct device *dev)
return api->resume(dev);
}

+struct i2c_client_config {
+ char *i2c_master;
+ uint16_t i2c_addr;
+};
+
+#define I2C_DECLARE_CLIENT_CONFIG struct i2c_client_config i2c_client
+
+#define I2C_CLIENT(_master, _addr) \
+ .i2c_client = { \
+ .i2c_master = (_master), \
+ .i2c_addr = (_addr), \
+ }
+
+#define I2C_GET_MASTER(_conf) ((_conf)->i2c_client.i2c_master)
+#define I2C_GET_ADDR(_conf) ((_conf)->i2c_client.i2c_addr)
+
#ifdef __cplusplus
}
#endif
--
1.9.1

Join devel@lists.zephyrproject.org to automatically receive all group messages.