Library to pull unique device ID from CPU chip. functions to load into a string that can be used in IoT access point ID and another to send the ID back on serial port. Tested on KL46Z but should work on STM and others by changing address where ID is located.

Dependents:   stm32_print_unique_serial_number_copy bcsdk bcsdk bcsdk-sdchain

Revision:
0:b9461291f915
Child:
1:c7453c2b8a2f
diff -r 000000000000 -r b9461291f915 uniqueCPUID.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uniqueCPUID.h	Wed Mar 09 18:04:45 2016 +0000
@@ -0,0 +1,39 @@
+/*
+  by Joseph Ellsworth CTO A2WH.
+  Freeuse for all.  No promises,  No warranty *
+  Please contact us http://a2wh.com for help with custom design projects.
+
+  Most STM and Freescale ARM chips include a unique Serail Number embedded
+  in the CPU.  This is a perfect number to use in IoT as a SSID.  I use
+  this to produce the WIFi SID so I can walk up with a phone and download
+  telemetry.   I found a blog discussion for mbed that suggested using the
+  MAC but this assumes mbed hardware whereas this version uses the serial
+  number built in to the CPU so it should work on native boards.
+*/
+
+#ifndef uniqueCPUID_h
+#define uniqueCPUID_h
+#include "mbed.h"
+
+#define uniqueSerialAdd_kl_freescale (unsigned long *)0x40048058
+#define uniqueSerialAddr_stm32 (unsigned long *)0x1FFFF7E8
+
+//TODO: Add logic to detect the different boards and select the correct
+//  CPU ID based on the active board.
+#define uniqueSerialAddr uniqueSerialAdd_kl_freescale
+
+// Change to enable for address for your chip family
+// Note some ealry stm L3 chips were produced with all
+// chip ID set to FFF.  I have not seen any but did find
+// it mentioned in a blog.
+
+
+/* format the unique serial number as a string. we could use
+as the router SID for Lot.  Supress leading zeros to save
+space */
+void getUniqueIDAsStr(char *destStr);
+
+/* Send unique device ID to serail port */
+void printUniqueId(Serial pc);
+
+#endif