|
1 /* |
|
2 ** This file is part of fsusb_picdem |
|
3 ** |
|
4 ** fsusb_picdem is free software; you can redistribute it and/or |
|
5 ** modify it under the terms of the GNU General Public License as |
|
6 ** published by the Free Software Foundation; either version 2 of the |
|
7 ** License, or (at your option) any later version. |
|
8 ** |
|
9 ** fsusb_picdem is distributed in the hope that it will be useful, but |
|
10 ** WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 ** General Public License for more details. |
|
13 ** |
|
14 ** You should have received a copy of the GNU General Public License |
|
15 ** along with fsusb_picdem; if not, write to the Free Software |
|
16 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
17 ** 02110-1301, USA |
|
18 */ |
|
19 |
|
20 #ifndef __BOOTLOAD_H__ |
|
21 #define __BOOTLOAD_H__ |
|
22 |
|
23 |
|
24 |
|
25 /* |
|
26 * Command packets: |
|
27 * |
|
28 * 0x00: command |
|
29 * 0x01: data length (usually; different action for some commands!) |
|
30 * 0x02: address bits 7..0 |
|
31 * 0x03: address bits 15..8 |
|
32 * 0x04: address bits 23..16 (upper bits always zero) |
|
33 * 0x05: data[0] |
|
34 * 0x06: data[1] |
|
35 * 0x07: data[2] |
|
36 * 0x??: ... |
|
37 * 0x3f: data[BL_DATA_LEN-1] |
|
38 */ |
|
39 |
|
40 |
|
41 |
|
42 typedef unsigned char byte; |
|
43 |
|
44 |
|
45 |
|
46 #define BL_PACKET_LEN 64 |
|
47 #define BL_HEADER_LEN 5 // command, len, low, high, upper |
|
48 #define BL_DATA_LEN (BL_PACKET_LEN - BL_HEADER_LEN) |
|
49 |
|
50 |
|
51 |
|
52 enum { |
|
53 READ_VERSION = 0x00, // Works |
|
54 READ_FLASH = 0x01, // Works |
|
55 WRITE_FLASH = 0x02, // Works |
|
56 ERASE_FLASH = 0x03, // Works |
|
57 READ_EEDATA = 0x04, // NOT IMPLEMENTED |
|
58 WRITE_EEDATA = 0x05, // NOT IMPLEMENTED |
|
59 READ_CONFIG = 0x06, // NOT IMPLEMENTED |
|
60 // (but in current firmware READ_FLASH works |
|
61 WRITE_CONFIG = 0x07, // NOT TESTED |
|
62 UPDATE_LED = 0x32, // NOT IMPLEMENTED |
|
63 RESET = 0xFF // NOT IMPLEMENTED |
|
64 }; |
|
65 |
|
66 |
|
67 |
|
68 typedef union _bl_packet { |
|
69 byte _byte[64]; |
|
70 struct { |
|
71 byte command; |
|
72 byte len; |
|
73 struct { |
|
74 byte low; |
|
75 byte high; |
|
76 byte upper; |
|
77 } address; |
|
78 byte data[BL_DATA_LEN]; |
|
79 }; |
|
80 } bl_packet; |
|
81 |
|
82 #endif /* __BOOTLOAD_H__ */ |