Update mbed_overrides.c

pull/1216/head
chris-styles 2015-06-30 08:46:17 +01:00
parent c60b81202c
commit 41ff2c8773
1 changed files with 12 additions and 9 deletions

View File

@ -34,6 +34,7 @@ void NMI_Handler(void)
// Provide ethernet devices with a semi-unique MAC address from the UUID
void mbed_mac_address(char *mac)
{
// Making a random-as-possible MAC from 3 16 bit seeds and load of XOR'ing
uint16_t MAC[3]; // 3 16 bits words for the MAC
uint32_t UUID_LOC_BASE = 0x40048054;
@ -50,20 +51,22 @@ void mbed_mac_address(char *mac)
}
}
mac[0] = MAC[2] >> 8;
mac[1] = MAC[2];
mac[2] = MAC[1] >> 8;
mac[3] = MAC[1];
mac[4] = MAC[0] >> 8;
mac[5] = MAC[0];
// we only want bottom 16 bits of word1 (MAC bits 32-47)
// and bit 9 forced to 1, bit 8 forced to 0
// Locally administered MAC, reduced conflicts
// http://en.wikipedia.org/wiki/MAC_address
// uint32_t word1 = *(uint32_t *)UUID_LOC_WORD1;
MAC[2] |= 0x0002;
MAC[2] &= 0xFFFE;
mac[0] = MAC[0];
mac[1] = MAC[0] >> 8;
mac[2] = MAC[1];
mac[3] = MAC[1] >> 8;
mac[4] = MAC[2];
mac[5] = MAC[2] >> 8;
mac[0] |= 0x02;
mac[0] &= 0xFE;
}