Skip to content

Commit 3cd7251

Browse files
committed
added getDeviceId()
1 parent 46031de commit 3cd7251

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
CHANGELOG
22

3+
v 1.6
4+
- Added getDeviceId() to return the unique id for each device
5+
(see DeviceInfo sketch)
6+
37
v 1.5.1
48
- Added support for OSX (contributed by nitsky)
59
- RFDLoader now supports 32-bit and 64-bit osx snow leopard through mavericks
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
void setup() {
2+
Serial.begin(57600);
3+
4+
Serial.println("The device id is:");
5+
uint64_t id = getDeviceId();
6+
Serial.println(getDeviceIdLow(), HEX);
7+
Serial.println(getDeviceIdHigh(), HEX);
8+
}
9+
10+
void loop() {
11+
}

variants/RFduino/variant.cpp

100755100644
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,21 @@ uint8_t UART0_RX()
260260
return uc_data;
261261
}
262262

263+
uint32_t getDeviceIdLow()
264+
{
265+
return NRF_FICR->DEVICEID[0];
266+
}
267+
268+
uint32_t getDeviceIdHigh()
269+
{
270+
return NRF_FICR->DEVICEID[1];
271+
}
272+
273+
uint64_t getDeviceId()
274+
{
275+
return ((uint64_t)getDeviceIdHigh() << 32) | getDeviceIdLow();
276+
}
277+
263278
#ifdef __cplusplus
264279
}
265280
#endif

variants/RFduino/variant.h

100755100644
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ uint8_t UART0_RX();
166166

167167
#include "Memory.h"
168168

169+
// unique id for each unit
170+
uint32_t getDeviceIdLow();
171+
uint32_t getDeviceIdHigh();
172+
uint64_t getDeviceId();
173+
169174
#ifdef __cplusplus
170175
}
171176
#endif

0 commit comments

Comments
 (0)