Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
38:9070c17536cd
Parent:
21:ce51bb0ba4a5
Child:
40:1324da35afd4
--- a/SnCRCUtils.h	Wed May 29 00:20:31 2013 +0000
+++ b/SnCRCUtils.h	Wed May 29 18:54:19 2013 +0000
@@ -1,6 +1,8 @@
 #ifndef SN_SnCRCUtils
 #define SN_SnCRCUtils
 
+namespace SnCRCUtils {
+
 /*******************************************************************\
 *   CRC code "borrowed" from:                                       *
 *   http://mbed.org/users/jpelletier/programs/CRC/lje513            *
@@ -63,6 +65,29 @@
     return update_crc32_normal(crc_tabxfer_normal,crc,c);
 }
 
+//
+// calculate CRC for data set
+//
+template<typename T>
+static
+uint32_t GetCRC32for(const T* data, const uint32_t len) {
+    // calculate the 32bit CRC for an array of data
+    // len = number of array elements; not number of bytes
+  
+    union {
+        const T* x;
+        const uint8_t* c;
+    } d;
+    d.x = data;
+    uint32_t crc(0);
+    const uint32_t bytes = len * sizeof(T);
+    for (register uint32_t i=0; i<bytes; ++i, ++d.c) {
+        crc = update_crc32_xfer(crc, *(d.c));
+    }
+    return crc;
+}
+
+/*
 inline
 uint32_t update_crc32_xfer_short( uint32_t crc, const uint16_t c) {
     SnBitUtils::tmp.s[0] = c;
@@ -80,6 +105,8 @@
     }
     return crc;
 }
+*/
 
+};
 
 #endif // SN_SnCRCUtils
\ No newline at end of file