Subversion Repositories pentevo

Rev

Rev 908 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 908 Rev 913
Line 2... Line 2...
2
#define _IHEX_C_
2
#define _IHEX_C_
3
 
3
 
4
// max length of bytes in ihex is 255, thus 512+ chars maximum length. So the value below is sane.
4
// max length of bytes in ihex is 255, thus 512+ chars maximum length. So the value below is sane.
5
#define IHEX_BUF_SZ (1024)
5
#define IHEX_BUF_SZ (1024)
6
 
6
 
-
 
7
// maximum sane length of ihex line:
-
 
8
//   1 : semicolon
-
 
9
//   2 : byte length
-
 
10
//   4 : word address
-
 
11
//   2 : byte type
-
 
12
// 510 : hex string of max 255 bytes
-
 
13
//   2 : byte checksum
-
 
14
//   2 : newlines
-
 
15
// =523 bytes
-
 
16
#define MAX_IHEX_LENGTH (523)
-
 
17
 
-
 
18
// types of IHEX recors
-
 
19
#define IHEX_TYPE_DATA     (0)
-
 
20
#define IHEX_TYPE_EOF      (1)
-
 
21
#define IHEX_TYPE_SEGADDR  (2)
-
 
22
#define IHEX_TYPE_STARTSEG (3)
-
 
23
#define IHEX_TYPE_ELINADDR (4)
-
 
24
#define IHEX_TYPE_STARTLIN (5)
-
 
25
 
-
 
26
 
-
 
27
 
7
// parses intelhex file into the memory area so that low_bound<=every byte's address<high_bound.
28
// parses intelhex file into the memory area so that low_bound<=every byte's address<high_bound.
8
//
29
//
9
// when a byte is put in the buffer, a 'disp' value is added to its address to
30
// when a byte is put in the buffer, a 'disp' value is added to its address to
10
// make index into 'buffer' array.
31
// make index into 'buffer' array.
11
//
32
//
Line 19... Line 40...
19
// detected errors:
40
// detected errors:
20
// - any of file errors
41
// - any of file errors
21
// - intelhex format errors (incl. unknown record types)
42
// - intelhex format errors (incl. unknown record types)
22
// - addressing errors (any byte from intelhex goes outside bounds)
43
// - addressing errors (any byte from intelhex goes outside bounds)
23
// an appropriate error message is printed into stderr
44
// an appropriate error message is printed into stderr
24
//
-
 
25
int parse_ihex(uint8_t * buffer, int32_t disp, int32_t low_bound, int32_t high_bound, uint8_t fill, char * filename);
45
int parse_ihex(uint8_t * buffer, int32_t disp, int32_t low_bound, int32_t high_bound, uint8_t fill, char * filename);
26
 
46
 
27
 
47
 
-
 
48
// writes intelhex from memory buffer. addresses are from low_bound to high_bound,
-
 
49
// indices in the buffer are from low_bound+disp to high_bound+disp.
-
 
50
//
-
 
51
// returns zero in case of any errors, otherwise non-zero.
-
 
52
int write_ihex(uint8_t * buffer, int32_t disp, int32_t low_bound, int32_t high_bound, char * filename);
-
 
53
 
28
#endif // _IHEX_C_
54
#endif // _IHEX_C_
29
 
55