Skip to content

Commit

Permalink
Added uid system command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ultrawipf committed Jun 1, 2023
1 parent 4ccc04f commit 3cae1e8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
### 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
- Added basic iterative TMC PI autotuning
- 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
- Dynamic TMC encoder alignment current based on current limit
- Added effect monitoring per axis

2 changes: 1 addition & 1 deletion Firmware/FFBoard/Inc/SystemCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Firmware/FFBoard/Inc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 15 additions & 0 deletions Firmware/FFBoard/Src/SystemCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3cae1e8

Please sign in to comment.