Temperature (cjc0, sensor0) Humidity I2C_0 Accelerometer SPI_0

Fork of ADISense1000_Example_FW by Analog Devices

Revision:
1:982f6f565e14
Parent:
0:76fed7dd9235
diff -r 76fed7dd9235 -r 982f6f565e14 main.cpp
--- a/main.cpp	Thu Jan 25 16:00:23 2018 +0000
+++ b/main.cpp	Fri Aug 24 09:01:59 2018 +0000
@@ -39,12 +39,16 @@
  *****************************************************************************/
 #include "mbed.h"
 #include "inc/adi_sense_api.h"
-#include "inc/adi_sense_1000/adi_sense_1000_api.h"
 #include "inc/adi_sense_log.h"
 #include "common/utils.h"
 
 extern ADI_SENSE_CONFIG config;
 
+ADI_SENSE_RESULT res;
+ADI_SENSE_DEVICE_HANDLE hDevice;
+ADI_SENSE_MEASUREMENT_MODE eMeasurementMode = ADI_SENSE_MEASUREMENT_MODE_NORMAL;
+bool_t bDeviceReady;
+
 /* Change the following pointer to select any of the configurations above */
 static ADI_SENSE_CONFIG *pSelectedConfig = &config;
 
@@ -65,16 +69,10 @@
     },
 };
 
-int main()
+uint8_t adisense1000_boot(void)
 {
-    ADI_SENSE_RESULT res;
-    ADI_SENSE_DEVICE_HANDLE hDevice;
-    ADI_SENSE_MEASUREMENT_MODE eMeasurementMode = ADI_SENSE_MEASUREMENT_MODE_NORMAL;
-    bool_t bDeviceReady;
+   bool_t bDeviceReady;
 
-    /*
-     * Open an ADI Sense device instance.
-     */
     res = adi_sense_Open(0, &connectionInfo, &hDevice);
     if (res != ADI_SENSE_SUCCESS)
     {
@@ -82,9 +80,6 @@
         return res;
     }
 
-    /*
-     * Reset the given ADI Sense device....
-     */
     ADI_SENSE_LOG_INFO("Resetting ADI Sense device, please wait...");
     res = adi_sense_Reset(hDevice);
     if (res != ADI_SENSE_SUCCESS)
@@ -92,9 +87,7 @@
         ADI_SENSE_LOG_ERROR("Failed to reset device");
         return res;
     }
-    /*
-     * ...and wait until the device is ready.
-     */
+
     do {
         wait_ms(100);
         res = adi_sense_GetDeviceReadyState(hDevice, &bDeviceReady);
@@ -106,10 +99,6 @@
     } while (! bDeviceReady);
     ADI_SENSE_LOG_INFO("ADI Sense device ready");
 
-    /*
-     * Write configuration settings to the device registers.
-     * Settings are not applied until adi_sense_ApplyConfigUpdates() is called.
-     */
     ADI_SENSE_LOG_INFO("Setting device configuration");
     res = adi_sense_SetConfig(hDevice, pSelectedConfig);
     if (res != ADI_SENSE_SUCCESS)
@@ -123,23 +112,36 @@
         ADI_SENSE_LOG_ERROR("Failed to apply device configuration");
         return res;
     }
-
-    /*
-     * Kick off the measurement cycle here
-     */
-    ADI_SENSE_LOG_INFO("Configuration completed, starting measurement cycles");
-    utils_runMeasurement(hDevice, eMeasurementMode);
-
-    /*
-     * Clean up and exit
-     */
-    res = adi_sense_Close(hDevice);
-    if (res != ADI_SENSE_SUCCESS)
-    {
-        ADI_SENSE_LOG_ERROR("Failed to close device instance");
-        return res;
-    }
-
     return 0;
 }
 
+void blink_led()
+{
+    DigitalOut led1(LED1);
+    int i=0;
+    for(i=0; i<10; i++) {
+        led1 = !led1;
+        wait(0.5);
+    }
+}
+
+int main()
+{
+    wait(0.5);
+    blink_led();
+    
+    adisense1000_boot();
+    ADI_SENSE_LOG_INFO("Configuration Set Success");
+    wait(0.5);
+    
+    ADI_SENSE_LOG_INFO("~ Get Data\n\r");
+    
+    //temp_comp temp pressure himidity AccX AccY AccZ
+    
+    ADI_SENSE_LOG_INFO("tc_raw\ttc_pro\tt_raw\tt_pro\tp_raw\tp_pro\th_raw\th_pro\tax_raw\tax_pro\tay_raw\tay_pro\taz_raw\taz_pro");
+    //ADI_SENSE_LOG_INFO("tc_pro t_pro h_pro ax_pro ay_pro az_pro");
+    
+    utils_runMeasurement(hDevice, eMeasurementMode);
+    
+}
+