abgabe des Praktikums
This commit is contained in:
@@ -5,7 +5,16 @@
|
||||
int task_add_run( void * task ) {
|
||||
|
||||
// TODO
|
||||
|
||||
add_config * config = (add_config *) task;
|
||||
for( uint32_t i=0; i< DATA_CHANNEL_DEPTH; ++i)
|
||||
{
|
||||
float a,b;
|
||||
float_word c;
|
||||
data_channel_read(config->sources [0],(uint32_t * ) & a);
|
||||
data_channel_read(config->sources [1],(uint32_t * ) & b);
|
||||
c.value = a+b;
|
||||
data_channel_write( config->sink, c.word);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,57 @@
|
||||
#include "system/task_crc.h"
|
||||
#include "system/data_channel.h"
|
||||
#include "system/float_word.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Funktion zur Berechnung des CRC32
|
||||
void berechne_crc32(uint32_t data, uint32_t * crc);
|
||||
void crc32( uint32_t data, uint32_t* crc );
|
||||
|
||||
int task_crc_run( void * task ) {
|
||||
crc_config * config = (crc_config*) task;
|
||||
uint32_t value = config->start;
|
||||
// Nachfolgende Antworten Lesen den FIFO der ersten Datenquelle aus und multiplizieren
|
||||
// den jeweils gelesenen Wert mit 4 und speichern das Ergebnis in der Datensenke
|
||||
for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
|
||||
float_word a;
|
||||
data_channel_read(config->base.sources[0], (uint32_t * ) & a.value );
|
||||
if (i<10) {printf("\n Input %i DATA; %x\ CRC: %x\n", i, a.word, value);}
|
||||
berechne_crc32(a.word, &value); //Startwert jedes Mal, oder mit vorheriger crc starten?
|
||||
if (i<10) {printf("\n CRC Zwischenwert Output(%i): %x\n", i, value);}
|
||||
}
|
||||
printf("CRC Wert: %x\n", value);
|
||||
data_channel_write( config->base.sink, value);
|
||||
|
||||
// TODO
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void berechne_crc32(uint32_t data, uint32_t * crc) {
|
||||
uint32_t bytes[4]; //Reihenfolge richtig?
|
||||
uint32_t reg32 = ~*crc;
|
||||
|
||||
bytes[0] = (uint32_t) (data) & 0x000000FF;
|
||||
bytes[1] = (uint32_t) (data >>8) & 0x000000FF;
|
||||
bytes[2] = (uint32_t) (data >>16) & 0x000000FF;
|
||||
bytes[3] = (uint32_t) (data >>24) & 0x000000FF; //aufffüllen
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
//von rechts nch links
|
||||
for (uint8_t j = 0; j <8; j++) {
|
||||
|
||||
// Prüfen, ob das am weitesten rechts stehende Bit von crc 1 ist
|
||||
if ((reg32 & 1) != (bytes[i] & 1)) { //Wieso crc & 1?
|
||||
reg32 = (reg32 >> 1)^CRC32POLY; // XOR mit dem Polynom
|
||||
} else {
|
||||
reg32 >>= 1;
|
||||
}
|
||||
bytes[i]>>=1;
|
||||
}
|
||||
*crc = reg32 ^0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,29 @@
|
||||
#include "system/task_sine.h"
|
||||
#include "system/data_channel.h"
|
||||
#include "system/float_word.h"
|
||||
//Aus dem Skript kopiert:
|
||||
#include "system/task_sine.h"
|
||||
#include "system/hardware_task.h"
|
||||
#include "system/sine_config.h"
|
||||
#include "system/data_channel.h"
|
||||
#include "system/float_word.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <system.h>
|
||||
|
||||
int task_sine_run( void * data ) {
|
||||
int task_sine_run( void * data) {
|
||||
|
||||
// TODO
|
||||
// Nachfolgende Anweisungen Schreiben 1024 Mal den Wert 4 in den FIFO für Sinus
|
||||
sine_config * task = (sine_config * ) data;
|
||||
uint32_t data_channel_base = task->base.sink;
|
||||
data_channel_clear( data_channel_base );
|
||||
|
||||
for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
|
||||
|
||||
float_word res;
|
||||
res.value = task->amplitude * sin(task->phase + i *2 * M_PI / task->samples_per_periode);
|
||||
|
||||
data_channel_write( data_channel_base, res.word );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user