You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2018/12/03 12:42:23 UTC

[mynewt-core] 12/15: hw/battery: Add bus driver support

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 6b9a7d78ac166b6afa6c32b2c0bc69b89ac119ef
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Nov 23 17:43:02 2018 +0100

    hw/battery: Add bus driver support
---
 hw/battery/include/battery/battery_drv.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/hw/battery/include/battery/battery_drv.h b/hw/battery/include/battery/battery_drv.h
index ab2713c..2731761 100644
--- a/hw/battery/include/battery/battery_drv.h
+++ b/hw/battery/include/battery/battery_drv.h
@@ -29,6 +29,11 @@
 #define __BATTERY_DRV_H__
 
 #include "os/mynewt.h"
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include "bus/bus_driver.h"
+#include "bus/i2c.h"
+#include "bus/spi.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -140,8 +145,17 @@ struct battery_driver_functions {
 };
 
 struct battery_driver {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+    /* Underlying bus node */
+    union {
+        struct os_dev dev;
+        struct bus_i2c_node i2c_node;
+        struct bus_spi_node spi_node;
+    };
+#else
     /* Underlying OS device */
     struct os_dev dev;
+#endif
 
     const struct battery_driver_functions *bd_funcs;
     /* Array of properties supported by this battery */