diff --git a/software/signal_processing/crc.c b/software/signal_processing/crc.c index 8830ddd..afc667e 100644 --- a/software/signal_processing/crc.c +++ b/software/signal_processing/crc.c @@ -3,49 +3,74 @@ #include "system/float_word.h" //#include /* c-library for crc32() */ #include /* for "size_t" */ +#include + +#if 0 +#define PRINT_DEBUG_VALUES +#endif -uint32_t crc32(const char *s,size_t n) { - uint32_t crc=0xFFFFFFFF; - for(size_t i=0;i>=1; - if(b) crc=crc^0xEDB88320; + //if(b) crc=crc^0x04C11DB7; // Polynomial representations: NORMAL + if(b) crc=crc^0xEDB88320; // Polynomial representations: REVERSED ch>>=1; } } + + #ifdef PRINT_DEBUG_VALUES + printf("OUTPUT: %08x\n", crc); + printf("~OUTPUT: %08x\n", ~crc); + getchar(); // just here for debugging step by step + #endif /*PRINT_DEBUG_VALUES*/ + return ~crc; } -int task_crc_run( void * task ) { - +int task_crc_run( void * task ) +{ // TODO crc_config * crc = ( crc_config * ) task; uint32_t data_channel_base = crc->base.sink; data_channel_clear( data_channel_base); - + float_word crc_res; float_word crc_input; + crc_res.word = crc->start; + for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) { data_channel_read(crc->base.sources[0], (uint32_t*)&crc_input.value); - - crc_res.word = crc32((const void *)&crc_input, sizeof(crc_input)); - + crc_res.word = crc32(&crc_res.word,(const void *)&crc_input, sizeof(crc_input)); } - data_channel_write( data_channel_base, crc_res.word ); - return 0; }