CRC example to compute 32-bit CRC .

Files at this revision

API Documentation at this revision

Comitter:
deepikabhavnani
Date:
Fri Mar 23 16:13:52 2018 +0000
Parent:
1:6f792125397a
Commit message:
CRC example - 5.8

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
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;
-}
+ }
diff -r 6f792125397a -r a9d9b5c4a32b mbed-os.lib
--- a/mbed-os.lib	Fri Dec 29 23:13:37 2017 +0000
+++ b/mbed-os.lib	Fri Mar 23 16:13:52 2018 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#5f6572179d66ce4c09d6517b659ac51133cc980d
+https://github.com/ARMmbed/mbed-os/#ad284b28064b22d7e125bcd83e3b5bf649bc4c37