Example to show the usage of compute_partial API from CRC class.

main.cpp

Committer:
deepikabhavnani
Date:
2018-01-02
Revision:
1:77ae554366b9
Parent:
0:8e16fea6a7d2
Child:
2:834c44916a38

File content as of revision 1:77ae554366b9:

#include "mbed.h"
#include "FastCRC.h"

int main() {
    FastCRC ct(CRC_32BIT);

    char  test[] = "123456789";
    uint32_t crc;

    ct.init();
    ct.compute((void *)test, strlen((const char*)test), &crc);
    
    printf("The CRC of 0x%x \"123456789\" is \"0xCBF43926\" Result: 0x%x\n", 
                            ct.get_polynomial(), crc);
    
    
    ct.compute_partial_start(&crc);
    ct.compute_partial((void *)&test, 4, &crc);
    ct.compute_partial((void *)&test[4], 5, &crc);
    ct.compute_partial_stop(&crc);
    
    printf("The CRC of 0x%x \"123456789\" is \"0xCBF43926\" Result: 0x%x\n", 
                            ct.get_polynomial(), crc);
    
    ct.deinit();
    return 0;
}