1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tools/fsusb/bootload.h Tue Jan 29 22:31:52 2008 +0100
1.3 @@ -0,0 +1,82 @@
1.4 +/*
1.5 +** This file is part of fsusb_picdem
1.6 +**
1.7 +** fsusb_picdem is free software; you can redistribute it and/or
1.8 +** modify it under the terms of the GNU General Public License as
1.9 +** published by the Free Software Foundation; either version 2 of the
1.10 +** License, or (at your option) any later version.
1.11 +**
1.12 +** fsusb_picdem is distributed in the hope that it will be useful, but
1.13 +** WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.15 +** General Public License for more details.
1.16 +**
1.17 +** You should have received a copy of the GNU General Public License
1.18 +** along with fsusb_picdem; if not, write to the Free Software
1.19 +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1.20 +** 02110-1301, USA
1.21 +*/
1.22 +
1.23 +#ifndef __BOOTLOAD_H__
1.24 +#define __BOOTLOAD_H__
1.25 +
1.26 +
1.27 +
1.28 +/*
1.29 + * Command packets:
1.30 + *
1.31 + * 0x00: command
1.32 + * 0x01: data length (usually; different action for some commands!)
1.33 + * 0x02: address bits 7..0
1.34 + * 0x03: address bits 15..8
1.35 + * 0x04: address bits 23..16 (upper bits always zero)
1.36 + * 0x05: data[0]
1.37 + * 0x06: data[1]
1.38 + * 0x07: data[2]
1.39 + * 0x??: ...
1.40 + * 0x3f: data[BL_DATA_LEN-1]
1.41 + */
1.42 +
1.43 +
1.44 +
1.45 +typedef unsigned char byte;
1.46 +
1.47 +
1.48 +
1.49 +#define BL_PACKET_LEN 64
1.50 +#define BL_HEADER_LEN 5 // command, len, low, high, upper
1.51 +#define BL_DATA_LEN (BL_PACKET_LEN - BL_HEADER_LEN)
1.52 +
1.53 +
1.54 +
1.55 +enum {
1.56 + READ_VERSION = 0x00, // Works
1.57 + READ_FLASH = 0x01, // Works
1.58 + WRITE_FLASH = 0x02, // Works
1.59 + ERASE_FLASH = 0x03, // Works
1.60 + READ_EEDATA = 0x04, // NOT IMPLEMENTED
1.61 + WRITE_EEDATA = 0x05, // NOT IMPLEMENTED
1.62 + READ_CONFIG = 0x06, // NOT IMPLEMENTED
1.63 + // (but in current firmware READ_FLASH works
1.64 + WRITE_CONFIG = 0x07, // NOT TESTED
1.65 + UPDATE_LED = 0x32, // NOT IMPLEMENTED
1.66 + RESET = 0xFF // NOT IMPLEMENTED
1.67 +};
1.68 +
1.69 +
1.70 +
1.71 +typedef union _bl_packet {
1.72 + byte _byte[64];
1.73 + struct {
1.74 + byte command;
1.75 + byte len;
1.76 + struct {
1.77 + byte low;
1.78 + byte high;
1.79 + byte upper;
1.80 + } address;
1.81 + byte data[BL_DATA_LEN];
1.82 + };
1.83 +} bl_packet;
1.84 +
1.85 +#endif /* __BOOTLOAD_H__ */