mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
DeviceID (#1314)
* Ability to print hex * Add device ID getter * Refactor debug menu * No longer need patch * Update make_translation.py * Fix typo * Fix hex drawing
This commit is contained in:
@@ -120,9 +120,6 @@ def get_constants(build_version: str) -> List[Tuple[str, str]]:
|
|||||||
def get_debug_menu() -> List[str]:
|
def get_debug_menu() -> List[str]:
|
||||||
return [
|
return [
|
||||||
datetime.today().strftime("%d-%m-%y"),
|
datetime.today().strftime("%d-%m-%y"),
|
||||||
"HW G ",
|
|
||||||
"HW M ",
|
|
||||||
"HW P ",
|
|
||||||
"Time ",
|
"Time ",
|
||||||
"Move ",
|
"Move ",
|
||||||
"RTip ",
|
"RTip ",
|
||||||
@@ -131,7 +128,11 @@ def get_debug_menu() -> List[str]:
|
|||||||
"Vin ",
|
"Vin ",
|
||||||
"ACC ",
|
"ACC ",
|
||||||
"PWR ",
|
"PWR ",
|
||||||
|
"ID ",
|
||||||
"Max ",
|
"Max ",
|
||||||
|
"HW G ",
|
||||||
|
"HW M ",
|
||||||
|
"HW P ",
|
||||||
"Hall ",
|
"Hall ",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -429,7 +430,24 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer
|
|||||||
|
|
||||||
|
|
||||||
def get_forced_first_symbols() -> List[str]:
|
def get_forced_first_symbols() -> List[str]:
|
||||||
forced_first_symbols = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
forced_first_symbols = [
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c",
|
||||||
|
"d",
|
||||||
|
"e",
|
||||||
|
"f",
|
||||||
|
]
|
||||||
return forced_first_symbols
|
return forced_first_symbols
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ void log_system_state(int32_t PWMWattsx10);
|
|||||||
// Returns true if the tip is disconnected
|
// Returns true if the tip is disconnected
|
||||||
bool isTipDisconnected();
|
bool isTipDisconnected();
|
||||||
|
|
||||||
|
// Return hardware unique ID if possible
|
||||||
|
uint64_t getDeviceID();
|
||||||
|
|
||||||
// Status LED controls
|
// Status LED controls
|
||||||
|
|
||||||
enum StatusLED {
|
enum StatusLED {
|
||||||
|
|||||||
@@ -471,3 +471,7 @@ void setStatusLED(const enum StatusLED state) {
|
|||||||
setBuzzer(false);
|
setBuzzer(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uint64_t getDeviceID() {
|
||||||
|
//
|
||||||
|
return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
|
||||||
|
}
|
||||||
@@ -282,5 +282,9 @@ bool isTipDisconnected() {
|
|||||||
return tipTemp > tipDisconnectedThres;
|
return tipTemp > tipDisconnectedThres;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStatusLED(const enum StatusLED state) {}
|
void setStatusLED(const enum StatusLED state) {}
|
||||||
uint8_t preStartChecks() { return 0; }
|
uint8_t preStartChecks() { return 0; }
|
||||||
|
uint64_t getDeviceID() {
|
||||||
|
//
|
||||||
|
return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
|
||||||
|
}
|
||||||
|
|||||||
@@ -310,6 +310,9 @@ void HAL_ResumeTick(void);
|
|||||||
uint32_t HAL_GetHalVersion(void);
|
uint32_t HAL_GetHalVersion(void);
|
||||||
uint32_t HAL_GetREVID(void);
|
uint32_t HAL_GetREVID(void);
|
||||||
uint32_t HAL_GetDEVID(void);
|
uint32_t HAL_GetDEVID(void);
|
||||||
|
uint32_t HAL_GetUIDw0(void);
|
||||||
|
uint32_t HAL_GetUIDw1(void);
|
||||||
|
uint32_t HAL_GetUIDw2(void);
|
||||||
void HAL_DBGMCU_EnableDBGSleepMode(void);
|
void HAL_DBGMCU_EnableDBGSleepMode(void);
|
||||||
void HAL_DBGMCU_DisableDBGSleepMode(void);
|
void HAL_DBGMCU_DisableDBGSleepMode(void);
|
||||||
void HAL_DBGMCU_EnableDBGStopMode(void);
|
void HAL_DBGMCU_EnableDBGStopMode(void);
|
||||||
|
|||||||
@@ -513,6 +513,24 @@ void HAL_GetUID(uint32_t *UID) {
|
|||||||
UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
|
UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns first word of the unique device identifier (UID based on 96 bits)
|
||||||
|
* @retval Device identifier
|
||||||
|
*/
|
||||||
|
uint32_t HAL_GetUIDw0(void) { return (READ_REG(*((uint32_t *)UID_BASE))); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns second word of the unique device identifier (UID based on 96 bits)
|
||||||
|
* @retval Device identifier
|
||||||
|
*/
|
||||||
|
uint32_t HAL_GetUIDw1(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 4U)))); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns third word of the unique device identifier (UID based on 96 bits)
|
||||||
|
* @retval Device identifier
|
||||||
|
*/
|
||||||
|
uint32_t HAL_GetUIDw2(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 8U)))); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -91,4 +91,5 @@ bool isTipDisconnected() {
|
|||||||
|
|
||||||
void setStatusLED(const enum StatusLED state) {}
|
void setStatusLED(const enum StatusLED state) {}
|
||||||
|
|
||||||
uint8_t preStartChecks() { return 0; }
|
uint8_t preStartChecks() { return 0; }
|
||||||
|
uint64_t getDeviceID() { return dbg_id_get(); }
|
||||||
|
|||||||
@@ -423,6 +423,13 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void OLED::drawHex(uint32_t x, FontStyle fontStyle) {
|
||||||
|
// print number to hex
|
||||||
|
for (uint_fast8_t i = 0; i < 8; i++) {
|
||||||
|
uint16_t value = (x >> (4 * (7 - i))) & 0b1111;
|
||||||
|
drawChar(value + 2, fontStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
// maximum places is 5
|
// maximum places is 5
|
||||||
void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) {
|
void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) {
|
||||||
char buffer[7] = {0};
|
char buffer[7] = {0};
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public:
|
|||||||
// Draws a checkbox
|
// Draws a checkbox
|
||||||
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
|
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
|
||||||
static void debugNumber(int32_t val, FontStyle fontStyle);
|
static void debugNumber(int32_t val, FontStyle fontStyle);
|
||||||
|
static void drawHex(uint32_t x, FontStyle fontStyle);
|
||||||
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
|
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
|
||||||
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
|
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
|
||||||
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
|
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
|
||||||
@@ -104,8 +105,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
|
static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
|
||||||
static void setFramebuffer(uint8_t *buffer);
|
static void setFramebuffer(uint8_t *buffer);
|
||||||
static uint8_t * firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
||||||
static uint8_t * secondStripPtr; // Pointers to the strips
|
static uint8_t *secondStripPtr; // Pointers to the strips
|
||||||
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
|
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
|
||||||
static bool initDone;
|
static bool initDone;
|
||||||
static DisplayState displayState;
|
static DisplayState displayState;
|
||||||
|
|||||||
@@ -691,46 +691,34 @@ void showDebugMenu(void) {
|
|||||||
case 0: // Just prints date
|
case 0: // Just prints date
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// High water mark for GUI
|
|
||||||
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// High water mark for the Movement task
|
|
||||||
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// High water mark for the PID task
|
|
||||||
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
// system up time stamp
|
// system up time stamp
|
||||||
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL);
|
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 2:
|
||||||
// Movement time stamp
|
// Movement time stamp
|
||||||
OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL);
|
OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 3:
|
||||||
// Raw Tip
|
// Raw Tip
|
||||||
{ OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); }
|
{ OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); }
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 4:
|
||||||
// Temp in C
|
// Temp in C
|
||||||
OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL);
|
OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 5:
|
||||||
// Handle Temp
|
// Handle Temp
|
||||||
OLED::printNumber(getHandleTemperature(0), 6, FontStyle::SMALL);
|
OLED::printNumber(getHandleTemperature(0), 6, FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 6:
|
||||||
// Voltage input
|
// Voltage input
|
||||||
printVoltage();
|
printVoltage();
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 7:
|
||||||
// Print ACC type
|
// Print ACC type
|
||||||
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
|
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 8:
|
||||||
// Power negotiation status
|
// Power negotiation status
|
||||||
{
|
{
|
||||||
int sourceNumber = 0;
|
int sourceNumber = 0;
|
||||||
@@ -766,12 +754,32 @@ void showDebugMenu(void) {
|
|||||||
OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL);
|
OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 9:
|
||||||
|
// Print device ID Numbers
|
||||||
|
{
|
||||||
|
uint64_t id = getDeviceID();
|
||||||
|
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL);
|
||||||
|
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
// Max deg C limit
|
// Max deg C limit
|
||||||
OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL);
|
OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
#ifdef HALL_SENSOR
|
case 11:
|
||||||
|
// High water mark for GUI
|
||||||
|
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
// High water mark for the Movement task
|
||||||
|
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
|
||||||
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
|
// High water mark for the PID task
|
||||||
|
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
|
||||||
|
break;
|
||||||
|
#ifdef HALL_SENSOR
|
||||||
|
case 14:
|
||||||
// Print raw hall effect value if availabe, none if hall effect disabled.
|
// Print raw hall effect value if availabe, none if hall effect disabled.
|
||||||
{
|
{
|
||||||
int16_t hallEffectStrength = getRawHallEffect();
|
int16_t hallEffectStrength = getRawHallEffect();
|
||||||
@@ -781,6 +789,7 @@ void showDebugMenu(void) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -792,9 +801,9 @@ void showDebugMenu(void) {
|
|||||||
else if (b == BUTTON_F_SHORT) {
|
else if (b == BUTTON_F_SHORT) {
|
||||||
screen++;
|
screen++;
|
||||||
#ifdef HALL_SENSOR
|
#ifdef HALL_SENSOR
|
||||||
screen = screen % 14;
|
screen = screen % 15;
|
||||||
#else
|
#else
|
||||||
screen = screen % 13;
|
screen = screen % 14;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
GUIDelay();
|
GUIDelay();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
ifndef model
|
ifndef model
|
||||||
model:=TS100
|
model:=Pinecil
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ALL_MINIWARE_MODELS=TS100 TS80 TS80P
|
ALL_MINIWARE_MODELS=TS100 TS80 TS80P
|
||||||
@@ -161,7 +161,7 @@ bootldr_size=0x0
|
|||||||
CPUFLAGS= -march=rv32imac \
|
CPUFLAGS= -march=rv32imac \
|
||||||
-mabi=ilp32 \
|
-mabi=ilp32 \
|
||||||
-mcmodel=medany -fsigned-char -fno-builtin -nostartfiles
|
-mcmodel=medany -fsigned-char -fno-builtin -nostartfiles
|
||||||
DEV_LDFLAGS=-nostartfiles --specs=patch.specs
|
DEV_LDFLAGS=-nostartfiles
|
||||||
DEV_AFLAGS=
|
DEV_AFLAGS=
|
||||||
DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
|
DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
|
||||||
DEV_CFLAGS=
|
DEV_CFLAGS=
|
||||||
@@ -192,10 +192,10 @@ $(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \
|
|||||||
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
|
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
|
||||||
|
|
||||||
# code optimisation ------------------------------------------------------------
|
# code optimisation ------------------------------------------------------------
|
||||||
OPTIM=-Os -flto -finline-small-functions -fshort-wchar -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
|
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
|
||||||
|
|
||||||
# global defines ---------------------------------------------------------------
|
# global defines ---------------------------------------------------------------
|
||||||
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
|
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar
|
||||||
|
|
||||||
DEBUG=-g3
|
DEBUG=-g3
|
||||||
ifdef swd_enable
|
ifdef swd_enable
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
*link:
|
|
||||||
%(nano_link) %:replace-outfile(-lm_nano -lm)
|
|
||||||
Reference in New Issue
Block a user