ADI iSensor FX3 Firmware  v2.9.4-pub
Firmware for the Analog Devices EVAL-ADIS-FX3 IMU Evaluation Platform. This firmware can be compiled using the Cypress EZ USB Suite IDE
Functions | Variables
ErrorLog.c File Reference

Implementation file for FX3 flash error logging module. More...

#include "ErrorLog.h"

Functions

static void FindFirmwareVersion (uint8_t *outBuf)
 Parses the firmware version number from FirmwareID to a user provided buffer. More...
 
static void WriteLogToFlash (ErrorMsg *msg)
 Writes a log data structure to flash memory. More...
 
static void WriteLogToDebug (ErrorMsg *msg)
 Prints an error log object to the debug console. More...
 
static uint32_t GetNewLogAddress (uint32_t *TotalLogCount)
 Gets address (in flash memory) for a new error log entry. More...
 
static uint32_t GetLogCount ()
 Gets the log count from flash. More...
 
void AdiLogError (FileIdentifier File, uint32_t Line, uint32_t ErrorCode)
 Logs a firmware error to flash memory for later examination. More...
 
void WriteErrorLogCount (uint32_t count)
 Sets the error log count value in flash. More...
 

Variables

BoardState FX3State
 
uint8_t FirmwareID [32]
 
uint8_t LogBuffer [FLASH_PAGE_SIZE]
 

Detailed Description

Implementation file for FX3 flash error logging module.

Copyright (c) 2018-2020 Analog Devices, Inc. All Rights Reserved. This software is proprietary to Analog Devices, Inc. and its licensors.

THIS SOFTWARE UTILIZES LIBRARIES DEVELOPED AND MAINTAINED BY CYPRESS INC. THE LICENSE INCLUDED IN THIS REPOSITORY DOES NOT EXTEND TO CYPRESS PROPERTY.

Use of this file is governed by the license agreement included in this repository.

Date
12/6/2019
Author
A. Nolan (alex..nosp@m.nola.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Function Documentation

◆ AdiLogError()

void AdiLogError ( FileIdentifier  File,
uint32_t  Line,
uint32_t  ErrorCode 
)

Logs a firmware error to flash memory for later examination.

Parameters
FileThe file which produced the error
LineThe line in the source file which produced the error
ErrorCodeThe error code which produced the error. Should be of type CyU3PReturnStatus_t.
Returns
void

When calling this function, the Line parameter should be generated by the C pre-processor using the LINE macro. Internally, this function sets the unit boot time stamp (FX3 boot time), system uptime based on the FX3 RTOS tick clock, and the FX3 firmware version before logging the error to both the debugger output (serial port) and flash memory.

◆ FindFirmwareVersion()

static void FindFirmwareVersion ( uint8_t *  outBuf)
static

Parses the firmware version number from FirmwareID to a user provided buffer.

Parameters
outBufThe buffer to place the firmware version into
Returns
void

This function uses a fixed offset to get the version number from the FirmwareID string. This fixed offset works for current and past versions of the FirmwareID, but will break if the ID format is changed.

◆ GetLogCount()

static uint32_t GetLogCount ( )
static

Gets the log count from flash.

Returns
The current logged error count (from LOG_COUNT)

◆ GetNewLogAddress()

static uint32_t GetNewLogAddress ( uint32_t *  TotalLogCount)
static

Gets address (in flash memory) for a new error log entry.

Parameters
TotalLogCountReturn by reference for the total number of error log entries stored in flash
Returns
The flash address of the new error log entry

This function implements the error log circular buffer logic by mod-ing the count with the capacity (newer entries will overwrite the oldest error log once the buffer is full).

◆ WriteErrorLogCount()

void WriteErrorLogCount ( uint32_t  count)

Sets the error log count value in flash.

Parameters
countThe new error log count value to write to flash
Returns
void

◆ WriteLogToDebug()

static void WriteLogToDebug ( ErrorMsg msg)
static

Prints an error log object to the debug console.

Parameters
msgThe error log object to print
Returns
void

◆ WriteLogToFlash()

static void WriteLogToFlash ( ErrorMsg msg)
static

Writes a log data structure to flash memory.

Parameters
msgThe error log object to write
Returns
void

This function first gets the address for the new buffer entry from the flash error log ring buffer. It then clears the 32 bytes which have been allocated in flash for the current error log. The passed log is then copied byte-wise into the LogBuffer, array, then written to flash. Finally, the LOG_COUNT variable in flash is incremented.

Variable Documentation

◆ FX3State

BoardState FX3State
extern

Struct. which stores all run time configurable FX3 settings

◆ LogBuffer

uint8_t LogBuffer[FLASH_PAGE_SIZE]

Error log buffer. Each error log entry is copied here before being written to flash