From 4009a2794d1f1f622b7de222640f4dd91959ad9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 15 Oct 2021 22:06:30 +0200 Subject: [PATCH] Add STM device resvision to MOTD. --- stm-firmware/include/stm-periph/unique-id.h | 4 +++- stm-firmware/oven-driver.c | 2 +- stm-firmware/settings/settings-sd-card.c | 2 +- stm-firmware/shell.c | 10 ++++++++-- stm-firmware/stm-periph/unique-id.c | 12 +++++++++++- stm-firmware/ui/gui.c | 2 +- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/stm-firmware/include/stm-periph/unique-id.h b/stm-firmware/include/stm-periph/unique-id.h index 974a1e5..7a8ef98 100644 --- a/stm-firmware/include/stm-periph/unique-id.h +++ b/stm-firmware/include/stm-periph/unique-id.h @@ -29,6 +29,8 @@ * @param mid mid word of ID * @param low low word of ID */ -void unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low); +void stm_unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low); + +void stm_dev_rev_id_get(uint32_t *device_id, uint32_t *revision_id); #endif /* __UNIQUE_ID_H__ */ diff --git a/stm-firmware/oven-driver.c b/stm-firmware/oven-driver.c index 79be403..6dcb2bb 100644 --- a/stm-firmware/oven-driver.c +++ b/stm-firmware/oven-driver.c @@ -34,7 +34,7 @@ #include /** - * @brief PID ontroller instance of the oven driver + * @brief PID controller instance of the oven driver */ static struct pid_controller IN_SECTION(.ccm.bss) oven_pid; diff --git a/stm-firmware/settings/settings-sd-card.c b/stm-firmware/settings/settings-sd-card.c index acbe14f..bf1a5bd 100644 --- a/stm-firmware/settings/settings-sd-card.c +++ b/stm-firmware/settings/settings-sd-card.c @@ -38,7 +38,7 @@ static void get_controller_folder_path(char *path, size_t size) if (!path) return; - unique_id_get(&high, &mid, &low); + stm_unique_id_get(&high, &mid, &low); snprintf(path, size, "/%08X-%08X-%08X", (unsigned int)high, (unsigned int)mid, (unsigned int)low); diff --git a/stm-firmware/shell.c b/stm-firmware/shell.c index 7b5eb6f..402e00f 100644 --- a/stm-firmware/shell.c +++ b/stm-firmware/shell.c @@ -64,10 +64,13 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle, uint32_t low_id; uint32_t mid_id; uint32_t high_id; + uint32_t stm_rev_id; + uint32_t stm_dev_id; const char *hw_rev_str; enum hw_revision pcb_rev; - unique_id_get(&high_id, &mid_id, &low_id); + stm_unique_id_get(&high_id, &mid_id, &low_id); + stm_dev_rev_id_get(&stm_dev_id, &stm_rev_id); shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n" "Compiled: " __DATE__ " at " __TIME__ "\r\n"); @@ -85,7 +88,10 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle, hw_rev_str = "Hardware: Unknown Revision. You might have to update the firmware!"; break; } - shellmatta_printf(handle, "%s", hw_rev_str); + shellmatta_printf(handle, "%s\r\n", hw_rev_str); + + shellmatta_printf(handle, "STM Device ID: 0x%04X\r\n", stm_dev_id); + shellmatta_printf(handle, "STM Revision ID: 0x%04X\r\n", stm_rev_id); return SHELLMATTA_OK; } diff --git a/stm-firmware/stm-periph/unique-id.c b/stm-firmware/stm-periph/unique-id.c index d52bf19..aa56130 100644 --- a/stm-firmware/stm-periph/unique-id.c +++ b/stm-firmware/stm-periph/unique-id.c @@ -19,12 +19,13 @@ */ #include +#include #define LOW_WORD_ADDR (0x1FFF7A10UL) #define MID_WORD_ADDR (LOW_WORD_ADDR+4U) #define HIGH_WORD_ADDR (LOW_WORD_ADDR+8U) -void unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low) +void stm_unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low) { if (!high || !mid || !low) return; @@ -33,3 +34,12 @@ void unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low) *mid = *((uint32_t *)MID_WORD_ADDR); *high = *((uint32_t *)HIGH_WORD_ADDR); } + + +void stm_dev_rev_id_get(uint32_t *device_id, uint32_t *revision_id) +{ + if (device_id) + *device_id = DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID; + if (revision_id) + *revision_id = (DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16; +} diff --git a/stm-firmware/ui/gui.c b/stm-firmware/ui/gui.c index 37662af..8275066 100644 --- a/stm-firmware/ui/gui.c +++ b/stm-firmware/ui/gui.c @@ -189,7 +189,7 @@ static void gui_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry ent if (last_page == 3) break; last_page = 3; - unique_id_get(&ser1, &ser2, &ser3); + stm_unique_id_get(&ser1, &ser2, &ser3); menu_lcd_outputf(menu, 0, "Serial: %08X", ser1); menu_lcd_outputf(menu, 1, " %08X", ser2);