Helmut Tschemernjak / SX1276GenericLib

Dependents:   DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_USB_Rx ... more

Fork of SX1276Lib by Semtech

Files at this revision

API Documentation at this revision

Comitter:
Helmut Tschemernjak
Date:
Wed Aug 02 10:34:14 2017 +0200
Parent:
77:7f227a4dffe6
Child:
79:8ae448a3c1fd
Commit message:
Added CPUID function

Changed in this revision

Arduino-mbed-APIs/arduino-d21.cpp Show annotated file Show diff for this revision Revisions of this file
Arduino-mbed-APIs/arduino-mbed.h Show annotated file Show diff for this revision Revisions of this file
--- a/Arduino-mbed-APIs/arduino-d21.cpp	Mon Jul 31 16:11:17 2017 +0200
+++ b/Arduino-mbed-APIs/arduino-d21.cpp	Wed Aug 02 10:34:14 2017 +0200
@@ -19,6 +19,32 @@
  * __SAMD21G18A__ is Genuino Zero-Board (compatible with the LoRa board)
  */
 
+int
+CPUID(uint8_t *buf, int maxSize, uint32_t xorval)
+{
+    int f1 = 0x55d5f559; // D21 128-bit UUID, first 32 bit.
+    int f2 = 0x55d5f515; // D21 128-bit UUID, next 96 bit.
+
+    if (maxSize >= 16 ) {
+        int cnt = 0;
+        int fa = f1 ^ xorval;
+        uint32_t *first = (uint32_t *)fa;
+        uint8_t *dst = (uint8_t *)first;
+        for (int i = 0; i < sizeof(uint32_t); i++)
+        	*buf++ = *dst++;
+        cnt += 4;
+        int fb = f2 ^ xorval;
+        uint32_t *next = (uint32_t *)fb;
+        dst = (uint8_t *)next;
+        for (int i = 0; i < sizeof(uint32_t)*3; i++)
+        	*buf++ = *dst++;
+        cnt += 12;
+        return cnt;
+    }
+    
+    return 0;
+}
+
 /*
  * see tcc.h is automatically included from:
  * Arduino15/packages/arduino/tools/CMSIS-Atmel/1.1.0/CMSIS/
--- a/Arduino-mbed-APIs/arduino-mbed.h	Mon Jul 31 16:11:17 2017 +0200
+++ b/Arduino-mbed-APIs/arduino-mbed.h	Wed Aug 02 10:34:14 2017 +0200
@@ -38,6 +38,7 @@
 extern void stopTimer(Tcc *t);
 extern uint64_t ns_getTicker(void);
 extern Tcc *getTimeout_tcc(void);
+extern int CPUID(uint8_t *buf, int maxSize, uint32_t xorval);
 
 
 extern void sleep(void);