#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Data Structures | |
| struct | _SRecord |
Typedefs | |
| typedef _SRecord | SRecord |
Enumerations | |
| enum | SRecordErrors { SRECORD_OK = 0, SRECORD_ERROR_FILE = -1, SRECORD_ERROR_EOF = -2, SRECORD_ERROR_INVALID_RECORD = -3, SRECORD_ERROR_INVALID_ARGUMENTS = -4 } |
| enum | SRecordTypes { SRECORD_TYPE_S0 = 0, SRECORD_TYPE_S1, SRECORD_TYPE_S2, SRECORD_TYPE_S3, SRECORD_TYPE_S4, SRECORD_TYPE_S5, SRECORD_TYPE_S6, SRECORD_TYPE_S7, SRECORD_TYPE_S8, SRECORD_TYPE_S9 } |
Functions | |
| int | New_SRecord (int type, uint32_t address, uint8_t data[], int dataLen, SRecord *srec) |
| int | Read_SRecord (SRecord *srec, FILE *in) |
| int | Write_SRecord (const SRecord srec, FILE *out) |
| void | Print_SRecord (const SRecord srec) |
| uint8_t | Checksum_SRecord (const SRecord srec) |
Alias "SRecord" for struct _SRecord, done for convenience and clarity.
| enum SRecordErrors |
All possible error codes the Motorola S-Record utility functions may return.
| enum SRecordTypes |
Motorola S-Record Types S0-S9
| uint8_t Checksum_SRecord | ( | const SRecord | srec | ) |
Calculates the checksum of a Motorola S-Record SRecord structure. See the Motorola S-Record specifications for more details on the checksum calculation.
| srec | The Motorola S-Record structure that the checksum will be calculated of. |
| int New_SRecord | ( | int | type, | |
| uint32_t | address, | |||
| uint8_t | data[], | |||
| int | dataLen, | |||
| SRecord * | srec | |||
| ) |
Sets all of the record fields of a Motorola S-Record structure.
| type | The Motorola S-Record type (integer value of 0 through 9). | |
| address | The 32-bit address of the data. The actual size of the address (16-,24-, or 32-bits) when written to a file depends on the S-Record type. | |
| data | The 8-bit array of data. | |
| dataLen | The size of the 8-bit data array. | |
| srec | A pointer to the target Motorola S-Record structure where these fields will be set. |
| SRECORD_OK | on success. | |
| SRECORD_ERROR_INVALID_ARGUMENTS | if srec does not point to a valid SRecord structure, or if the length of the 8-bit data array is out of range (less than zero or greater than the maximum data length allowed by record specifications, see SRecord.data). |
| void Print_SRecord | ( | const SRecord | srec | ) |
Prints the contents of a Motorola S-Record structure to stdout. The record dump consists of the type, address, entire data array, and checksum fields of the record.
| srec | The Motorola S-Record structure that will be printed to stdout. |
| SRECORD_OK | on success. |
| int Read_SRecord | ( | SRecord * | srec, | |
| FILE * | in | |||
| ) |
Reads a Motorola S-Record record from an opened file.
| srec | A pointer to the Motorola S-Record structure that will store the read record. | |
| in | A file pointer to an opened file that can be read. |
| SRECORD_OK | on success. | |
| SRECORD_ERROR_INVALID_ARGUMENTS | if srec does not point to a valid SRecord structure or the file pointer "in" is invalid. | |
| SRECORD_ERROR_EOF | if end-of-file has been reached. | |
| SRECORD_ERROR_FILE | if a file reading error has occured. | |
| SRECORD_INVALID_RECORD | if the record read is invalid (record did not match specifications or record checksum was invalid). |
| int Write_SRecord | ( | const SRecord | srec, | |
| FILE * | out | |||
| ) |
Writes a Motorola S-Record to an opened file.
| srec | The Motorola S-Record structure that will be written. | |
| in | A file pointer to an opened file that can be written to. |
| SRECORD_OK | on success. | |
| SRECORD_ERROR_INVALID_ARGUMENTS | if the file pointer "out" is invalid. | |
| SRECORD_ERROR_INVALID_RECORD | if the record's data length (the SRecord.dataLen variable of the record) is out of range (greater than the maximum data length allowed by record specifications, see SRecord.data). | |
| SRECORD_ERROR_FILE | if a file writing error has occured. |
1.5.1