stm32/serialno: Cleaned up the inconsistencies in how DESIG_UNIQUE_ID_BASE is used in the serialno code
This commit is contained in:
parent
5a9131dcb2
commit
9a0e4b4f23
|
@ -23,7 +23,7 @@
|
||||||
char *serial_no_read(char *s)
|
char *serial_no_read(char *s)
|
||||||
{
|
{
|
||||||
#if DFU_SERIAL_LENGTH == 9
|
#if DFU_SERIAL_LENGTH == 9
|
||||||
const volatile uint32_t *const unique_id_p = (volatile uint32_t *)DESIG_UNIQUE_ID_BASE;
|
const volatile uint32_t *const unique_id_p = (uint32_t *)DESIG_UNIQUE_ID_BASE;
|
||||||
const uint32_t unique_id = unique_id_p[0] + unique_id_p[1] + unique_id_p[2];
|
const uint32_t unique_id = unique_id_p[0] + unique_id_p[1] + unique_id_p[2];
|
||||||
/* Fetch serial number from chip's unique ID */
|
/* Fetch serial number from chip's unique ID */
|
||||||
for(size_t i = 0; i < 8U; ++i) {
|
for(size_t i = 0; i < 8U; ++i) {
|
||||||
|
@ -34,7 +34,7 @@ char *serial_no_read(char *s)
|
||||||
}
|
}
|
||||||
#elif DFU_SERIAL_LENGTH == 13
|
#elif DFU_SERIAL_LENGTH == 13
|
||||||
/* Use the same serial number as the ST DFU Bootloader.*/
|
/* Use the same serial number as the ST DFU Bootloader.*/
|
||||||
const uint16_t *const uid = (uint16_t *)DESIG_UNIQUE_ID_BASE;
|
const volatile uint16_t *const uid = (uint16_t *)DESIG_UNIQUE_ID_BASE;
|
||||||
# if defined(STM32F4) || defined(STM32F7)
|
# if defined(STM32F4) || defined(STM32F7)
|
||||||
int offset = 3;
|
int offset = 3;
|
||||||
# elif defined(STM32L0) || defined(STM32F0) || defined(STM32F3)
|
# elif defined(STM32L0) || defined(STM32F0) || defined(STM32F3)
|
||||||
|
@ -42,7 +42,7 @@ char *serial_no_read(char *s)
|
||||||
# endif
|
# endif
|
||||||
sprintf(s, "%04X%04X%04X", uid[1] + uid[5], uid[0] + uid[4], uid[offset]);
|
sprintf(s, "%04X%04X%04X", uid[1] + uid[5], uid[0] + uid[4], uid[offset]);
|
||||||
#elif DFU_SERIAL_LENGTH == 25
|
#elif DFU_SERIAL_LENGTH == 25
|
||||||
volatile uint32_t *unique_id_p = (uint32_t *)DESIG_UNIQUE_ID_BASE;
|
const volatile uint32_t *const unique_id_p = (uint32_t *)DESIG_UNIQUE_ID_BASE;
|
||||||
uint32_t unique_id = 0;
|
uint32_t unique_id = 0;
|
||||||
for (size_t i = 0; i < 24U; ++i) {
|
for (size_t i = 0; i < 24U; ++i) {
|
||||||
const size_t chunk = i >> 3U;
|
const size_t chunk = i >> 3U;
|
||||||
|
|
Loading…
Reference in New Issue