Official support library for using mbed as a programmable coprocessor in the Innomatix DAP-III+ telematics platform
Main.cpp
- Committer:
- Innomatix
- Date:
- 2016-09-30
- Revision:
- 8:a6311d40c5a2
- Parent:
- 4:fd93c4cb05df
- Child:
- 10:5fbe72ffb725
File content as of revision 8:a6311d40c5a2:
/******************************************************************* * * 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.5" #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() { 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 ); }