Port of teensy 3 FastCRC library, uses hardware CRC

Dependents:   fastCRCperf

Port of teensy 3 FastCRC library, uses hardware CRC on K64F. About 30 times faster than Arduino CRC (crc16.h).

https://github.com/FrankBoesing/FastCRC

teensy forum discussions on FastCRC https://forum.pjrc.com/threads/25699-Fast-CRC-library-(uses-the-built-in-crc-module-in-Teensy3)

Revision:
0:7343f324d853
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crc16.h	Fri Apr 22 09:51:51 2016 +0000
@@ -0,0 +1,64 @@
+#ifndef _UTIL_CRC16_H_
+#define _UTIL_CRC16_H_
+
+#include <stdint.h>
+
+static inline uint16_t _crc16_update(uint16_t crc, uint8_t data) __attribute__((always_inline, unused));
+static inline uint16_t _crc16_update(uint16_t crc, uint8_t data)
+{
+    unsigned int i;
+
+    crc ^= data;
+    for (i = 0; i < 8; ++i) {
+        if (crc & 1) {
+            crc = (crc >> 1) ^ 0xA001;
+        } else {
+            crc = (crc >> 1);
+        }
+    }
+    return crc;
+}
+
+static inline uint16_t _crc_xmodem_update(uint16_t crc, uint8_t data) __attribute__((always_inline, unused));
+static inline uint16_t _crc_xmodem_update(uint16_t crc, uint8_t data)
+{
+    unsigned int i;
+
+    crc = crc ^ ((uint16_t)data << 8);
+    for (i=0; i<8; i++) {
+        if (crc & 0x8000) {
+            crc = (crc << 1) ^ 0x1021;
+        } else {
+            crc <<= 1;
+        }
+    }
+    return crc;
+}
+
+static inline uint16_t _crc_ccitt_update (uint16_t crc, uint8_t data) __attribute__((always_inline, unused));
+static inline uint16_t _crc_ccitt_update (uint16_t crc, uint8_t data)
+{
+    data ^= (crc & 255);
+    data ^= data << 4;
+
+    return ((((uint16_t)data << 8) | (crc >> 8)) ^ (uint8_t)(data >> 4) 
+        ^ ((uint16_t)data << 3));
+}
+
+static inline uint8_t _crc_ibutton_update(uint8_t crc, uint8_t data) __attribute__((always_inline, unused));
+static inline uint8_t _crc_ibutton_update(uint8_t crc, uint8_t data)
+{
+    unsigned int i;
+
+    crc = crc ^ data;
+    for (i = 0; i < 8; i++) {
+        if (crc & 0x01) {
+            crc = (crc >> 1) ^ 0x8C;
+        } else {
+            crc >>= 1;
+        }
+    }
+    return crc;
+}
+
+#endif