Add get firmware version command

This commit is contained in:
Doug Brown 2023-08-25 23:38:42 -07:00 committed by Doug Brown
parent 1e63f3aea4
commit 81b3d28ffb
2 changed files with 26 additions and 1 deletions

View File

@ -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_ */

View File

@ -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);