ROHMUSDC / Mbed 2 deprecated ROHMSensorShield_BALLOONGAME

Dependencies:   BLE_API mbed nRF51822

Fork of Nordic_UART_TEMPLATE_ROHM_SHLD1Update by ROHMUSDC

Files at this revision

API Documentation at this revision

Comitter:
kbahar3
Date:
Mon Jun 20 03:00:38 2016 +0000
Parent:
10:aa05fb52aaa3
Commit message:
Added Functionality for both SHLD0 and SHLD1 since these boards contain different pressure sensors

Changed in this revision

Nordic_UART_TEMPLATE.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r aa05fb52aaa3 -r c989bcb5d497 Nordic_UART_TEMPLATE.lib
--- a/Nordic_UART_TEMPLATE.lib	Mon Jun 20 00:32:40 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/ROHMUSDC/code/Nordic_UART_TEMPLATE_ROHM/#eabae2996ecc
diff -r aa05fb52aaa3 -r c989bcb5d497 main.cpp
--- a/main.cpp	Mon Jun 20 00:32:40 2016 +0000
+++ b/main.cpp	Mon Jun 20 03:00:38 2016 +0000
@@ -38,8 +38,10 @@
  *  MBED Repository Link: https://developer.mbed.org/teams/ROHMUSDC/code/ROHMSensorShield_BALLOONGAME/
  */
 
-#define nRF52DevKit
+#define nRF52DevKit         //Comment out and change target to Nordic NRf51822 for DemoBoard.  Comment in and change target to Nordic nRF51-DK for Nordic DK Board (and ROHM SHLD0 or SHLD1)
+#define NRFDK               //Comment out and change target to Nordic NRf51822 for DemoBoard.  Comment in and change target to Nordic nRF51-DK for Nordic DK Board (and ROHM SHLD0 or SHLD1)
 #define Pressure            //BM1383, Barometric Pressure Sensor
+#define BM1383A             //Comment in for SHLD1. Comment out for SHLD0 and DemoBoard.
 
 #include "mbed.h"
 #include "BLEDevice.h"
@@ -53,7 +55,7 @@
 #define ADV_INTERVAL_MS         (1000UL)
 #define UART_BAUD_RATE          (19200UL)
 #define DEVICE_NAME             ("ROHM DEMO  ") // This can be read AFTER connecting to the device.
-#define SHORT_NAME              ("BALLOON1")    // Keep this short: max 8 chars if a 128bit UUID is also advertised.
+#define SHORT_NAME              ("BALLOONK")    // Keep this short: max 8 chars if a 128bit UUID is also advertised.
 #define DEBUG(...)              { m_serial_port.printf(__VA_ARGS__); }
 
 // Function Prototypes
@@ -69,7 +71,12 @@
 UARTService *m_uart_service_ptr;
 DigitalIn   testButton(p20);
 InterruptIn sw4Press(p20);
+#ifdef NRFDK
 I2C         i2c(p30,p7);
+#endif
+#ifndef NRFDK
+I2C         i2c(p7,p30);
+#endif
 bool        RepStart = true;
 bool        NoRepStart = false;
 int         i = 1;
@@ -88,10 +95,18 @@
 char        PWR_OFF[2] = {0x12, 0x00};
 char        SLEEP_OFF[2] = {0x13, 0x01};
 char        SLEEP_ON[2] = {0x13, 0x00};
-char        Mode_Control[2] = {0x14, 0xCA};
 
 char        Press_Content_ReadData[6];
+#ifdef BM1383A
 char        Press_Addr_ReadData =0x1A;
+char        Mode_Control[2] = {0x14, 0xCA};
+#endif
+#ifndef BM1383A
+char        Press_Addr_ReadData =0x1C;
+char        PWR_DOWN[2] = {0x12, 0x01};
+char        SLEEP[2] = {0x13, 0x01};
+char        Mode_Control[2] = {0x14, 0xC4}; 
+#endif
 
 int         BM1383_Temp_highByte;
 int         BM1383_Temp_lowByte;
@@ -224,6 +239,12 @@
     //i2c.write(Press_addr_w, &Mode_Control[0], 2, false);
     #endif
 
+    #ifndef BM1383A
+    i2c.write(Press_addr_w, &PWR_DOWN[0], 2, false);
+    i2c.write(Press_addr_w, &SLEEP[0], 2, false);
+    i2c.write(Press_addr_w, &Mode_Control[0], 2, false);
+    #endif
+    
     //Start BTLE Initialization Section
     m_ble.init();
     m_ble.onDisconnection(disconnectionCallback);
@@ -325,9 +346,11 @@
         if(ReceivedValue.compare(0,4,"CAL0") == 0)
         {
             pressureCurr = 0;
+            #ifdef BM1383A
             i2c.write(Press_addr_w, &PWR_ON[0], 2, false);
             i2c.write(Press_addr_w, &SLEEP_OFF[0], 2, false);
             i2c.write(Press_addr_w, &Mode_Control[0], 2, false);
+            #endif
             for(i = 0; i < 10; i++)
             {
                 #ifdef Pressure
@@ -348,9 +371,11 @@
         else if(ReceivedValue.compare(0,4,"CAL1") == 0)
         {
             pressureCurr = 0;
+            #ifdef BM1383A
             i2c.write(Press_addr_w, &PWR_ON[0], 2, false);
             i2c.write(Press_addr_w, &SLEEP_OFF[0], 2, false);
             i2c.write(Press_addr_w, &Mode_Control[0], 2, false);
+            #endif
             for(i = 0; i < 10; i++)
             {
                 #ifdef Pressure
@@ -375,9 +400,11 @@
             slope = (HeightKnown_Total - HeightBase) / (BM1383_Pres_KnownLevel - BM1383_Pres_0Level);
             yInt = HeightBase - (slope * BM1383_Pres_0Level);
             pressureCurr = 0;
+            #ifdef BM1383A
             i2c.write(Press_addr_w, &PWR_ON[0], 2, false);
             i2c.write(Press_addr_w, &SLEEP_OFF[0], 2, false);
             i2c.write(Press_addr_w, &Mode_Control[0], 2, false);
+            #endif
             for(i = 0; i < 10; i++)
             {
                 #ifdef Pressure