Description: How to print the MAC address of an mbed to the dispBoB
macAddress.cpp@1:4012148564b2, 11 Jul 2011 (annotated)
- Committer:
- Date:
- Mon Jul 11 15:05:07 2011 +0000
- Revision:
- 1:4012148564b2
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| 1:4012148564b2 | 1 | #include "mbed.h" | |
| 1:4012148564b2 | 2 | #include "dispBoB.h" | |
| 1:4012148564b2 | 3 | #include "stdio.h" | |
| 1:4012148564b2 | 4 | ||
| 1:4012148564b2 | 5 | dispBoB db(p28, p27, p26); //object instantiation | |
| 1:4012148564b2 | 6 | extern "C" int mbed_mac_address(char *); | |
| 1:4012148564b2 | 7 | ||
| 1:4012148564b2 | 8 | int main() { | |
| 1:4012148564b2 | 9 | uint64_t uid = 0; | |
| 1:4012148564b2 | 10 | char mac[6]; | |
| 1:4012148564b2 | 11 | mbed_mac_address(mac); //this copies the MAC address into the | |
| 1:4012148564b2 | 12 | uid = mac[0] << 40 | mac[1] << 32 | //variable 'uid' | |
| 1:4012148564b2 | 13 | mac[2] << 24 | mac[3] << 16 | | |
| 1:4012148564b2 | 14 | mac[4] << 8 | mac[5] << 0; | |
| 1:4012148564b2 | 15 | char MACAddressBuffer[9]; | |
| 1:4012148564b2 | 16 | sprintf(MACAddressBuffer, "%x", uid); //convert type uint64_t --> char* (format hex) | |
| 1:4012148564b2 | 17 | db.scroll(MACAddressBuffer, 0.2); //scroll foramtted MAC address across dispBoB | |
| 1:4012148564b2 | 18 | } |

