From 4de2a1eb6224dbb218c80f652bf0ed36f2ac29f4 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Wed, 12 Feb 2020 22:36:34 +0000 Subject: [PATCH 1/3] Fix alignment warning --- .../mimxrt10xx/common-hal/microcontroller/Processor.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index 23493f766..6b0a15185 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -58,8 +58,17 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk)); // Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info) + // into 8 bit wide destination, avoiding punning. for (int i = 0; i < 4; ++i) - ((uint32_t*) raw_id)[i] = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); + { + uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); + + for (int j = 0; j < 4; j++) + { + raw_id[i*4+j] = wr&0xff; + wr>>=8; + } + } OCOTP_Deinit(OCOTP); } From d13f04f9534813ab1c1d975350961bfc0f5b7f67 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Fri, 14 Feb 2020 23:02:02 +0000 Subject: [PATCH 2/3] Updated formatting --- .../common-hal/microcontroller/Processor.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index 6b0a15185..fdec73f47 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -59,16 +59,12 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { // Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info) // into 8 bit wide destination, avoiding punning. - for (int i = 0; i < 4; ++i) - { - uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); - - for (int j = 0; j < 4; j++) - { - raw_id[i*4+j] = wr&0xff; - wr>>=8; - } - } - + for (int i = 0; i < 4; ++i) { + uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); + for (int j = 0; j < 4; j++) { + raw_id[i*4+j] = wr&0xff; + wr>>=8; + } + } OCOTP_Deinit(OCOTP); } From 77ad9aff3cd91d1f81f81ab7369fc5996277cdcd Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Sun, 16 Feb 2020 00:40:04 +0000 Subject: [PATCH 3/3] Formatting updates --- ports/mimxrt10xx/common-hal/microcontroller/Processor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index fdec73f47..0c8131ef4 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -62,8 +62,8 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { for (int i = 0; i < 4; ++i) { uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1); for (int j = 0; j < 4; j++) { - raw_id[i*4+j] = wr&0xff; - wr>>=8; + raw_id[i*4+j] = wr & 0xff; + wr >>= 8; } } OCOTP_Deinit(OCOTP);