Browse Source

crc.c Korrekturen

master
badenbergra78621 11 months ago
parent
commit
69302fa649
1 changed files with 23 additions and 3 deletions
  1. 23
    3
      software/signal_processing/crc.c

+ 23
- 3
software/signal_processing/crc.c View File

#include "system/task_crc.h" #include "system/task_crc.h"
#include "system/data_channel.h" #include "system/data_channel.h"
#include "system/float_word.h" #include "system/float_word.h"
#include <zlib.h> /* c-library for crc32() */
//#include <zlib.h> /* c-library for crc32() */
#include <stddef.h> /* for "size_t" */


uint32_t crc32(const char *s,size_t n) {
uint32_t crc=0xFFFFFFFF;
for(size_t i=0;i<n;i++)
{
char ch=s[i];
for(size_t j=0;j<8;j++) {
uint32_t b=(ch^crc)&1;
crc>>=1;
if(b) crc=crc^0xEDB88320;
ch>>=1;
}
}
return ~crc;
}





int task_crc_run( void * task ) { int task_crc_run( void * task ) {




for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i )
{ {
data_channel_read(crc->base.sources[0], uint32_t(&crc_input.value));
data_channel_read(crc->base.sources[0], (uint32_t*)&crc_input.value);
crc_res.value = crc32(0, (const void*)crc_input.value, sizeof(crc_input.value));
crc_res.word = crc32((const void *)&crc_input, sizeof(crc_input));
} }



Loading…
Cancel
Save