From 3cae1e855820e7d971d3a89541bcbf11e7a5bda8 Mon Sep 17 00:00:00 2001 From: Yannick Richter Date: Wed, 31 May 2023 10:45:59 +0200 Subject: [PATCH] Added uid system command --- CHANGELOG.md | 6 ++++-- Firmware/FFBoard/Inc/SystemCommands.h | 2 +- Firmware/FFBoard/Inc/constants.h | 2 +- Firmware/FFBoard/Src/SystemCommands.cpp | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5afccac66..1d21aafe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ### Changes this version: -- Added effect monitoring per axis +- Added uid command (`sys.uid?` returns first 64 bits as val and second 32 as adr) ### Changes in 1.13.x - Added PWM direction toggle @@ -7,4 +7,6 @@ - Fixed issues with CAN transmission with multiple axes - Added SSI encoder support (AMT232B) - Fixed SPI buttons not working (SPI2 DMA on F407) -- Dynamic TMC encoder alignment current based on current limit \ No newline at end of file +- Dynamic TMC encoder alignment current based on current limit +- Added effect monitoring per axis + \ No newline at end of file diff --git a/Firmware/FFBoard/Inc/SystemCommands.h b/Firmware/FFBoard/Inc/SystemCommands.h index fab13c54e..85ebb9f7f 100644 --- a/Firmware/FFBoard/Inc/SystemCommands.h +++ b/Firmware/FFBoard/Inc/SystemCommands.h @@ -11,7 +11,7 @@ #include "CommandHandler.h" enum class FFBoardMain_commands : uint32_t{ - help=0,save=1,reboot=2,dfu=3,swver=4,hwtype=5,lsmain,main,lsactive,format,errors,errorsclr,flashdump,flashraw,vint,vext,mallinfo,heapfree,taskstats,debug,devid + help=0,save=1,reboot=2,dfu=3,swver=4,hwtype=5,lsmain,main,lsactive,format,errors,errorsclr,flashdump,flashraw,vint,vext,mallinfo,heapfree,taskstats,debug,devid,uid }; class SystemCommands : public CommandHandler { diff --git a/Firmware/FFBoard/Inc/constants.h b/Firmware/FFBoard/Inc/constants.h index e6fe357e7..b5ed06e51 100644 --- a/Firmware/FFBoard/Inc/constants.h +++ b/Firmware/FFBoard/Inc/constants.h @@ -8,7 +8,7 @@ * For more settings see target_constants.h in a target specific folder */ -static const uint8_t SW_VERSION_INT[3] = {1,13,2}; // Version as array. 8 bit each! +static const uint8_t SW_VERSION_INT[3] = {1,13,3}; // Version as array. 8 bit each! #define MAX_AXIS 2 // ONLY USE 2 for now else screws HID Reports #define FLASH_VERSION 0 // Counter to increase whenever a full flash erase is required. diff --git a/Firmware/FFBoard/Src/SystemCommands.cpp b/Firmware/FFBoard/Src/SystemCommands.cpp index 331f3132a..d6dc34b61 100644 --- a/Firmware/FFBoard/Src/SystemCommands.cpp +++ b/Firmware/FFBoard/Src/SystemCommands.cpp @@ -68,6 +68,7 @@ void SystemCommands::registerCommands(){ CommandHandler::registerCommand("devid", FFBoardMain_commands::devid, "Get chip dev id and rev id",CMDFLAG_GET); CommandHandler::registerCommand("name", CommandHandlerCommands::name, "name of class",CMDFLAG_GET|CMDFLAG_STR_ONLY); CommandHandler::registerCommand("cmdinfo", CommandHandlerCommands::cmdinfo, "Flags of a command id (adr). -1 if cmd id invalid",CMDFLAG_GETADR); + CommandHandler::registerCommand("uid", FFBoardMain_commands::uid, "Get 96b chip uid. Adr0-2 sel blk",CMDFLAG_GET | CMDFLAG_GETADR); } // Choose lower optimize level because the compiler likes to blow up this function @@ -265,6 +266,20 @@ CommandStatus SystemCommands::internalCommand(const ParsedCommand& cmd,std::vect HAL_FLASH_Lock(); } break; + case FFBoardMain_commands::uid: + if(cmd.type == CMDtype::get){ + replies.emplace_back((uint64_t)HAL_GetUIDw0() | (uint64_t)HAL_GetUIDw1() << 32,HAL_GetUIDw2()); + }else if(cmd.type == CMDtype::getat){ + if(cmd.adr == 0){ + replies.emplace_back(HAL_GetUIDw0()); + }else if(cmd.adr == 1){ + replies.emplace_back(HAL_GetUIDw1()); + }else if(cmd.adr == 2){ + replies.emplace_back(HAL_GetUIDw2()); + } + } + break; + default: flag = CommandStatus::NOT_FOUND;