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.

48 lines
701B

  1. /*
  2. FastCRC-Example
  3. (c) Frank Boesing 2014
  4. This example shows how to use the update functions.
  5. */
  6. #include <FastCRC.h>
  7. FastCRC16 CRC16;
  8. uint8_t buf[9] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
  9. void setup() {
  10. uint16_t crc;
  11. delay(1500);
  12. Serial.begin(115200);
  13. Serial.println("CRC Example");
  14. Serial.println();
  15. Serial.print("CCITT-CRC of \"");
  16. for (unsigned int i = 0; i < sizeof(buf); i++) {
  17. Serial.print((char) buf[i]);
  18. }
  19. Serial.print("\" is: 0x");
  20. //Calculate first half of buffer:
  21. crc = CRC16.ccitt(&buf[0], 4);
  22. //Calculate seconde half of buffer:
  23. crc = CRC16.ccitt_upd(&buf[4],5);
  24. Serial.println(crc, HEX );
  25. }
  26. void loop() {
  27. }