![](/media/cache/group/mbed-logo-square-512_3.png.50x50_q85.png)
CRC example to compute 32-bit CRC .
main.cpp@2:a9d9b5c4a32b, 2018-03-23 (annotated)
- Committer:
- deepikabhavnani
- Date:
- Fri Mar 23 16:13:52 2018 +0000
- Revision:
- 2:a9d9b5c4a32b
- Parent:
- 1:6f792125397a
CRC example - 5.8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
deepikabhavnani | 0:4ea3a9a52bb6 | 1 | #include "mbed.h" |
deepikabhavnani | 0:4ea3a9a52bb6 | 2 | |
deepikabhavnani | 2:a9d9b5c4a32b | 3 | int main() |
deepikabhavnani | 2:a9d9b5c4a32b | 4 | { |
deepikabhavnani | 2:a9d9b5c4a32b | 5 | MbedCRC<POLY_32BIT_ANSI, 32> ct; |
deepikabhavnani | 0:4ea3a9a52bb6 | 6 | |
deepikabhavnani | 2:a9d9b5c4a32b | 7 | char test[] = "123456789"; |
deepikabhavnani | 2:a9d9b5c4a32b | 8 | uint32_t crc = 0; |
deepikabhavnani | 2:a9d9b5c4a32b | 9 | |
deepikabhavnani | 2:a9d9b5c4a32b | 10 | printf("\nPolynomial = 0x%lx Width = %d \n", ct.get_polynomial(), ct.get_width()); |
deepikabhavnani | 2:a9d9b5c4a32b | 11 | |
deepikabhavnani | 1:6f792125397a | 12 | ct.compute((void *)test, strlen((const char*)test), &crc); |
deepikabhavnani | 2:a9d9b5c4a32b | 13 | printf("The CRC of data \"123456789\" is : 0x%lx\n", crc); |
deepikabhavnani | 0:4ea3a9a52bb6 | 14 | return 0; |
deepikabhavnani | 2:a9d9b5c4a32b | 15 | } |