summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-02-18 13:54:24 -0800
committerGitHub <noreply@github.com>2020-02-18 13:54:24 -0800
commit2063867899d66a86fa60bd5be4b4ac3d4a9ecff6 (patch)
treed12435f2a71b47028b476fdedb2a604a850491ce
parent850e655a4c62c6abc497ff691008865e3be599b9 (diff)
parent77ad9aff3cd91d1f81f81ab7369fc5996277cdcd (diff)
Merge pull request #2618 from mubes/alignment-warning
Fix alignment warning
-rw-r--r--ports/mimxrt10xx/common-hal/microcontroller/Processor.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c
index 23493f766..0c8131ef4 100644
--- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c
+++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c
@@ -58,8 +58,13 @@ 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)
- for (int i = 0; i < 4; ++i)
- ((uint32_t*) raw_id)[i] = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
-
+ // 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;
+ }
+ }
OCOTP_Deinit(OCOTP);
}