Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HW_CRC_K64F mbed
Fork of fastCRCperf by
main.cpp
- Committer:
- manitou
- Date:
- 2016-04-22
- Revision:
- 0:d4f8f8fee9db
- Child:
- 1:66996d5c4b7c
File content as of revision 0:d4f8f8fee9db:
// test FastCRC performance, hardware vs avr softcrc
//FastCRC
//Benchmark
//
//(c) Frank Boesing 2014
#include "mbed.h"
#include "FastCRC.h"
#include "crc16.h"
Timer tmr;
#define micros tmr.read_us
#define BUFSIZE 16384
FastCRC8 CRC8;
FastCRC16 CRC16;
FastCRC32 CRC32;
uint8_t buf[BUFSIZE] __attribute__((aligned(4)));
// Supporting functions for Software CRC
inline uint16_t softcrc(uint16_t seed, uint8_t *data, uint16_t datalen) {
for (uint16_t i=0; i<datalen; i++) {
seed = _crc16_update(seed, data[i]);
}
return seed;
}
inline uint16_t softcrcIbutton(uint16_t seed, uint8_t *data, uint16_t datalen) {
for (uint16_t i=0; i<datalen; i++) {
seed = _crc_ibutton_update(seed, data[i]);
}
return seed;
}
inline uint16_t softcrcCCIT(uint16_t seed, uint8_t *data, uint16_t datalen) {
for (uint16_t i=0; i<datalen; i++) {
seed = _crc_ccitt_update(seed, data[i]);
}
return seed;
}
inline uint16_t softcrcXMODEM(uint16_t seed, uint8_t *data, uint16_t datalen) {
for (uint16_t i=0; i<datalen; i++) {
seed = _crc_xmodem_update(seed, data[i]);
}
return seed;
}
void printVals(char * name, uint32_t crc, uint32_t time) {
printf("%s Value:0x%x, Time: %d us\n",name,crc,time);
}
main() {
uint32_t time;
uint32_t crc;
tmr.start();
printf("\nSystemCoreClock %d %s %s\n",SystemCoreClock,__TIME__,__DATE__);
printf("CRC Benchmark %d bytes\n",sizeof(buf));
//Fill array with data
for (int i=0; i<BUFSIZE; i++) {
buf[i] = (i+1) & 0xff;
}
time = micros();
crc = CRC8.maxim(buf, BUFSIZE);
time = micros() - time;
printVals("Maxim (iButton) FastCRC:",crc,time);
time = micros();
crc = softcrcIbutton(0, buf, BUFSIZE);
time = micros() - time;
printVals("Maxim (iButton) builtin:",crc,time);
time = micros();
crc = CRC16.modbus(buf, BUFSIZE);
time = micros() - time;
printVals("MODBUS FastCRC:",crc,time);
time = micros();
crc = softcrc(0xffff, buf, BUFSIZE);
time = micros() - time;
printVals("MODBUS builtin:",crc,time);
time = micros();
crc = CRC16.xmodem(buf, BUFSIZE);
time = micros() - time;
printVals("XMODEM FastCRC:",crc,time);
time = micros();
crc = softcrcXMODEM(0, buf, BUFSIZE);
time = micros() - time;
printVals("XMODEM builtin:",crc,time);
time = micros();
crc = CRC16.mcrf4xx(buf,BUFSIZE);
time = micros() - time;
printVals("MCRF4XX FastCRC:",crc,time);
time = micros();
crc = softcrcCCIT(0xffff, buf, BUFSIZE);
time = micros() - time;
printVals("MCRF4XX builtin:",crc,time);
time = micros();
crc = CRC16.kermit(buf, BUFSIZE);
time = micros() - time;
printVals("KERMIT FastCRC:",crc,time);
time = micros();
crc = CRC32.crc32(buf, BUFSIZE);
time = micros() - time;
printVals("Ethernet FastCRC:",crc,time);
}
