Add unique ID as serial number to version output

This commit is contained in:
Mario Hüttel 2020-02-12 22:24:17 +01:00
parent c6dd4e735c
commit 0da3ebed6f
4 changed files with 39 additions and 1 deletions

View File

@ -39,6 +39,8 @@ CFILES += stm-periph/uart.c stm-periph/dma-ring-buffer.c
CFILES += digio.c CFILES += digio.c
CFILES += stm-periph/unique-id.c
DEFINES += -DDEBUGBUILD DEFINES += -DDEBUGBUILD
#TODO #TODO

View File

@ -0,0 +1,14 @@
#ifndef __UNIQUE_ID_H__
#define __UNIQUE_ID_H__
#include <stdint.h>
/**
* @brief Get the device's unique 96 bit ID programmed by ST during manufacturing
* @param high high word of ID
* @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);
#endif /* __UNIQUE_ID_H__ */

View File

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <helper-macros/helper-macros.h> #include <helper-macros/helper-macros.h>
#include <reflow-controller/systick.h> #include <reflow-controller/systick.h>
#include <stm-periph/unique-id.h>
#ifndef GIT_VER #ifndef GIT_VER
#define GIT_VER "VERSION NOT SET" #define GIT_VER "VERSION NOT SET"
@ -27,9 +28,15 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
{ {
(void)arguments; (void)arguments;
(void)length; (void)length;
uint32_t low_id;
uint32_t mid_id;
uint32_t high_id;
unique_id_get(&high_id, &mid_id, &low_id);
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n" shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
"Compiled: " __DATE__ " at " __TIME__); "Compiled: " __DATE__ " at " __TIME__ "\r\n"
"Serial: %08X-%08X-%08X", high_id, mid_id, low_id);
return SHELLMATTA_OK; return SHELLMATTA_OK;
} }

View File

@ -0,0 +1,15 @@
#include <stm-periph/unique-id.h>
#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)
{
if (!high || !mid || !low)
return;
*low = *((uint32_t *)LOW_WORD_ADDR);
*mid = *((uint32_t *)MID_WORD_ADDR);
*high = *((uint32_t *)HIGH_WORD_ADDR);
}