UUID read and print

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 int main()
00004 {
00005     unsigned int UUID_LOC_WORD0 = 0x40048060;
00006     unsigned int UUID_LOC_WORD1 = 0x4004805C;
00007     unsigned int UUID_LOC_WORD2 = 0x40048058;
00008     unsigned int UUID_LOC_WORD3 = 0x40048054;
00009 
00010     // Fetch word 0
00011     uint32_t word0 = *(uint32_t *)UUID_LOC_WORD0;
00012 
00013     // Fetch word 1
00014     // we only want bottom 16 bits of word1 (MAC bits 32-47)
00015     // and bit 9 forced to 1, bit 8 forced to 0
00016     // Locally administered MAC, reduced conflicts
00017     // http://en.wikipedia.org/wiki/MAC_address
00018     uint32_t word1 = *(uint32_t *)UUID_LOC_WORD1;
00019     //word1 |= 0x00000200;
00020     //word1 &= 0x0000FEFF;
00021     
00022     uint32_t word2 = *(uint32_t *)UUID_LOC_WORD2;
00023     uint32_t word3 = *(uint32_t *)UUID_LOC_WORD3;
00024     
00025     //printf("%4x%08x", word1, word0);   // Device id must be in lower case
00026     printf("%08x%08x%08x%08x", word3, word2, word1, word0);   // Device id must be in lower case
00027     
00028     while(1);
00029 }
00030