eui_provider_params.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 ML!PA Consulting GmbH
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
18 #ifndef EUI_PROVIDER_PARAMS_H
19 #define EUI_PROVIDER_PARAMS_H
20 
21 #include "net/eui64.h"
22 #include "periph/eeprom.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 #define EEPROM_MAC_ADDR (0x1fe4)
33 
37 static inline int _eeprom_mac_get_eui64(uint8_t index, eui64_t *addr)
38 {
39  (void)index;
40 
41  if (eeprom_read(EEPROM_MAC_ADDR, addr, sizeof(eui64_t)) != sizeof(eui64_t)) {
42  return -1;
43  }
44 
45  addr->uint64.u64 = byteorder_htonll(addr->uint64.u64).u64;
46 
47  return 0;
48 }
49 
54 #define EUI64_PROVIDER_FUNC _eeprom_mac_get_eui64
55 #define EUI64_PROVIDER_TYPE NETDEV_AT86RF2XX
56 #define EUI64_PROVIDER_INDEX 0
59 #ifdef __cplusplus
60 }
61 #endif
62 
63 #endif /* EUI_PROVIDER_PARAMS_H */
static network_uint64_t byteorder_htonll(uint64_t v)
Convert from host byte order to network byte order, 64 bit.
Definition: byteorder.h:499
static int _eeprom_mac_get_eui64(uint8_t index, eui64_t *addr)
Constant in EEPROM provides a EUI-64, this is also printed on the board.
Low-level eeprom driver interface.
EUI-64 data type definition.
size_t eeprom_read(uint32_t pos, void *data, size_t len)
Read len bytes from the given position.
uint64_t u64
64 bit representation
Definition: byteorder.h:97
Data type to represent an EUI-64.
Definition: eui64.h:55
network_uint64_t uint64
represented as 64 bit value
Definition: eui64.h:56