Official support library for using mbed as a programmable coprocessor in the Innomatix DAP-III+ telematics platform

Revision:
0:b9e1003fbee7
Child:
1:c7920c8bc557
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Main.cpp	Fri Apr 15 18:35:31 2016 +0000
@@ -0,0 +1,107 @@
+/*******************************************************************
+ *
+ *  File: main.cpp
+ *
+ *  Description: Example of using Innomatix Coprocessor Support functionality
+ *
+ *  Copyright 2015 Innomatix, LLC., All Rights Reserved
+ *
+ *  THIS DOCUMENT AND ITS CONTENTS ARE INTELLECTUAL PROPERTY
+ *  OF INNOMATIX, LLC.  ANY DUPLICATION IN PART OR WHOLE
+ *  WITHOUT PRIOR WRITTEN CONSENT IS STRICTLY PROHIBITED.
+ *
+ *******************************************************************/
+#include "mbed.h"
+
+#include "UpdateClientAPI.h"
+#include "RemoteDataStoreAPI.h"
+#include "InnomatixCanAPI.h"
+#include "InnomatixMeta.h"
+
+#define APPVERS       "1.0.2"
+#define APPDESC       "Coprocessor example application"
+
+
+// Create variables using the metadata macros to embed metadata the in the compiled
+// application.  When the application is uploaded to the InnomatixData host,
+// the host will scan the file and extract the metadata info.
+const char *UserApplicationVersion = TFVERSION( APPVERS );
+const char *UserApplicationDescription = TFDESCRIPTION( APPDESC );
+
+
+
+extern "C" void mbed_reset();
+extern void DoExample( char *zVersion );
+
+
+/*************************************************************************/
+void SystemUpdate()
+{
+	UpdateStatus_e eUpdateResult = statusNoUpdate;
+	int count = 0;
+
+    /*====================================================================*/
+    // UpdateInit params are not used by the MBED implementation
+    eUpdateResult = UpdateInit( "usb", 0 );
+    printf( "Innomatix Update API initialization: %s\r\n", (statusSuccess == eUpdateResult ? "INITIALIZED" : "FAILED") );
+
+    /*====================================================================*/
+    if( statusSuccess == eUpdateResult )
+    {
+		printf( "Innomatix Coprocessor Checking for Firmware Update\r\n" );
+
+        // The coprocessor gets to this point much quicker than the DAP
+        // gets started and launches the coprocessor update server, we'll
+        // wait here until he is ready.
+        while( count < 15 )
+        {
+            eUpdateResult = PerformUpdate( 1000 );
+            if( statusNoConnection == eUpdateResult )
+            {
+                // timeout connecting to server, try again 
+                count++;
+            }else if( statusSuccess == eUpdateResult )
+            {
+                printf( "    Update performed, restarting\r\n" );
+                wait_ms( 1000 );
+                mbed_reset();
+                break;
+            }else
+            {
+                printf( "    Update skipped, reason: %s\r\n", UpdateStatusNames[ eUpdateResult ] );
+				break;
+            }
+        }
+        UpdateClose();
+    }
+}
+
+
+/*************************************************************************/
+// Only need to define this so that we can change the baud rate
+// Else the default baud rate on the USB console is 9600
+Serial console(USBTX, USBRX);
+
+/*************************************************************************/
+int main()
+{
+    char str[ 128 ] = {0};
+    int count = 0;
+
+    console.baud(115200);
+
+    printf( "===========================================\r\n" );
+    printf( "Starting Coprocessor Support Example App\r\n" );
+    printf( "Built at %s on %s\r\n", __TIME__, __DATE__ );
+    printf( "Version: %s\r\n", APPVERS );
+    printf( "Description: %s\r\n", APPDESC );
+    printf( "===========================================\r\n" );
+
+    SystemUpdate();
+      
+    DoExample( APPVERS );
+
+	error( "Coprocessor exited main loop, waiting to die\r\n" );
+
+    return( 0 );
+}