UUID read and print
main.cpp@7:b66c459fd169, 2015-04-21 (annotated)
- Committer:
- sam_grove
- Date:
- Tue Apr 21 23:52:25 2015 +0000
- Revision:
- 7:b66c459fd169
- Parent:
- 6:3deacf18cc07
- Child:
- 8:a9f1c2722cd9
update program to print UUID or MAC formatted UUID
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 0:496297783a79 | 1 | #include "mbed.h" |
sam_grove | 0:496297783a79 | 2 | |
sam_grove | 4:dd6505971fd2 | 3 | // new comment |
sam_grove | 4:dd6505971fd2 | 4 | |
sam_grove | 2:3d2e61cce12a | 5 | //#if defined(TARGET_K64F) |
sam_grove | 2:3d2e61cce12a | 6 | //#if defined(TARGET_LPC1768) |
sam_grove | 2:3d2e61cce12a | 7 | #if defined(TARGET_C027) |
sam_grove | 2:3d2e61cce12a | 8 | #error haha |
sam_grove | 2:3d2e61cce12a | 9 | #endif |
sam_grove | 2:3d2e61cce12a | 10 | |
sam_grove | 7:b66c459fd169 | 11 | int main() |
sam_grove | 7:b66c459fd169 | 12 | { |
sam_grove | 7:b66c459fd169 | 13 | unsigned int UUID_LOC_WORD0 = 0x40048060; |
sam_grove | 7:b66c459fd169 | 14 | unsigned int UUID_LOC_WORD1 = 0x4004805C; |
sam_grove | 7:b66c459fd169 | 15 | |
sam_grove | 7:b66c459fd169 | 16 | // Fetch word 0 |
sam_grove | 7:b66c459fd169 | 17 | uint32_t word0 = *(uint32_t *)UUID_LOC_WORD0; |
sam_grove | 7:b66c459fd169 | 18 | |
sam_grove | 7:b66c459fd169 | 19 | // Fetch word 1 |
sam_grove | 7:b66c459fd169 | 20 | // we only want bottom 16 bits of word1 (MAC bits 32-47) |
sam_grove | 7:b66c459fd169 | 21 | // and bit 9 forced to 1, bit 8 forced to 0 |
sam_grove | 7:b66c459fd169 | 22 | // Locally administered MAC, reduced conflicts |
sam_grove | 7:b66c459fd169 | 23 | // http://en.wikipedia.org/wiki/MAC_address |
sam_grove | 7:b66c459fd169 | 24 | uint32_t word1 = *(uint32_t *)UUID_LOC_WORD1; |
sam_grove | 7:b66c459fd169 | 25 | //word1 |= 0x00000200; |
sam_grove | 7:b66c459fd169 | 26 | //word1 &= 0x0000FEFF; |
sam_grove | 0:496297783a79 | 27 | |
sam_grove | 7:b66c459fd169 | 28 | //printf("%4x%08x", word1, word0); // Device id must be in lower case |
sam_grove | 7:b66c459fd169 | 29 | printf("%08x%08x", word1, word0); // Device id must be in lower case |
sam_grove | 7:b66c459fd169 | 30 | |
sam_grove | 7:b66c459fd169 | 31 | while(1); |
sam_grove | 0:496297783a79 | 32 | } |
sam_grove | 0:496297783a79 | 33 |