board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Alexander Chudov <chudov@gmail.com>
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 
19 #ifndef BOARD_H
20 #define BOARD_H
21 
22 #include "cpu.h"
23 
24 #include "periph/eeprom.h"
25 #include "net/eui_provider.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #define EEPROM_MAC_ADDR (0x1fe4)
36 
40 static inline int _eeprom_mac_get_eui64(const void *arg, eui64_t *addr)
41 {
42  (void) arg;
43 
44  if (eeprom_read(EEPROM_MAC_ADDR, addr, sizeof(eui64_t)) != sizeof(eui64_t)) {
45  return -1;
46  }
47 
48  addr->uint64.u64 = byteorder_htonll(addr->uint64.u64).u64;
49 
50  return 0;
51 }
52 
57 #define EUI64_PROVIDER_FUNC _eeprom_mac_get_eui64
58 #define EUI64_PROVIDER_TYPE NETDEV_AT86RF2XX
59 #define EUI64_PROVIDER_INDEX 0
60 
66 #define XTIMER_WIDTH (16)
67 #define XTIMER_HZ (CLOCK_CORECLOCK / 64)
68 #define XTIMER_BACKOFF (40)
69 
75 void board_init(void);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /* BOARD_H */
82 
eui64_t::uint64
network_uint64_t uint64
represented as 64 bit value
Definition: eui64.h:56
eeprom_read
size_t eeprom_read(uint32_t pos, void *data, size_t len)
Read len bytes from the given position.
eui_provider.h
EUI-48 and EUI-64 address provider.
eeprom.h
Low-level eeprom driver interface.
_eeprom_mac_get_eui64
static int _eeprom_mac_get_eui64(const void *arg, eui64_t *addr)
Constant in EEPROM provides a EUI-64, this is also printed on the board.
Definition: board.h:40
eui64_t
Data type to represent an EUI-64.
Definition: eui64.h:55
be_uint64_t::u64
uint64_t u64
64 bit representation
Definition: byteorder.h:100
board_init
void board_init(void)
Board level initialization.
byteorder_htonll
static network_uint64_t byteorder_htonll(uint64_t v)
Convert from host byte order to network byte order, 64 bit.
Definition: byteorder.h:451