HexToC.c File Reference

A program to convert multiple Freescale S-record files into a C source file. More...

#include <windows.h>
#include <stdio.h>
#include <io.h>
#include "Common.h"

Data Structures

struct  FlashImage
 Struct used to contain information about the files converted. More...

Defines

#define ICPFlashStart   (0xFC00)
 Start of Protected Flash memory
Values at this address or above are ignored.

Functions

unsigned int hex1ToDecimal (char **ptr)
 Convert a single character ('0'-'9', 'a'-'f' or 'A'-'F') into a hex value.
unsigned int hex2ToDecimal (char **ptr)
 Convert two characters ('0'-'9', 'a'-'f' or 'A'-'F') into a hex value.
unsigned int hex4ToDecimal (char **ptr)
 Convert four characters ('0'-'9', 'a'-'f' or 'A'-'F') into a hex value.
int loadSRecordFile (char *filename)
 Load a Freescale S-record file into the buffer.
void writeCSourceFile (FILE *fp)
 Write buffer to C source file.
void convertFiles (char *outputFilename, char *inputFilenameMask)
 Converts multiple S-record files into a C source file.
int main (int argc, char *argv[])

Variables

U8 flashImage [0x10000]
FlashImage flashImages [20]
 Array used to contain information about the files converted.
int flashImageNumber
 Number of the last loaded file.


Detailed Description

A program to convert multiple Freescale S-record files into a C source file.

Note: ignores values at or above ICPFlashStart

Usage: HexToC outputFilename inputFilenameMask

Created on: 27/07/2008 Author: PODonoghue


Define Documentation

#define ICPFlashStart   (0xFC00)

Start of Protected Flash memory
Values at this address or above are ignored.


Function Documentation

void convertFiles ( char *  outputFilename,
char *  inputFilenameMask 
)

Converts multiple S-record files into a C source file.

Parameters:
outputFilename - name of output file to create
inputFilenameMask - mask for input files. This may contain a path.

unsigned int hex1ToDecimal ( char **  ptr  ) 

Convert a single character ('0'-'9', 'a'-'f' or 'A'-'F') into a hex value.

Parameters:
ptr - Ptr to the ptr to the character to convert. *ptr is advanced
Returns:
- a value in the range 0 to 15

unsigned int hex2ToDecimal ( char **  ptr  ) 

Convert two characters ('0'-'9', 'a'-'f' or 'A'-'F') into a hex value.

Parameters:
ptr - Ptr to the ptr to the character to convert. *ptr is advanced
Returns:
- a value in the range 0 to 255

unsigned int hex4ToDecimal ( char **  ptr  ) 

Convert four characters ('0'-'9', 'a'-'f' or 'A'-'F') into a hex value.

Parameters:
ptr - Ptr to the ptr to the character to convert. *ptr is advanced
Returns:
- a value in the range 0 to 65535

int loadSRecordFile ( char *  filename  ) 

Load a Freescale S-record file into the buffer.

Minimal error checking (file open etc, no S-record validity checks).
A global buffer flashImage[] is used. The buffer is cleared to 0xFF before loading
flashImages[] is updated appropriately

Parameters:
filename - name (path) to the file to load
Returns:

FALSE - load failed
TRUE - load was successful

int main ( int  argc,
char *  argv[] 
)

void writeCSourceFile ( FILE *  fp  ) 

Write buffer to C source file.

Parameters:
fp - file pointer of open output file


Variable Documentation

U8 flashImage[0x10000]

Number of the last loaded file.

Array used to contain information about the files converted.


Generated on Wed Aug 13 18:50:29 2008 for HexToC by  doxygen 1.5.6