File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_STM Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -431,3 +431,31 @@ void eth_arch_disable_interrupts(void)
431
431
{
432
432
NVIC_DisableIRQ (ETH_IRQn );
433
433
}
434
+
435
+ /** This returns a unique 6-byte MAC address, based on the device UID
436
+ * This function overrides hal/common/mbed_interface.c function
437
+ * @param mac A 6-byte array to write the MAC address
438
+ */
439
+ void mbed_mac_address (char * mac ) {
440
+ unsigned char ST_mac_addr [3 ] = {0x00 , 0x80 , 0xe1 }; // default STMicro mac address
441
+
442
+ // Read unic id
443
+ #if defined (TARGET_STM32F2 )
444
+ uint32_t word0 = * (uint32_t * )0x1FFF7A10 ;
445
+ #elif defined (TARGET_STM32F4 )
446
+ uint32_t word0 = * (uint32_t * )0x1FFF7A10 ;
447
+ #elif defined (TARGET_STM32F7 )
448
+ uint32_t word0 = * (uint32_t * )0x1FF0F420 ;
449
+ #else
450
+ #error MAC address can not be derived from target unique Id
451
+ #endif
452
+
453
+ mac [0 ] = ST_mac_addr [0 ];
454
+ mac [1 ] = ST_mac_addr [1 ];
455
+ mac [2 ] = ST_mac_addr [2 ];
456
+ mac [3 ] = (word0 & 0x00ff0000 ) >> 16 ;
457
+ mac [4 ] = (word0 & 0x0000ff00 ) >> 8 ;
458
+ mac [5 ] = (word0 & 0x000000ff );
459
+
460
+ return ;
461
+ }
You can’t perform that action at this time.
0 commit comments