Ethernet for Nucleo and Disco board STM32F746 works with gcc and arm. IAC is untested
Dependents: STM32F746_iothub_client_sample_mqtt DISCO-F746NG_Ethernet Nucleo_F746ZG_Ethernet thethingsiO-DISCO_F746NG-mqtt ... more
Diff: lwip-eth/arch/TARGET_STM/stm32f7_emac.c
- Revision:
- 1:28ba13dd96f7
- Parent:
- 0:d26c1b55cfca
--- a/lwip-eth/arch/TARGET_STM/stm32f7_emac.c Sun Jun 19 16:23:40 2016 +0000 +++ b/lwip-eth/arch/TARGET_STM/stm32f7_emac.c Thu Jun 23 09:04:23 2016 +0000 @@ -26,12 +26,7 @@ //#define EMAC_TRANSMIT_WAIT #define EMAC_T_WAIT 200 -#define MAC_ADDR_0 MBED_MAC_ADDR_0 -#define MAC_ADDR_1 MBED_MAC_ADDR_1 -#define MAC_ADDR_2 MBED_MAC_ADDR_2 -#define MAC_ADDR_3 MBED_MAC_ADDR_3 -#define MAC_ADDR_4 MBED_MAC_ADDR_4 -#define MAC_ADDR_5 MBED_MAC_ADDR_5 + /* LAN8742A PHY Address*/ #define LAN8742A_PHY_ADDRESS 0x00U @@ -48,6 +43,7 @@ __ALIGN_BEGIN uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE] __ALIGN_END; /* Ethernet Transmit Buffer */ +uint8_t macaddress[6]; ETH_HandleTypeDef heth; uint32_t phy_status = 0; @@ -255,10 +251,26 @@ */ static void stm32f7_low_level_init(struct netif *netif) { - uint8_t macaddress[6]= { MAC_ADDR_0, MAC_ADDR_1, MAC_ADDR_2, MAC_ADDR_3, MAC_ADDR_4, MAC_ADDR_5 }; - + HAL_StatusTypeDef hal_eth_init_status; - + uint8_t* sernoaddr=(uint8_t*)0x1FF0F420; + uint32_t serno =0; + uint32_t i; + uint8_t sernoid; + // sum over the Unique device ID register 96bits + for(i=0;i<12;i++) + { + serno=serno+sernoaddr[i]; + } + macaddress[0]=2; + macaddress[1]=0; + macaddress[2]=0; + sernoid=(serno>>16)&0xff; + macaddress[3]=sernoid; + sernoid=(serno>>8)&0xff; + macaddress[4]=sernoid; + sernoid=(serno)&0xff; + macaddress[5]=sernoid; /* Init ETH */ heth.Instance = ETH; @@ -608,17 +620,36 @@ */ err_t eth_arch_enetif_init(struct netif *netif) { + uint8_t* sernoaddr=0x1FF0F420; + uint32_t serno =0; + uint32_t i; + uint8_t sernoid; + // sum over the Unique device ID register 96bits + for(i=0;i<12;i++) + { + serno=serno+sernoaddr[i]; + } + macaddress[0]=2; + macaddress[1]=0; + macaddress[2]=0; + sernoid=(serno>>16)&0xff; + macaddress[3]=sernoid; + sernoid=(serno>>8)&0xff; + macaddress[4]=sernoid; + sernoid=(serno)&0xff; + macaddress[5]=sernoid; + /* set MAC hardware address */ netif->hwaddr_len = ETHARP_HWADDR_LEN; /* set netif MAC hardware address */ - netif->hwaddr[0] = MAC_ADDR_0; - netif->hwaddr[1] = MAC_ADDR_1; - netif->hwaddr[2] = MAC_ADDR_2; - netif->hwaddr[3] = MAC_ADDR_3; - netif->hwaddr[4] = MAC_ADDR_4; - netif->hwaddr[5] = MAC_ADDR_5; + netif->hwaddr[0] = macaddress[0]; + netif->hwaddr[1] = macaddress[1]; + netif->hwaddr[2] = macaddress[2]; + netif->hwaddr[3] = macaddress[3]; + netif->hwaddr[4] = macaddress[4]; + netif->hwaddr[5] = macaddress[5]; /* maximum transfer unit */ netif->mtu = 1500;