bootload.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef __BOOTLOAD_H__
  20. #define __BOOTLOAD_H__
  21. /*
  22. * Command packets:
  23. *
  24. * 0x00: command
  25. * 0x01: data length (usually; different action for some commands!)
  26. * 0x02: address bits 7..0
  27. * 0x03: address bits 15..8
  28. * 0x04: address bits 23..16 (upper bits always zero)
  29. * 0x05: data[0]
  30. * 0x06: data[1]
  31. * 0x07: data[2]
  32. * 0x??: ...
  33. * 0x3f: data[BL_DATA_LEN-1]
  34. */
  35. typedef unsigned char byte;
  36. #define BL_PACKET_LEN 64
  37. #define BL_HEADER_LEN 5 // command, len, low, high, upper
  38. #define BL_DATA_LEN (BL_PACKET_LEN - BL_HEADER_LEN)
  39. enum {
  40. READ_VERSION = 0x00, // Works
  41. READ_FLASH = 0x01, // Works
  42. WRITE_FLASH = 0x02, // Works
  43. ERASE_FLASH = 0x03, // Works
  44. READ_EEDATA = 0x04, // NOT IMPLEMENTED
  45. WRITE_EEDATA = 0x05, // NOT IMPLEMENTED
  46. READ_CONFIG = 0x06, // NOT IMPLEMENTED
  47. // (but in current firmware READ_FLASH works
  48. WRITE_CONFIG = 0x07, // NOT TESTED
  49. UPDATE_LED = 0x32, // NOT IMPLEMENTED
  50. RESET = 0xFF // NOT IMPLEMENTED
  51. };
  52. typedef union _bl_packet {
  53. byte _byte[64];
  54. struct {
  55. byte command;
  56. byte len;
  57. struct {
  58. byte low;
  59. byte high;
  60. byte upper;
  61. } address;
  62. byte data[BL_DATA_LEN];
  63. };
  64. } bl_packet;
  65. #endif /* __BOOTLOAD_H__ */