drivers/enc28j60: used uuid module for addr gen
This commit is contained in:
parent
81e8afd19e
commit
4105011867
@ -61,6 +61,7 @@ endif
|
|||||||
ifneq (,$(filter enc28j60,$(USEMODULE)))
|
ifneq (,$(filter enc28j60,$(USEMODULE)))
|
||||||
USEMODULE += netdev2_eth
|
USEMODULE += netdev2_eth
|
||||||
USEMODULE += xtimer
|
USEMODULE += xtimer
|
||||||
|
USEMODULE += uuid
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter encx24j600,$(USEMODULE)))
|
ifneq (,$(filter encx24j600,$(USEMODULE)))
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "uuid.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
@ -30,10 +31,6 @@
|
|||||||
#include "enc28j60.h"
|
#include "enc28j60.h"
|
||||||
#include "enc28j60_regs.h"
|
#include "enc28j60_regs.h"
|
||||||
|
|
||||||
#if CPUID_LEN
|
|
||||||
#include "periph/cpuid.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
#include "debug.h"
|
#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) {
|
if (buf != NULL) {
|
||||||
#ifdef MODULE_NETSTATS_L2
|
#ifdef MODULE_NETSTATS_L2
|
||||||
netdev->stats.rx_count++;
|
netdev->stats.rx_count++;
|
||||||
netdev2->stats.rx_bytes += size;
|
netdev->stats.rx_bytes += size;
|
||||||
#endif
|
#endif
|
||||||
/* read packet content into the supplied buffer */
|
/* read packet content into the supplied buffer */
|
||||||
if (size <= max_len) {
|
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 */
|
/* set non-back-to-back inter packet gap -> 0x12 is default */
|
||||||
cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD);
|
cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD);
|
||||||
/* set default MAC address */
|
/* set default MAC address */
|
||||||
#if CPUID_LEN
|
uint8_t macbuf[ETHERNET_ADDR_LEN];
|
||||||
uint8_t macbuf[CPUID_LEN];
|
uuid_get(macbuf, ETHERNET_ADDR_LEN);
|
||||||
cpuid_get(&macbuf); /* we get the full ID but use only parts of it */
|
|
||||||
macbuf[0] |= 0x02; /* locally administered address */
|
macbuf[0] |= 0x02; /* locally administered address */
|
||||||
macbuf[0] &= ~0x01; /* unicast address */
|
macbuf[0] &= ~0x01; /* unicast address */
|
||||||
#else
|
|
||||||
uint8_t macbuf[] = ENC28J60_FALLBACK_MAC;
|
|
||||||
#endif
|
|
||||||
mac_set(dev, macbuf);
|
mac_set(dev, macbuf);
|
||||||
|
|
||||||
/* PHY configuration */
|
/* PHY configuration */
|
||||||
|
|||||||
@ -32,15 +32,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
* @brief Struct containing the needed peripheral configuration
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user