-
Notifications
You must be signed in to change notification settings - Fork 21
/
ihex.h
43 lines (34 loc) · 1008 Bytes
/
ihex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef IHEX_H
#define IHEX_H
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#define IHEX_LINE_LENGTH 16
#define IHEX_MIN_STRING 11
#define IHEX_OFFS_LEN 1
#define IHEX_OFFS_ADDR 3
#define IHEX_OFFS_TYPE 7
#define IHEX_OFFS_DATA 9
#define IHEX_START ":"
#define IHEX_NEWLINE "\n"
#define IHEX_ENDFILE ":00000001FF"
enum {
IHEX_DATA_RECORD,
IHEX_END_OF_FILE_RECORD,
IHEX_EXTENDED_SEGMENT_ADDRESS_RECORD,
IHEX_START_SEGMENT_ADDRESS_RECORD,
IHEX_EXTENDED_LINEAR_ADDRESS_RECORD,
IHEX_START_LINEAR_ADDRESS_RECORD
};
enum {
IHEX_ERROR_NONE,
IHEX_ERROR_FILE,
IHEX_ERROR_SIZE,
IHEX_ERROR_FMT,
IHEX_ERROR_CRC
};
#define IHEX_DIGIT(n) ((char)((n) + (((n) < 10) ? '0' : ('A' - 10))))
uint8_t IHEX_WriteFile(FILE *fp, uint8_t *data, uint16_t len);
uint8_t IHEX_ReadFile(FILE *fp, uint8_t *data, uint16_t maxlen,
uint16_t *min_addr, uint16_t *max_addr);
#endif