USB PIC Bootloader. User Manual


7.3.1. Boot_cmd union

To ease software development, all commands, sent to Bootloader, are defined as structures.

As interface between PC and Bootloader supports only packages of fixed size, all structures are members of boot_cmd union:

typedef union
{
/*
 * data field is used to make all commands the same length
 */
      unsigned char data[BOOT_CMD_SIZE];
      boot_cmd_header header;
      boot_cmd_read_flash read_flash;
      boot_cmd_write_flash write_flash;
      boot_cmd_erase_flash erase_flash;
      boot_cmd_get_fw_ver get_fw_ver;
      boot_cmd_reset reset;
      boot_cmd_read_id read_id;
      boot_cmd_write_id write_id;
      boot_cmd_read_eeprom read_eeprom;
      boot_cmd_write_eeprom write_eeprom;
} boot_cmd;

Fields assignment:

data

data field is added to make the size of all packages equal to BOOT_CMD_SIZE bytes.

header

header field is used to access general for all packages parameters - cmd и echo. These parameters are also available from other structures that define specific commands parameters.

All other fields are used to access the parameters specific for the corresponding commands.