example LPC1768 uuid from serial

Dependencies:   IAP mbed

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Mon Sep 29 23:04:18 2014 +0000
Child:
1:28e9d3ed6106
Commit message:
Hello world example

Changed in this revision

IAP.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IAP.lib	Mon Sep 29 23:04:18 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/sam_grove/code/IAP/#f794a51897b8
--- /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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 29 23:04:18 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file