rakha asyrofi / Mbed 2 deprecated nRF51_ADXL3xx

Dependencies:   ADXL362_v3 BLE_API mbed nRF51822

Fork of BLENano_SimpleTemplate_adxl362_170813 by Jun ADI

Files at this revision

API Documentation at this revision

Comitter:
Jun_adi
Date:
Thu Aug 03 05:19:36 2017 +0000
Parent:
5:95238da08cee
Child:
7:2d9b5491b2d3
Commit message:
ADXL362 test

Changed in this revision

ADXL362.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADXL362.lib	Thu Aug 03 05:19:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/Jun_adi/code/ADXL362/#828314a3d09b
--- a/main.cpp	Sat May 20 15:29:47 2017 +0000
+++ b/main.cpp	Thu Aug 03 05:19:36 2017 +0000
@@ -32,17 +32,24 @@
 //------------------------------------------------------------ 
 #include "mbed.h"
 #include "ble/BLE.h"
-
+#include "ADXL362.h"
+ 
 
 //------------------------------------------------------------
 //Definition
 //------------------------------------------------------------ 
 #define TXRX_BUF_LEN 20                     //max 20[byte]
-#define DEVICE_LOCAL_NAME "BlueJelly"     
-#define ADVERTISING_INTERVAL 160            //160 * 0.625[ms] = 100[ms]
-#define TICKER_TIME 200000                  //200000[us] = 200[ms]
+#define DEVICE_LOCAL_NAME "ADXL362"         //Change Name
+#define ADVERTISING_INTERVAL 16            //16 * 0.625[ms] = 10[ms]
+#define TICKER_TIME 10000                  //10000[us] = 10[ms]
 #define DIGITAL_OUT_PIN P0_9
-#define ANALOG_IN_PIN   P0_4
+//#define ANALOG_IN_PIN   P0_4
+
+//Set Pin
+#define CS P0_10
+#define MOSI P0_9
+#define MISO P0_11
+#define SCK P0_8
 
 
 //------------------------------------------------------------
@@ -50,8 +57,10 @@
 //------------------------------------------------------------ 
 BLE ble;
 DigitalOut      LED_SET(DIGITAL_OUT_PIN);
-AnalogIn        ANALOG(ANALOG_IN_PIN);
+//AnalogIn        ANALOG(ANALOG_IN_PIN);
 
+//Set pin at header file.(see ADXL362.h line185)
+ADXL362 adxl362(CS, MOSI, MISO, SCK);
 
 //------------------------------------------------------------
 //Service & Characteristic Setting
@@ -110,8 +119,11 @@
 //======================================================================
 //onTimeout
 //======================================================================
+
+/*
 void m_status_check_handle(void)
 {   
+
     uint8_t buf[2];
 
     //Read Analog port
@@ -123,7 +135,7 @@
     //Send out
     ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 2); 
 }
-
+*/
 
 //======================================================================
 //convert reverse UUID
@@ -142,11 +154,17 @@
 //======================================================================
 int main(void)
 {
+    //ADXL362 Reset
+    adxl362.reset();
+    wait_ms(600);      // we need to wait at least 500ms after ADXL362 reset
+    adxl362.set_mode(ADXL362::MEASUREMENT);
+
+    
     uint8_t base_uuid_rev[16];
 
     //Timer Setting [us]
     Ticker ticker;
-    ticker.attach_us(m_status_check_handle, TICKER_TIME);
+    //ticker.attach_us(m_status_check_handle, TICKER_TIME);
     
     //BLE init
     ble.init();
@@ -187,6 +205,17 @@
     //------------------------------------------------------------
     while(1)
     {
+        //uint8_t x,y,z;
+        uint8_t x[1];
+        x[0] = adxl362.scanx_u8();
+        //y=adxl362.scany_u8();
+        //z=adxl362.scanz_u8();
+        //printf("x = %x y = %x z = %x\r\n",x,y,z);
+        //wait_ms(10);
+    
+        //Send out
+        ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), x, 1); 
+        
         ble.waitForEvent(); 
     }
 }
\ No newline at end of file