Skip to content

Commit 02bb0df

Browse files
committed
Merge pull request #1797 from 0xc0170/dev_k64f_hal_additions
k64f - mac address - fix warnings - get UID via K64F SIM macros
2 parents 4afc14d + 04e4c6a commit 02bb0df

File tree

1 file changed

+10
-9
lines changed
  • hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K64F/TARGET_FRDM

1 file changed

+10
-9
lines changed

hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K64F/TARGET_FRDM/mbed_overrides.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ void rtc_setup_oscillator(RTC_Type *base)
4444
// Provide ethernet devices with a semi-unique MAC address from the UUID
4545
void mbed_mac_address(char *mac)
4646
{
47+
uint16_t MAC[3]; // 3 16 bits words for the MAC
4748

48-
unsigned int UUID_LOC_BASE = 0x40048054; // First adddress of the 4-word UUID
49-
char uuid[16]; // So we can take a local copy of the UUID
50-
uint32_t MAC[3]; // 3 16 bits words for the MAC
51-
52-
// copy the UUID to the variable MAC[]
53-
memcpy(uuid,(const void*)UUID_LOC_BASE,sizeof(uuid));
49+
// get UID via SIM_UID macros defined in the K64F MCU CMSIS header file
50+
uint32_t UID[4];
51+
UID[0] = SIM->UIDH;
52+
UID[1] = SIM->UIDMH;
53+
UID[2] = SIM->UIDML;
54+
UID[3] = SIM->UIDL;
5455

5556
// generate three CRC16's using different slices of the UUID
56-
MAC[0] = crcSlow(uuid, 8); // most significant half-word
57-
MAC[1] = crcSlow(uuid, 12);
58-
MAC[2] = crcSlow(uuid, 16); // least significant half word
57+
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
58+
MAC[1] = crcSlow((const uint8_t *)UID, 12);
59+
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
5960

6061
// The network stack expects an array of 6 bytes
6162
// so we copy, and shift and copy from the half-word array to the byte array

0 commit comments

Comments
 (0)