File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K64F/TARGET_FRDM Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -44,18 +44,19 @@ void rtc_setup_oscillator(RTC_Type *base)
44
44
// Provide ethernet devices with a semi-unique MAC address from the UUID
45
45
void mbed_mac_address (char * mac )
46
46
{
47
+ uint16_t MAC [3 ]; // 3 16 bits words for the MAC
47
48
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 ;
54
55
55
56
// 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
59
60
60
61
// The network stack expects an array of 6 bytes
61
62
// so we copy, and shift and copy from the half-word array to the byte array
You can’t perform that action at this time.
0 commit comments