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 
9 #pragma once
10 
20 #include "net/eui64.h"
21 #include "periph/eeprom.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
31 #define EEPROM_MAC_ADDR (0x1fe4)
32 
36 static inline int _eeprom_mac_get_eui64(uint8_t index, eui64_t *addr)
37 {
38  (void)index;
39 
40  if (eeprom_read(EEPROM_MAC_ADDR, addr, sizeof(eui64_t)) != sizeof(eui64_t)) {
41  return -1;
42  }
43 
44  addr->uint64.u64 = byteorder_htonll(addr->uint64.u64).u64;
45 
46  return 0;
47 }
48 
53 #define EUI64_PROVIDER_FUNC _eeprom_mac_get_eui64
54 #define EUI64_PROVIDER_TYPE NETDEV_AT86RF2XX
55 #define EUI64_PROVIDER_INDEX 0
58 #ifdef __cplusplus
59 }
60 #endif
61 
static network_uint64_t byteorder_htonll(uint64_t v)
Convert from host byte order to network byte order, 64 bit.
Definition: byteorder.h:498
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:96
Data type to represent an EUI-64.
Definition: eui64.h:55
network_uint64_t uint64
represented as 64 bit value
Definition: eui64.h:56