Fertig
This commit is contained in:
@@ -4,7 +4,17 @@
|
||||
|
||||
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;
|
||||
float b;
|
||||
data_channel_read( config-> sources[ 0 ], (uint32_t * ) & a);
|
||||
data_channel_read( config-> sources[ 1 ], (uint32_t * ) & b);
|
||||
float_word c;
|
||||
c.value = a+b;
|
||||
data_channel_write( config->sink, c.word );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,45 @@
|
||||
#include "system/task_rand.h"
|
||||
#include "system/hardware_task.h"
|
||||
#include "system/data_channel.h"
|
||||
#include "system/float_word.h"
|
||||
|
||||
int task_rand_run( void * task ) {
|
||||
|
||||
// TODO
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "system/task_rand.h"
|
||||
#include "system/hardware_task.h"
|
||||
#include "system/data_channel.h"
|
||||
#include "system/float_word.h"
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
|
||||
int task_rand_run(void *task) {
|
||||
rand_config *config = (rand_config *)task;
|
||||
uint32_t data_channel_base = DATA_CHANNEL_2_BASE;
|
||||
|
||||
|
||||
uint32_t lfsr = config->seed;
|
||||
|
||||
for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
|
||||
|
||||
uint32_t bit = ((lfsr >> 31) ^ (lfsr >> 21) ^ (lfsr >> 1) ^ (lfsr >> 0)) & 1;
|
||||
lfsr = (lfsr << 1) | bit;
|
||||
|
||||
|
||||
float_word res;
|
||||
res.word = lfsr;
|
||||
|
||||
|
||||
uint32_t exponent = (lfsr >> 23) & 0xFF;
|
||||
|
||||
|
||||
if (exponent & 0x80) {
|
||||
exponent = 0x80 | (lfsr & 0x01);
|
||||
}else {
|
||||
|
||||
exponent = 0x7C | (lfsr & 0x03);
|
||||
}
|
||||
|
||||
|
||||
res.word &= ~(0xFF << 23);
|
||||
res.word |= (exponent << 23);
|
||||
|
||||
|
||||
|
||||
data_channel_write(data_channel_base, res.word);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
#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 ) {
|
||||
|
||||
// TODO
|
||||
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;
|
||||
|
||||
for(uint32_t y = 0; y < task->samples_per_periode; y++)
|
||||
{
|
||||
res.value = task->amplitude * sin(2*3.14/task->samples_per_periode*y + task->phase);
|
||||
data_channel_write( data_channel_base, res.word );
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user