diff --git a/programmer_protocol.h b/programmer_protocol.h index b9333ff..8a9fd67 100644 --- a/programmer_protocol.h +++ b/programmer_protocol.h @@ -48,7 +48,8 @@ typedef enum ProgrammerCommand WriteChipsAt, ReadChipsAt, SetChipsMask, - SetSectorLayout + SetSectorLayout, + GetFirmwareVersion } ProgrammerCommand; // After a command is sent, the programmer will always respond with @@ -186,4 +187,15 @@ typedef enum ProgrammerErasePortionOfChipReply ProgrammerErasePortionFinished } ProgrammerErasePortionOfChipReply; +// ------------------------- GET FIRMWARE VERSION PROTOCOL ------------------------- +// If the command is GetFirmwareVersion, the programmer will reply CommandReplyOK. +// Next, it will return 4 bytes: major version, minor version, revision, and a final +// byte where 0 means it's a normal version and 1 means it's a prerelease version. +// Other values are reserved. +// Finally, it will finish the response with ProgrammerGetFWVersionDone. +typedef enum ProgrammerGetFWVersionReply +{ + ProgrammerGetFWVersionDone +} ProgrammerGetFWVersionReply; + #endif /* PROGRAMMER_PROTOCOL_H_ */ diff --git a/simm_programmer.c b/simm_programmer.c index 319442b..4d2594d 100644 --- a/simm_programmer.c +++ b/simm_programmer.c @@ -44,6 +44,11 @@ /// The maximum number of erase groups we deal with #define MAX_ERASE_SECTOR_GROUPS 10 +/// Version info to respond with +#define VERSION_MAJOR 1 +#define VERSION_MINOR 5 +#define VERSION_REVISION 0 + /// The number of erase sector groups we know about currently. /// If it's zero, we don't know, so fall back to defaults. static uint8_t numEraseSectorGroups = 0; @@ -282,6 +287,14 @@ static void SIMMProgrammer_HandleWaitingForCommandByte(uint8_t byte) curCommandState = ReadingSectorLayout; USBCDC_SendByte(CommandReplyOK); break; + case GetFirmwareVersion: + USBCDC_SendByte(CommandReplyOK); + USBCDC_SendByte(VERSION_MAJOR); + USBCDC_SendByte(VERSION_MINOR); + USBCDC_SendByte(VERSION_REVISION); + USBCDC_SendByte(0); + USBCDC_SendByte(ProgrammerGetFWVersionDone); + break; // We don't know what this command is, so reply that it was invalid. default: USBCDC_SendByte(CommandReplyInvalid);