Library for inclusion of main.cpp -forked

Dependents:   df-2014-workshop-rfid-case-generator-k64f df-2014-rfid-case-gen-k64f-complete df-2014-rfid-case-gen-k64f-exercise

Fork of EndpointMain by Doug Anson

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Tue Oct 07 18:42:47 2014 +0000
Parent:
2:55b1877a3a14
Commit message:
updates for mac generation on K64F

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 55b1877a3a14 -r 1d8589377a86 main.cpp
--- a/main.cpp	Fri Sep 26 04:34:23 2014 +0000
+++ b/main.cpp	Tue Oct 07 18:42:47 2014 +0000
@@ -32,6 +32,30 @@
  
  // StatusReporter
  #include "StatusReporter.h"
+ 
+ #if _K64F_PLATFORM
+ // the K64F does not have a unique MAC address - so we must give it one... 
+ extern "C" void mbed_mac_address(char *mac)
+ {
+    // Fetch word 0
+    uint32_t word0 = *(uint32_t *)0x40048060;
+    // Fetch word 1
+    // we only want bottom 16 bits of word1 (MAC bits 32-47)
+    // and bit 9 forced to 1, bit 8 forced to 0
+    // Locally administered MAC, reduced conflicts
+    // http://en.wikipedia.org/wiki/MAC_address
+    uint32_t word1 = *(uint32_t *)0x4004805C;
+    word1 |= 0x00000200;
+    word1 &= 0x0000FEFF;
+    
+    mac[0] = (word1 & 0x000000ff);
+    mac[1] = (word1 & 0x0000ff00) >> 8;
+    mac[2] = (word0 & 0xff000000) >> 24;
+    mac[3] = (word0 & 0x00ff0000) >> 16;
+    mac[4] = (word0 & 0x0000ff00) >> 8;
+    mac[5] = (word0 & 0x000000ff);
+ }
+ #endif // _K64F_PLATFORM
   
  // Main Task...
  void mainTask(void const *v) {