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)

Committer:
manitou
Date:
Fri Apr 22 17:07:33 2016 +0000
Revision:
1:1ce0f4ee7357
Parent:
0:7343f324d853
table-drive bug fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
manitou 0:7343f324d853 1 /* FastCRC library code is placed under the MIT license
manitou 0:7343f324d853 2 * Copyright (c) 2014,2015 Frank Bösing
manitou 0:7343f324d853 3 *
manitou 0:7343f324d853 4 * Permission is hereby granted, free of charge, to any person obtaining
manitou 0:7343f324d853 5 * a copy of this software and associated documentation files (the
manitou 0:7343f324d853 6 * "Software"), to deal in the Software without restriction, including
manitou 0:7343f324d853 7 * without limitation the rights to use, copy, modify, merge, publish,
manitou 0:7343f324d853 8 * distribute, sublicense, and/or sell copies of the Software, and to
manitou 0:7343f324d853 9 * permit persons to whom the Software is furnished to do so, subject to
manitou 0:7343f324d853 10 * the following conditions:
manitou 0:7343f324d853 11 *
manitou 0:7343f324d853 12 * The above copyright notice and this permission notice shall be
manitou 0:7343f324d853 13 * included in all copies or substantial portions of the Software.
manitou 0:7343f324d853 14 *
manitou 0:7343f324d853 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
manitou 0:7343f324d853 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
manitou 0:7343f324d853 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
manitou 0:7343f324d853 18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
manitou 0:7343f324d853 19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
manitou 0:7343f324d853 20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
manitou 0:7343f324d853 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
manitou 0:7343f324d853 22 * SOFTWARE.
manitou 0:7343f324d853 23 */
manitou 0:7343f324d853 24
manitou 0:7343f324d853 25
manitou 0:7343f324d853 26 // CPU-specific implementations of helper functions
manitou 0:7343f324d853 27
manitou 0:7343f324d853 28 #if !defined(__CORTEX_M4)
manitou 0:7343f324d853 29 #if !defined(FastCRC_cpu)
manitou 0:7343f324d853 30 #define FastCRC_cpu
manitou 0:7343f324d853 31
manitou 0:7343f324d853 32 //Reverse byte order (16 bit)
manitou 0:7343f324d853 33 #if defined(__thumb__)
manitou 0:7343f324d853 34 static __attribute__((section(".rev16_text"))) __INLINE __ASM uint32_t REV16(uint32_t value)
manitou 0:7343f324d853 35 {
manitou 0:7343f324d853 36 rev16 r0, r0
manitou 0:7343f324d853 37 bx lr
manitou 0:7343f324d853 38 }
manitou 0:7343f324d853 39 #else
manitou 0:7343f324d853 40 static inline __attribute__((always_inline))
manitou 0:7343f324d853 41 unsigned int REV16( unsigned int value) //generic
manitou 0:7343f324d853 42 {
manitou 0:7343f324d853 43 return (value >> 8) | ((value & 0xff) << 8);
manitou 0:7343f324d853 44 }
manitou 0:7343f324d853 45 #endif
manitou 0:7343f324d853 46
manitou 0:7343f324d853 47
manitou 0:7343f324d853 48
manitou 0:7343f324d853 49
manitou 0:7343f324d853 50
manitou 0:7343f324d853 51 //Reverse byte order (32 bit)
manitou 0:7343f324d853 52 #if defined(__thumb__)
manitou 0:7343f324d853 53 static __attribute__((section(".rev16_text"))) __INLINE __ASM uint32_t REV32(uint32_t value)
manitou 0:7343f324d853 54 {
manitou 0:7343f324d853 55 rev r0, r0
manitou 0:7343f324d853 56 bx lr
manitou 0:7343f324d853 57 }
manitou 0:7343f324d853 58 #else
manitou 0:7343f324d853 59 static inline __attribute__((always_inline))
manitou 0:7343f324d853 60 unsigned int REV32( unsigned int value) //generic
manitou 0:7343f324d853 61 {
manitou 0:7343f324d853 62 value = (value >> 16) | ((value & 0xffff) << 16);
manitou 0:7343f324d853 63 return ((value >> 8) & 0xff00ff) | ((value & 0xff00ff) << 8);
manitou 0:7343f324d853 64 }
manitou 0:7343f324d853 65 #endif
manitou 0:7343f324d853 66
manitou 0:7343f324d853 67
manitou 0:7343f324d853 68 #endif
manitou 0:7343f324d853 69 #endif