drivers/w5100: use uuid_get() for HW addr gen
This commit is contained in:
parent
ab2339cc95
commit
8624456efe
@ -152,6 +152,7 @@ endif
|
|||||||
|
|
||||||
ifneq (,$(filter w5100,$(USEMODULE)))
|
ifneq (,$(filter w5100,$(USEMODULE)))
|
||||||
USEMODULE += netdev2_eth
|
USEMODULE += netdev2_eth
|
||||||
|
USEMODULE += uuid
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter xbee,$(USEMODULE)))
|
ifneq (,$(filter xbee,$(USEMODULE)))
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2016 Freie Universität Berlin
|
* Copyright (C) 2016-2017 Freie Universität Berlin
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
* General Public License v2.1. See the file LICENSE in the top level
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
@ -22,8 +22,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "uuid.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "periph/cpuid.h"
|
|
||||||
|
|
||||||
#include "net/ethernet.h"
|
#include "net/ethernet.h"
|
||||||
#include "net/netdev2/eth.h"
|
#include "net/netdev2/eth.h"
|
||||||
@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
#define SPI_CONF SPI_CONF_FIRST_RISING
|
#define SPI_CONF SPI_CONF_FIRST_RISING
|
||||||
#define RMSR_DEFAULT_VALUE (0x55)
|
#define RMSR_DEFAULT_VALUE (0x55)
|
||||||
#define MAC_SEED (0x23)
|
|
||||||
|
|
||||||
#define S0_MEMSIZE (0x2000)
|
#define S0_MEMSIZE (0x2000)
|
||||||
#define S0_MASK (S0_MEMSIZE - 1)
|
#define S0_MASK (S0_MEMSIZE - 1)
|
||||||
@ -143,9 +142,6 @@ static int init(netdev2_t *netdev)
|
|||||||
w5100_t *dev = (w5100_t *)netdev;
|
w5100_t *dev = (w5100_t *)netdev;
|
||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
uint8_t hwaddr[ETHERNET_ADDR_LEN];
|
uint8_t hwaddr[ETHERNET_ADDR_LEN];
|
||||||
#if CPUID_LEN
|
|
||||||
uint8_t cpuid[CPUID_LEN];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* test the SPI connection by reading the value of the RMSR register */
|
/* test the SPI connection by reading the value of the RMSR register */
|
||||||
tmp = rreg(dev, REG_TMSR);
|
tmp = rreg(dev, REG_TMSR);
|
||||||
@ -159,13 +155,7 @@ static int init(netdev2_t *netdev)
|
|||||||
while (rreg(dev, REG_MODE) & MODE_RESET) {};
|
while (rreg(dev, REG_MODE) & MODE_RESET) {};
|
||||||
|
|
||||||
/* initialize the device, start with writing the MAC address */
|
/* initialize the device, start with writing the MAC address */
|
||||||
memset(hwaddr, MAC_SEED, ETHERNET_ADDR_LEN);
|
uuid_get(hwaddr, ETHERNET_ADDR_LEN);
|
||||||
#if CPUID_LEN
|
|
||||||
cpuid_get(cpuid);
|
|
||||||
for (int i = 0; i < CPUID_LEN; i++) {
|
|
||||||
hwaddr[i % ETHERNET_ADDR_LEN] ^= cpuid[i];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
hwaddr[0] &= ~0x03; /* no group address and not globally unique */
|
hwaddr[0] &= ~0x03; /* no group address and not globally unique */
|
||||||
wchunk(dev, REG_SHAR0, hwaddr, ETHERNET_ADDR_LEN);
|
wchunk(dev, REG_SHAR0, hwaddr, ETHERNET_ADDR_LEN);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user