diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep index 25878d84d0..e51c1100ad 100644 --- a/drivers/Makefile.dep +++ b/drivers/Makefile.dep @@ -42,6 +42,7 @@ endif ifneq (,$(filter cc2420,$(USEMODULE))) USEMODULE += xtimer + USEMODULE += uuid USEMODULE += netif USEMODULE += ieee802154 USEMODULE += netdev2_ieee802154 diff --git a/drivers/cc2420/cc2420.c b/drivers/cc2420/cc2420.c index b75ceafcde..abe8cde527 100644 --- a/drivers/cc2420/cc2420.c +++ b/drivers/cc2420/cc2420.c @@ -20,7 +20,7 @@ * @} */ -#include "periph/cpuid.h" +#include "uuid.h" #include "byteorder.h" #include "net/ieee802154.h" #include "net/gnrc.h" @@ -32,36 +32,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -/** - * @todo Move this function to a global module - */ -#if CPUID_ID_LEN -static void addr_from_cpuid(uint8_t *addr) -{ - /* option 1: generate addresses from CPUID */ - uint8_t cpuid[CPUID_ID_LEN]; - - cpuid_get(cpuid); - memcpy(addr, cpuid, 8); - -#if CPUID_ID_LEN < 8 - /* in case CPUID_ID_LEN < 8, fill missing bytes with zeros */ - for (int i = CPUID_ID_LEN; i < 8; i++) { - addr_long[i] = 0; - } -#else - /* in case CPUID_ID_LEN > 8, XOR those bytes on top of the first 8 */ - for (int i = 8; i < CPUID_ID_LEN; i++) { - addr_long[i & 0x07] ^= cpuid[i]; - } -#endif - - /* make sure we mark the address as non-multicast and not globally unique */ - addr_long[0] &= ~(0x01); - addr_long[0] |= 0x02; -} -#endif - void cc2420_setup(cc2420_t * dev, const cc2420_params_t *params) { @@ -78,16 +48,17 @@ void cc2420_setup(cc2420_t * dev, const cc2420_params_t *params) int cc2420_init(cc2420_t *dev) { uint16_t reg; - uint8_t addr[8] = CC2420_ADDR_FALLBACK; + uint8_t addr[8]; /* reset options and sequence number */ dev->netdev.seq = 0; dev->netdev.flags = 0; /* set default address, channel, PAN ID, and TX power */ -#if CPUID_ID_LEN - addr_from_cpuid(addr); -#endif + uuid_get(addr, sizeof(addr)); + /* make sure we mark the address as non-multicast and not globally unique */ + addr[0] &= ~(0x01); + addr[0] |= 0x02; cc2420_set_addr_short(dev, &addr[6]); cc2420_set_addr_long(dev, addr); cc2420_set_pan(dev, CC2420_PANID_DEFAULT); diff --git a/drivers/cc2420/cc2420_getset.c b/drivers/cc2420/cc2420_getset.c index bd5d749468..0a48092328 100644 --- a/drivers/cc2420/cc2420_getset.c +++ b/drivers/cc2420/cc2420_getset.c @@ -21,6 +21,7 @@ */ #include +#include #include "cc2420.h" #include "cc2420_internal.h" diff --git a/drivers/include/cc2420.h b/drivers/include/cc2420.h index ac4c80c3ed..c10d0cf0a5 100644 --- a/drivers/include/cc2420.h +++ b/drivers/include/cc2420.h @@ -38,14 +38,6 @@ extern "C" { */ #define CC2420_PKT_MAXLEN (IEEE802154_FRAME_LEN_MAX) -/** - * @brief Default addresses used if the CPUID module is not present - * - * In case this address is used, that short address will be created by using the - * last two bytes of the long address. - */ -#define CC2420_ADDR_FALLBACK {0x12, 0x22, 0x33, 0x44, 0x55, 0x66, 0x08, 0x15} - /** * @brief PAN ID configuration */