You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2017/04/26 22:41:00 UTC

[12/50] [abbrv] incubator-mynewt-core git commit: No Ticket: Add sensor device creation in NRF52840

No Ticket: Add sensor device creation in NRF52840

- Also, change name of init functiosn so that they
  don't have "slinky_" prefix in them.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/73c8953b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/73c8953b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/73c8953b

Branch: refs/heads/bluetooth5
Commit: 73c8953be37e8e3b3603b4539fa37208199dcfcc
Parents: a1a0647
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Apr 18 18:55:58 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Apr 18 18:55:58 2017 -0700

----------------------------------------------------------------------
 hw/bsp/nrf52840pdk/src/hal_bsp.c | 86 +++++++++++++++++++++++++++++++++++
 hw/bsp/nrf52dk/src/hal_bsp.c     | 14 +++---
 2 files changed, 93 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/73c8953b/hw/bsp/nrf52840pdk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52840pdk/src/hal_bsp.c b/hw/bsp/nrf52840pdk/src/hal_bsp.c
index a0c78b8..bf2dd36 100644
--- a/hw/bsp/nrf52840pdk/src/hal_bsp.c
+++ b/hw/bsp/nrf52840pdk/src/hal_bsp.c
@@ -35,6 +35,36 @@
 #include "uart_hal/uart_hal.h"
 #include "os/os_dev.h"
 #include "bsp.h"
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+#include <lsm303dlhc/lsm303dlhc.h>
+static struct lsm303dlhc lsm303dlhc;
+#endif
+#if MYNEWT_VAL(BNO055_PRESENT)
+#include <bno055/bno055.h>
+#endif
+#if MYNEWT_VAL(TSL2561_PRESENT)
+#include <tsl2561/tsl2561.h>
+#endif
+#if MYNEWT_VAL(TCS34725_PRESENT)
+#include <tcs34725/tcs34725.h>
+#endif
+
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+static struct lsm303dlhc lsm303dlhc;
+#endif
+
+#if MYNEWT_VAL(BNO055_PRESENT)
+static struct bno055 bno055;
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+static struct tsl2561 tsl2561;
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+static struct tcs34725 tcs34725;
+#endif
+
 
 #if MYNEWT_VAL(UART_0)
 static struct uart_dev os_bsp_uart0;
@@ -144,6 +174,61 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
     return cfg_pri;
 }
 
+#if MYNEWT_VAL(LSM303DLHC_PRESENT) || MYNEWT_VAL(BNO055_PRESENT)
+static int
+accel_init(struct os_dev *dev, void *arg)
+{
+   return (0);
+}
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+static int
+light_init(struct os_dev *dev, void *arg)
+{
+    return (0);
+}
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+static int
+color_init(struct os_dev *dev, void *arg)
+{
+    return (0);
+}
+#endif
+
+static void
+sensor_dev_create(void)
+{
+    int rc;
+
+    (void)rc;
+#if MYNEWT_VAL(LSM303DLHC_PRESENT)
+    rc = os_dev_create((struct os_dev *) &lsm303dlhc, "accel0",
+      OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
+    assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(BNO055_PRESENT)
+    rc = os_dev_create((struct os_dev *) &bno055, "accel1",
+      OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
+    assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TSL2561_PRESENT)
+    rc = os_dev_create((struct os_dev *) &tsl2561, "light0",
+      OS_DEV_INIT_PRIMARY, 0, light_init, NULL);
+    assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(TCS34725_PRESENT)
+    rc = os_dev_create((struct os_dev *) &tcs34725, "color0",
+      OS_DEV_INIT_PRIMARY, 0, color_init, NULL);
+    assert(rc == 0);
+#endif
+}
+
 void
 hal_bsp_init(void)
 {
@@ -206,4 +291,5 @@ hal_bsp_init(void)
     assert(rc == 0);
 #endif
 
+    sensor_dev_create();
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/73c8953b/hw/bsp/nrf52dk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/src/hal_bsp.c b/hw/bsp/nrf52dk/src/hal_bsp.c
index 4a2a2a1..c0031b1 100644
--- a/hw/bsp/nrf52dk/src/hal_bsp.c
+++ b/hw/bsp/nrf52dk/src/hal_bsp.c
@@ -182,7 +182,7 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
 
 #if MYNEWT_VAL(LSM303DLHC_PRESENT) || MYNEWT_VAL(BNO055_PRESENT)
 static int
-slinky_accel_init(struct os_dev *dev, void *arg)
+accel_init(struct os_dev *dev, void *arg)
 {
    return (0);
 }
@@ -190,7 +190,7 @@ slinky_accel_init(struct os_dev *dev, void *arg)
 
 #if MYNEWT_VAL(TSL2561_PRESENT)
 static int
-slinky_light_init(struct os_dev *dev, void *arg)
+light_init(struct os_dev *dev, void *arg)
 {
     return (0);
 }
@@ -198,7 +198,7 @@ slinky_light_init(struct os_dev *dev, void *arg)
 
 #if MYNEWT_VAL(TCS34725_PRESENT)
 static int
-slinky_color_init(struct os_dev *dev, void *arg)
+color_init(struct os_dev *dev, void *arg)
 {
     return (0);
 }
@@ -212,25 +212,25 @@ sensor_dev_create(void)
     (void)rc;
 #if MYNEWT_VAL(LSM303DLHC_PRESENT)
     rc = os_dev_create((struct os_dev *) &lsm303dlhc, "accel0",
-      OS_DEV_INIT_PRIMARY, 0, slinky_accel_init, NULL);
+      OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
     assert(rc == 0);
 #endif
 
 #if MYNEWT_VAL(BNO055_PRESENT)
     rc = os_dev_create((struct os_dev *) &bno055, "accel1",
-      OS_DEV_INIT_PRIMARY, 0, slinky_accel_init, NULL);
+      OS_DEV_INIT_PRIMARY, 0, accel_init, NULL);
     assert(rc == 0);
 #endif
 
 #if MYNEWT_VAL(TSL2561_PRESENT)
     rc = os_dev_create((struct os_dev *) &tsl2561, "light0",
-      OS_DEV_INIT_PRIMARY, 0, slinky_light_init, NULL);
+      OS_DEV_INIT_PRIMARY, 0, light_init, NULL);
     assert(rc == 0);
 #endif
 
 #if MYNEWT_VAL(TCS34725_PRESENT)
     rc = os_dev_create((struct os_dev *) &tcs34725, "color0",
-      OS_DEV_INIT_PRIMARY, 0, slinky_color_init, NULL);
+      OS_DEV_INIT_PRIMARY, 0, color_init, NULL);
     assert(rc == 0);
 #endif