uniqueCPUID

Fork of uniqueCPUID by Joseph Ellsworth

Committer:
gastonfeng
Date:
Tue Oct 23 15:50:34 2018 +0800
Revision:
4:af0e9aaee2ed
Parent:
3:8ebd7b354018
json file

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeata2wh 0:b9461291f915 1 /*
joeata2wh 2:08766dc8051a 2 By Joseph Ellsworth CTO of A2WH
joeata2wh 2:08766dc8051a 3 Take a look at A2WH.com Producing Water from Air using Solar Energy
joeata2wh 2:08766dc8051a 4 March-2016 License: https://developer.mbed.org/handbook/MIT-Licence
joeata2wh 0:b9461291f915 5 Please contact us http://a2wh.com for help with custom design projects.
joeata2wh 0:b9461291f915 6
joeata2wh 2:08766dc8051a 7
joeata2wh 0:b9461291f915 8 Most STM and Freescale ARM chips include a unique Serail Number embedded
joeata2wh 0:b9461291f915 9 in the CPU. This is a perfect number to use in IoT as a SSID. I use
joeata2wh 0:b9461291f915 10 this to produce the WIFi SID so I can walk up with a phone and download
joeata2wh 0:b9461291f915 11 telemetry. I found a blog discussion for mbed that suggested using the
joeata2wh 0:b9461291f915 12 MAC but this assumes mbed hardware whereas this version uses the serial
joeata2wh 0:b9461291f915 13 number built in to the CPU so it should work on native boards.
joeata2wh 0:b9461291f915 14 */
joeata2wh 0:b9461291f915 15
joeata2wh 0:b9461291f915 16 #ifndef uniqueCPUID_h
joeata2wh 0:b9461291f915 17 #define uniqueCPUID_h
joeata2wh 0:b9461291f915 18 #include "mbed.h"
gastonfeng 3:8ebd7b354018 19 #include<string>
joeata2wh 0:b9461291f915 20 #define uniqueSerialAdd_kl_freescale (unsigned long *)0x40048058
gastonfeng 3:8ebd7b354018 21 #ifdef TARGET_STM32F0
gastonfeng 3:8ebd7b354018 22 #define uniqueSerialAddr_stm32 (unsigned long *)0x1FFFF7AC
gastonfeng 3:8ebd7b354018 23 #else
joeata2wh 0:b9461291f915 24 #define uniqueSerialAddr_stm32 (unsigned long *)0x1FFFF7E8
gastonfeng 3:8ebd7b354018 25 #endif
joeata2wh 0:b9461291f915 26
joeata2wh 0:b9461291f915 27 //TODO: Add logic to detect the different boards and select the correct
joeata2wh 0:b9461291f915 28 // CPU ID based on the active board.
joeata2wh 1:c7453c2b8a2f 29 //#define uniqueSerialAddr uniqueSerialAdd_kl_freescale
joeata2wh 1:c7453c2b8a2f 30 #define uniqueSerialAddr uniqueSerialAddr_stm32
joeata2wh 0:b9461291f915 31
joeata2wh 0:b9461291f915 32 // Change to enable for address for your chip family
joeata2wh 0:b9461291f915 33 // Note some ealry stm L3 chips were produced with all
joeata2wh 0:b9461291f915 34 // chip ID set to FFF. I have not seen any but did find
joeata2wh 0:b9461291f915 35 // it mentioned in a blog.
joeata2wh 0:b9461291f915 36
joeata2wh 0:b9461291f915 37
joeata2wh 0:b9461291f915 38 /* format the unique serial number as a string. we could use
joeata2wh 0:b9461291f915 39 as the router SID for Lot. Supress leading zeros to save
joeata2wh 0:b9461291f915 40 space */
joeata2wh 0:b9461291f915 41 void getUniqueIDAsStr(char *destStr);
joeata2wh 0:b9461291f915 42
joeata2wh 0:b9461291f915 43 /* Send unique device ID to serail port */
joeata2wh 0:b9461291f915 44 void printUniqueId(Serial pc);
gastonfeng 3:8ebd7b354018 45 std::string getUniqueIDAsString();
joeata2wh 0:b9461291f915 46 #endif