Small program to read the Part ID and Device Serial Number using IAP commands.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dminear
Date:
Fri Nov 09 04:04:47 2012 +0000
Commit message:
Initial release of code to get the device serial number.

Changed in this revision

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
diff -r 000000000000 -r ec398694bd6f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 09 04:04:47 2012 +0000
@@ -0,0 +1,55 @@
+/*
+ * How to read LPC1768 part ID and device serial number
+ * Dan Minear
+ * 2012-11-08
+ */
+ 
+#include "mbed.h"
+
+#define IAP_LOCATION 0x1FFF1FF1
+
+typedef void (*IAP)(unsigned long [], unsigned long[] );
+IAP iap_entry = (IAP) IAP_LOCATION;
+
+DigitalOut myled(LED1);
+
+int main() {
+    unsigned long command[5] = {0,0,0,0,0};
+    unsigned long result[5] = {0,0,0,0,0};
+
+    printf("\r\nStart...\r\n");
+    
+    // See User Manual section 32.8.5
+    command[0] = 54;    // partID
+    printf("\r\nPart ID: (should be 0x2601 3F37 for LPC1768)\r\n");
+    iap_entry(command, result);
+    if (result[0] == 0) {
+        for(int i = 1; i < 2; i++) {
+            printf( "0x%x\r\n", result[i] );
+        }
+    } else {
+        printf("Status error!\r\n");
+    }
+    
+    // See User Manual section 32.8.7
+    command[0] = 58;  // read device serial number
+    printf("\r\nSerial number:\r\n");
+    iap_entry(command, result);
+    if (result[0] == 0) {
+        for(int i = 1; i < 5; i++) {
+            printf( "0x%x\r\n", result[i] );
+        }
+    } else {
+        printf("Status error!\r\n");
+    }
+        
+    printf( "\r\nEnd\r\n" );
+        
+    // and now back to the default new project, just flash a LED
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
diff -r 000000000000 -r ec398694bd6f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Nov 09 04:04:47 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06
\ No newline at end of file