cc2538_eui_primary.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 
21 #include "net/eui64.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define CC2538_EUI64_LOCATION_PRI (0x00280028)
28 #define CC2538_EUI64_LOCATION_SEC (0x0027FFCC)
38 static inline int cc2538_get_eui64_primary(uint8_t index, eui64_t *addr)
39 {
40  (void)index;
41 
42  /*
43  * The primary EUI-64 seems to be written to memory in a non-sequential
44  * byte order, with both 4-byte halves of the address flipped.
45  */
46  addr->uint8[7] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[4];
47  addr->uint8[6] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[5];
48  addr->uint8[5] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[6];
49  addr->uint8[4] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[7];
50  addr->uint8[3] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[0];
51  addr->uint8[2] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[1];
52  addr->uint8[1] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[2];
53  addr->uint8[0] = ((uint8_t*)CC2538_EUI64_LOCATION_PRI)[3];
54 
55  return 0;
56 }
57 
62 #ifndef CC2538_EUI64_CUSTOM
63 #define EUI64_PROVIDER_FUNC cc2538_get_eui64_primary
64 #define EUI64_PROVIDER_TYPE NETDEV_CC2538
65 #define EUI64_PROVIDER_INDEX 0
66 #endif /* !CC2538_EUI64_CUSTOM */
69 #ifdef __cplusplus
70 } /* end extern "C" */
71 #endif
72 
static int cc2538_get_eui64_primary(uint8_t index, eui64_t *addr)
Get the primary (burned-in) EUI-64 of the device.
#define CC2538_EUI64_LOCATION_PRI
Primary EUI-64 address location.
EUI-64 data type definition.
Data type to represent an EUI-64.
Definition: eui64.h:55
uint8_t uint8[8]
split into 8 8-bit words.
Definition: eui64.h:57