CRC example to compute 32-bit CRC .

Revision:
2:a9d9b5c4a32b
Parent:
1:6f792125397a
diff -r 6f792125397a -r a9d9b5c4a32b main.cpp
--- a/main.cpp	Fri Dec 29 23:13:37 2017 +0000
+++ b/main.cpp	Fri Mar 23 16:13:52 2018 +0000
@@ -1,36 +1,15 @@
 #include "mbed.h"
-#include "BitwiseCRC.h"
-#include "FastCRC.h"
-
-#define FAST_COMPUTE        1
 
-#if defined(FAST_COMPUTE)
-#define CRC_ALGO    FastCRC
-#else
-#define CRC_ALGO    BitwiseCRC
-#endif
-
-char  test[] = "123456789";
-uint32_t crc;
-
-int crc_calculate(crc_polynomial_type_t crc_type) {
-    CRC_ALGO ct(crc_type);
+int main()
+{
+    MbedCRC<POLY_32BIT_ANSI, 32> ct;
 
-    ct.init();
+    char  test[] = "123456789";
+    uint32_t crc = 0;
+ 
+    printf("\nPolynomial = 0x%lx  Width = %d \n", ct.get_polynomial(), ct.get_width());
+ 
     ct.compute((void *)test, strlen((const char*)test), &crc);
-
-    printf("The CRC of 0x%x data \"123456789\" is : 0x%lx\n",
-                            ct.get_polynomial(), crc);
-    ct.deinit();
+    printf("The CRC of data \"123456789\" is : 0x%lx\n", crc);
     return 0;
-}
-
-int main() {
-
-    crc_calculate(CRC_32BIT);
-    crc_calculate(CRC_16BIT_IBM);
-    crc_calculate(CRC_16BIT_CCITT);
-
-    printf("End\n");
-    return 0;
-}
+ }