CRC example for SD driver

Revision:
1:ca0b1e353dfe
Parent:
0:e60fda833675
Child:
2:ee110889fa99
--- a/main.cpp	Mon Dec 18 22:58:44 2017 +0000
+++ b/main.cpp	Tue Jan 02 15:47:19 2018 +0000
@@ -1,22 +1,24 @@
 #include "mbed.h"
-#include "mbed_crc.h"
-#include "SlowCRC.h"
+#include "BaseCRC.h"
+#include "BitwiseCRC.h"
 #include "FastCRC.h"
 
 int crc_sd_7bit() {
-    SlowCRC<uint8_t> ct(CRC_7BIT_SD);
-    
+    BitwiseCRC ct(CRC_7BIT_SD);
+    char test[5];
+    uint32_t crc;
+
     ct.init();
     test[0] = 0x40;
     test[1] = 0x00;
     test[2] = 0x00;
     test[3] = 0x00;
     test[4] = 0x00;
-    
-    ct.compute((void *)test, 5, &crc);    
+
+    ct.compute((void *)test, 5, &crc);
     // CRC 7-bit as 8-bit data
     crc = (crc << 1 ) + 1;
-    printf("The CRC of 0x%x \"CMD0\" is \"0x95\" Result: 0x%x\n", 
+    printf("The CRC of 0x%x \"CMD0\" is \"0x95\" Result: 0x%x\n",
                             ct.get_polynomial(), crc);
 
     test[0] = 0x48;
@@ -24,11 +26,11 @@
     test[2] = 0x00;
     test[3] = 0x01;
     test[4] = 0xAA;
-    
-    ct.compute((void *)test, 5, &crc);    
+
+    ct.compute((void *)test, 5, &crc);
     // CRC 7-bit as 8-bit data
     crc = (crc << 1 ) + 1;
-    printf("The CRC of 0x%x \"CMD8\" is \"0x87\" Result: 0x%x\n", 
+    printf("The CRC of 0x%x \"CMD8\" is \"0x87\" Result: 0x%x\n",
                             ct.get_polynomial(), crc);
 
     test[0] = 0x51;
@@ -37,10 +39,10 @@
     test[3] = 0x00;
     test[4] = 0x00;
 
-    ct.compute((void *)test, 5, &crc);    
+    ct.compute((void *)test, 5, &crc);
     // CRC 7-bit as 8-bit data
     crc = (crc << 1 ) + 1;
-    printf("The CRC of 0x%x \"CMD17\" is \"0x55\" Result: 0x%x\n", 
+    printf("The CRC of 0x%x \"CMD17\" is \"0x55\" Result: 0x%x\n",
                             ct.get_polynomial(), crc);
 
     ct.deinit();
@@ -50,8 +52,8 @@
 int crc_sd_16bit() {
     char test[512];
     uint32_t crc;
-    FastCRC<uint16_t> sd(CRC_16BIT_SD);
-    
+    FastCRC sd(CRC_16BIT_SD);
+
     memset(test, 0xFF, 512);
     // 512 bytes with 0xFF data --> CRC16 = 0x7FA1
     sd.init();
@@ -61,9 +63,9 @@
     return 0;
 }
 
-int main() 
+int main()
 {
-    crc_sd_16bit();    
+    crc_sd_16bit();
     crc_sd_7bit();
     return 0;
 }