Vybhav Kadaba / Mbed OS EV-PRO-MW1001_test1

Files at this revision

API Documentation at this revision

Comitter:
Vkadaba
Date:
Thu Jul 25 11:46:20 2019 +0000
Parent:
13:97cb32670539
Child:
15:b5d57daeb7c0
Commit message:
Added deviceInformation function to get the firmware version Id

Changed in this revision

inc/admw_api.h 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
src/admw_1001.c Show annotated file Show diff for this revision Revisions of this file
--- a/inc/admw_api.h	Thu Jul 25 06:38:45 2019 +0000
+++ b/inc/admw_api.h	Thu Jul 25 11:46:20 2019 +0000
@@ -67,6 +67,10 @@
 /*! A handle used in all API functions to identify the ADMW device. */
 
 typedef void* ADMW_DEVICE_HANDLE;
+
+#define ADMW_FORMATTED_VERSION_SIZE     11u
+#define ADMW_VERSION_REG_VAL_SIZE       4u
+#define ADMW1001_FIRMWARE_VERSION_DEFAULT "00.00.0000"
 #define SPI_BUFFER_SIZE                        100u
 
 #define SFL_READ_STATUS_HDR_SIZE               14u
@@ -677,6 +681,7 @@
     ADMW_DEVICE_HANDLE hDevice,
     bool *pbCommandRunning);
 
+ADMW_RESULT deviceInformation(ADMW_DEVICE_HANDLE hDevice);
 #ifdef __cplusplus
 }
 #endif
--- a/main.cpp	Thu Jul 25 06:38:45 2019 +0000
+++ b/main.cpp	Thu Jul 25 11:46:20 2019 +0000
@@ -78,7 +78,7 @@
 #include "admw_log.h"
 #include "common/utils.h"
 #include "common/platform.h"
-
+#include "admw1001/ADMW1001_REGISTERS.h"
 
 
 
@@ -97,6 +97,7 @@
 
 static ADMW_CONNECTION connectionInfo = PLATFORM_CONNECTION_INFO;
 
+
 int main()
 {
     ADMW_RESULT res;
@@ -114,7 +115,7 @@
         ADMW_LOG_ERROR("Failed to open device instance");
         return res;
     }
-
+    
     /*
      * Reset the given ADI Sense device....
      */
@@ -160,6 +161,7 @@
      * Check device status after updating the configuration
      */
     res = admw_GetStatus(hDevice, &status);
+    deviceInformation(hDevice);
     if (res != ADMW_SUCCESS)
     {
         ADMW_LOG_ERROR("Failed to retrieve device status");
--- a/src/admw_1001.c	Thu Jul 25 06:38:45 2019 +0000
+++ b/src/admw_1001.c	Thu Jul 25 11:46:20 2019 +0000
@@ -2697,6 +2697,28 @@
 
     return ADMW_SUCCESS;
 }
+
+ADMW_RESULT deviceInformation(ADMW_DEVICE_HANDLE hDevice)
+{
+    uint16_t nAddress = REG_CORE_REVISION;
+    char nData[ADMW_VERSION_REG_VAL_SIZE];  //4 Bytes of version register data
+    ADMW_RESULT res;
+    res=admw1001_ReadRegister(hDevice,nAddress,nData,sizeof(nData));
+    if(res != ADMW_SUCCESS)
+    {
+        //if reading version register failed, sending 00.00.0000 as ADMW1001 firmware version
+        //strcat(nData, ADMW1001_FIRMWARE_VERSION_DEFAULT);
+        ADMW_LOG_INFO("Firmware Version Id is %X.%X",nData[2],nData[0]);
+    }
+    else
+    {
+        char buffer[ADMW_FORMATTED_VERSION_SIZE]; //00.00.0000  8 digits + 2 Bytes "." + one null character at the end
+        strcat(nData, buffer);
+        ADMW_LOG_INFO("Firmware Version Id is %X.%X",nData[2],nData[0]);
+    }
+    return ADMW_SUCCESS;
+} 
+   
 ADMW_RESULT admw1001_getFirmwareStatus(
     ADMW_DEVICE_HANDLE   const hDevice,
     bool                  * const bFirmwareStatus)
@@ -2842,4 +2864,4 @@
     }
 
     return eRet;
-}
+}
\ No newline at end of file