PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FastCRC_validate.ino 1.3KB

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //FastCRC
  2. //Validate computed CRCs
  3. //
  4. //(c) Frank Boesing 2014
  5. #include <util/crc16.h>
  6. #include <FastCRC.h>
  7. FastCRC7 CRC7;
  8. FastCRC8 CRC8;
  9. FastCRC16 CRC16;
  10. FastCRC32 CRC32;
  11. uint8_t buf[9] = {'1','2','3','4','5','6','7','8','9'};
  12. void printVals(const char * name, uint32_t check, uint32_t val){
  13. Serial.print(name);
  14. if (check == val)
  15. Serial.print(" is ok");
  16. else
  17. Serial.print(" is NOT ok");
  18. Serial.println();
  19. }
  20. void setup() {
  21. uint32_t crc;
  22. delay(1500);
  23. Serial.begin(115200);
  24. Serial.println("CRC Validation");
  25. crc = CRC7.crc7(buf, sizeof(buf));
  26. printVals("CRC7", 0x75, crc);
  27. crc = CRC8.smbus(buf, sizeof(buf));
  28. printVals("SMBUS", 0xf4, crc);
  29. crc = CRC8.maxim(buf, sizeof(buf));
  30. printVals("Maxim", 0xa1, crc);
  31. crc = CRC16.ccitt(buf, sizeof(buf));
  32. printVals("CCITT", 0x29b1, crc);
  33. crc = CRC16.mcrf4xx(buf, sizeof(buf));
  34. printVals("MCRF4XX", 0x6f91, crc);
  35. crc = CRC16.modbus(buf, sizeof(buf));
  36. printVals("MODBUS", 0x4b37, crc);
  37. crc = CRC16.kermit(buf, sizeof(buf));
  38. printVals("KERMIT", 0x2189, crc);
  39. crc = CRC16.xmodem(buf, sizeof(buf));
  40. printVals("XMODEM", 0x31c3, crc);
  41. crc = CRC16.x25(buf, sizeof(buf));
  42. printVals("X.25", 0x906e, crc);
  43. crc = CRC32.crc32(buf, sizeof(buf));
  44. printVals("CRC32", 0xcbf43926, crc);
  45. crc = CRC32.cksum(buf, sizeof(buf));
  46. printVals("CKSUM", 0x765e7680, crc);
  47. }
  48. void loop() {
  49. }