diff --git a/boards/derfmega256/Makefile.dep b/boards/derfmega256/Makefile.dep index 3d1c295b9b..d3281ed0a6 100644 --- a/boards/derfmega256/Makefile.dep +++ b/boards/derfmega256/Makefile.dep @@ -1 +1,5 @@ USEMODULE += boards_common_atmega + +ifneq (,$(filter eui_provider,$(USEMODULE))) + FEATURES_REQUIRED += periph_eeprom +endif diff --git a/boards/derfmega256/include/board.h b/boards/derfmega256/include/board.h index a28921631f..cf850d7cb6 100644 --- a/boards/derfmega256/include/board.h +++ b/boards/derfmega256/include/board.h @@ -21,10 +21,44 @@ #include "cpu.h" +#include "periph/eeprom.h" +#include "net/eui_provider.h" + #ifdef __cplusplus extern "C" { #endif +/** + * @name MAC configuration + * Offset of the MAC address in the EEPROM + */ +#define EEPROM_MAC_ADDR (0x1fe4) + +/** + * @brief Constant in EEPROM provides a EUI-64, this is also printed on the board + */ +static inline int _eeprom_mac_get_eui64(const void *arg, eui64_t *addr) +{ + (void) arg; + + if (eeprom_read(EEPROM_MAC_ADDR, addr, sizeof(eui64_t)) != sizeof(eui64_t)) { + return -1; + } + + addr->uint64.u64 = byteorder_htonll(addr->uint64.u64).u64; + + return 0; +} + +/** + * @name EUI-64 sources on the board + * @{ + */ +#define EUI64_PROVIDER_FUNC _eeprom_mac_get_eui64 +#define EUI64_PROVIDER_TYPE NETDEV_AT86RF2XX +#define EUI64_PROVIDER_INDEX 0 +/** @} */ + /** * @name xtimer configuration values * @{