diff options
author | root <root@lab.ourano.james.local> | 2021-02-26 12:12:38 +0000 |
---|---|---|
committer | root <root@lab.ourano.james.local> | 2021-02-26 12:12:38 +0000 |
commit | 3d48137c00511b3f2d35511482d1a76f8d06382d (patch) | |
tree | d75c88220cc847007869b0795a240c5077948262 /app/steth.c | |
parent | 6d3a824e1cdae6e28146b7de380724b49488f3c2 (diff) | |
download | clock-3d48137c00511b3f2d35511482d1a76f8d06382d.tar.gz clock-3d48137c00511b3f2d35511482d1a76f8d06382d.tar.bz2 clock-3d48137c00511b3f2d35511482d1a76f8d06382d.zip |
works
Diffstat (limited to 'app/steth.c')
-rw-r--r-- | app/steth.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/app/steth.c b/app/steth.c index 26429aa..5b94e1d 100644 --- a/app/steth.c +++ b/app/steth.c @@ -14,7 +14,7 @@ static int ready; static uint8_t __attribute__ ((aligned (4))) eth_buf[ETH_BUF_LEN]; -static uint8_t sa[ETHARP_HWADDR_LEN] = { 0xc0, 0xf1, 0xee, 0xc0, 0xff, 0xdd }; +static uint8_t sa[ETHARP_HWADDR_LEN]; extern uint32_t TxBD; extern uint32_t RxBD; @@ -32,6 +32,29 @@ extern uint32_t RxBD; +void steth_calculate_mac(void) +{ + uint32_t uid[3]; + uint8_t *ptr; + unsigned i; + desig_get_unique_id (uid); + + ptr=(uint8_t *)uid; + + for (i=0;i<ETHARP_HWADDR_LEN;++i) + sa[i]^=*(ptr++); + for (i=0;i<ETHARP_HWADDR_LEN;++i) + sa[i]^=*(ptr++); + + sa[0]&=0xfe; /*Clear I/G */ + sa[0]|=0x2; /*Set U/L */ + +printf("MAC ADDRESS is %02x:%02x:%02x:%02x:%02x:%02x\r\n",sa[0],sa[1],sa[2],sa[3],sa[4],sa[5]); +} + + + + static void mac_stat (void) { //uint32_t d, s; @@ -122,6 +145,7 @@ steth_rx (void) struct pbuf *p; uint32_t len; + p = pbuf_alloc (PBUF_RAW, MTU, PBUF_POOL); if (!p) return ERR_MEM; @@ -166,6 +190,7 @@ steth_lwip_init (struct netif *netif) { LWIP_ASSERT ("netif != NULL", (netif != NULL)); + #if LWIP_NETIF_HOSTNAME /* Initialize interface hostname */ netif->hostname = "lwip"; @@ -297,8 +322,8 @@ static void eth_reset (void) phy_stat(); eth_set_mac (sa); - eth_enable_checksum_offload(); eth_desc_init (eth_buf, TX_BUFS, RX_BUFS, FRAME_SZ, FRAME_SZ, 1); + // eth_enable_checksum_offload(); eth_irq_enable (ETH_DMAIER_NISE); eth_irq_enable (ETH_DMAIER_RIE); @@ -314,6 +339,8 @@ static void eth_start_an (void) phy_autoneg_enable (PHY); } + + void steth_init (void) { |