Example for updating the MTi-1's firmware. Uses a platform independent, retargetable pure C implementation of the firmware updater protocol.

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

main.cpp File Reference

main.cpp File Reference

Go to the source code of this file.

Functions

static void updateUartBaudrate ()
 Try to find the correct uart baudrate.
static Serial pc (PC_TX, PC_RX)
 Serial object for communicating with the PC.
static DigitalInOut resetLine (MT_RESET, PIN_INPUT, OpenDrain, 1)
 Reset line towards the module. Pulling this line down keeps the module in reset.
static void createMtInterface ()
 Create an instance of MtInterface.
static int readXffData (uint8_t *buffer, int offset, int length)
 Callback function for FwUpdate for reading data from the xff (xsens firmware file) file.
static void readyHandler (FWU_Result result)
 Callback function for FwUpdate for signaling that a firmware update has completed.
static void gotoConfig ()
 Sends a XMID_GotoConfig message to the Module.
static void handleXbusMessage (XbusMessage *xbusMessage)
 Handles xbus messages from the module.
static void hardwareReset (bool stayInBootloader)
 Reset the module via the hardware reset line.
static void sendXbusMessageWrapper (XbusMessage const *xbusMessage)
 C-wrapper for sendXbusMessage callback function of FwUpdate.
static char * lowLevelFormatToString (XbusBusFormat format)
 Helper function for converting a XbusLowLevelFormat to string.
static void printUsageInfo ()
 Print usage info of this example.
int main ()
 Main entry point of the embedded firmware updater example.

Variables

static MtInterfacemtInterface = 0
 Instance of MtInterface. Should be initialized by createMtInterface().
static FwUpdateg_fwUpdate = NULL
 Instance of the firmware updater.

Detailed Description

Copyright (C) Xsens Technologies B.V., 2015.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file main.cpp.


Function Documentation

static void createMtInterface (  ) [static]

Create an instance of MtInterface.

Definition at line 166 of file main.cpp.

static void gotoConfig (  ) [static]

Sends a XMID_GotoConfig message to the Module.

Definition at line 230 of file main.cpp.

static void handleXbusMessage ( XbusMessage xbusMessage ) [static]

Handles xbus messages from the module.

Parameters:
xbusMessageThe xbus message received from the module

Messages with message identifier XMID_FirmwareUpdate are passed to the firmware updater, other messages are just printed.

Definition at line 241 of file main.cpp.

static void hardwareReset ( bool  stayInBootloader ) [static]

Reset the module via the hardware reset line.

Parameters:
stayInBootloader,:If stayInBootloader is true, an XMID_GotoBootLoader is sent immediately after the reset.

By sending an XMID_GotoBootLoader within 100 ms after reset the module stays in bootloader mode instead of booting the application. This can be used if the normal GotoBootloader command fails to put the module in bootloader mode, e.g. because of a faulty firmware.

Definition at line 325 of file main.cpp.

static char* lowLevelFormatToString ( XbusBusFormat  format ) [static]

Helper function for converting a XbusLowLevelFormat to string.

Definition at line 400 of file main.cpp.

int main (  )

Main entry point of the embedded firmware updater example.

Definition at line 435 of file main.cpp.

static Serial pc ( PC_TX  ,
PC_RX   
) [static]

Serial object for communicating with the PC.

static void printUsageInfo (  ) [static]

Print usage info of this example.

Definition at line 417 of file main.cpp.

static int readXffData ( uint8_t *  buffer,
int  offset,
int  length 
) [static]

Callback function for FwUpdate for reading data from the xff (xsens firmware file) file.

Parameters:
bufferTarget buffer in which the xff data should be written
offsetOffset in the xff file where reading should start
lengthNumber of bytes which is requested
Returns:
Number of bytes which is actually written to the buffer

Definition at line 190 of file main.cpp.

static void readyHandler ( FWU_Result  result ) [static]

Callback function for FwUpdate for signaling that a firmware update has completed.

Parameters:
resultResult of the firmware update, either FWU_Success or FWU_Failed

Definition at line 216 of file main.cpp.

static DigitalInOut resetLine ( MT_RESET  ,
PIN_INPUT  ,
OpenDrain  ,
 
) [static]

Reset line towards the module. Pulling this line down keeps the module in reset.

static void sendXbusMessageWrapper ( XbusMessage const *  xbusMessage ) [static]

C-wrapper for sendXbusMessage callback function of FwUpdate.

Definition at line 391 of file main.cpp.

static void updateUartBaudrate (  ) [static]

Try to find the correct uart baudrate.

Definition at line 348 of file main.cpp.


Variable Documentation

FwUpdate* g_fwUpdate = NULL [static]

Instance of the firmware updater.

Definition at line 161 of file main.cpp.

MtInterface* mtInterface = 0 [static]

Instance of MtInterface. Should be initialized by createMtInterface().

Definition at line 147 of file main.cpp.