1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/enc28j60: used uuid module for addr gen

This commit is contained in:
Hauke Petersen 2017-01-10 15:15:16 +01:00
parent 81e8afd19e
commit 4105011867
3 changed files with 5 additions and 20 deletions

View File

@ -61,6 +61,7 @@ endif
ifneq (,$(filter enc28j60,$(USEMODULE)))
USEMODULE += netdev2_eth
USEMODULE += xtimer
USEMODULE += uuid
endif
ifneq (,$(filter encx24j600,$(USEMODULE)))

View File

@ -21,6 +21,7 @@
#include <errno.h>
#include <string.h>
#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 */

View File

@ -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
*/