From 410501186711a325c899fd3738e2cc01b342f6df Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Tue, 10 Jan 2017 15:15:16 +0100 Subject: [PATCH] drivers/enc28j60: used uuid module for addr gen --- drivers/Makefile.dep | 1 + drivers/enc28j60/enc28j60.c | 15 ++++----------- drivers/include/enc28j60.h | 9 --------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep index 40425d1ea2..bab106b7d1 100644 --- a/drivers/Makefile.dep +++ b/drivers/Makefile.dep @@ -61,6 +61,7 @@ endif ifneq (,$(filter enc28j60,$(USEMODULE))) USEMODULE += netdev2_eth USEMODULE += xtimer + USEMODULE += uuid endif ifneq (,$(filter encx24j600,$(USEMODULE))) diff --git a/drivers/enc28j60/enc28j60.c b/drivers/enc28j60/enc28j60.c index 5a7616dafa..848d8ad3cd 100644 --- a/drivers/enc28j60/enc28j60.c +++ b/drivers/enc28j60/enc28j60.c @@ -21,6 +21,7 @@ #include #include +#include "uuid.h" #include "mutex.h" #include "xtimer.h" #include "assert.h" @@ -30,10 +31,6 @@ #include "enc28j60.h" #include "enc28j60_regs.h" -#if CPUID_LEN -#include "periph/cpuid.h" -#endif - #define ENABLE_DEBUG (0) #include "debug.h" @@ -269,7 +266,7 @@ static int nd_recv(netdev2_t *netdev, void *buf, size_t max_len, void *info) if (buf != NULL) { #ifdef MODULE_NETSTATS_L2 netdev->stats.rx_count++; - netdev2->stats.rx_bytes += size; + netdev->stats.rx_bytes += size; #endif /* read packet content into the supplied buffer */ if (size <= max_len) { @@ -354,14 +351,10 @@ static int nd_init(netdev2_t *netdev) /* set non-back-to-back inter packet gap -> 0x12 is default */ cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD); /* set default MAC address */ -#if CPUID_LEN - uint8_t macbuf[CPUID_LEN]; - cpuid_get(&macbuf); /* we get the full ID but use only parts of it */ + uint8_t macbuf[ETHERNET_ADDR_LEN]; + uuid_get(macbuf, ETHERNET_ADDR_LEN); macbuf[0] |= 0x02; /* locally administered address */ macbuf[0] &= ~0x01; /* unicast address */ -#else - uint8_t macbuf[] = ENC28J60_FALLBACK_MAC; -#endif mac_set(dev, macbuf); /* PHY configuration */ diff --git a/drivers/include/enc28j60.h b/drivers/include/enc28j60.h index 0eb2330ce4..87b61a03fa 100644 --- a/drivers/include/enc28j60.h +++ b/drivers/include/enc28j60.h @@ -32,15 +32,6 @@ extern "C" { #endif -/** - * @brief Fallback MAC address in case CPUID is not available - * - * The enc28j60 does not provide a globally unique, pre-set MAC address, so we - * need to create one. For this the CPUID module is used to create a locally - * administered MAC. If this is not available, we use the MAC address below. - */ -#define ENC28J60_FALLBACK_MAC {0x02, 0x22, 0x33, 0x44, 0x55, 0x66} - /** * @brief Struct containing the needed peripheral configuration */