Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:f82a1ca216d4
- Child:
- 1:28e9d3ed6106
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Sep 29 23:04:18 2014 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "IAP.h"
+
+DigitalOut led(LED1);
+
+char *readUUID(void)
+{
+ static char buf[64] = {0};
+ IAP iap;
+ int32_t *block = iap.read_serial();
+ uint32_t serial_number[5] = {0};
+
+ memset(buf, 0, sizeof(buf));
+ serial_number[0] = *(block);
+ serial_number[1] = *(block+1);
+ // we only want bottom 16 bits of word1 (MAC bits 32-47)
+ // and bit 9 forced to 1, bit 8 forced to 0
+ // Locally administered MAC, reduced conflicts
+ // http://en.wikipedia.org/wiki/MAC_address
+ serial_number[0] |= 0x00000200;
+ serial_number[0] &= 0x0000FEFF;
+
+ snprintf(buf, 16, "%4X%08X", serial_number[0], serial_number[1]);
+
+ return buf;
+}
+
+int main(void)
+{
+ printf("%s\n", readUUID());
+
+ while(1) {
+ led = !led;
+ wait(0.5f);
+ }
+}