Merge pull request #2618 from mubes/alignment-warning

Fix alignment warning
This commit is contained in:
Scott Shawcroft 2020-02-18 13:54:24 -08:00 committed by GitHub
commit 2063867899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -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);
}