commit1
This commit is contained in:
@@ -2,9 +2,72 @@
|
||||
#include "system/data_channel.h"
|
||||
#include "system/float_word.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
float value;
|
||||
} Result;
|
||||
|
||||
|
||||
void generateSinusCurve(float samples_per_period, float phase, float amplitude, Result res[]) {
|
||||
float delta_phase = 2.0 * M_PI / samples_per_period;
|
||||
float current_phase = phase;
|
||||
|
||||
for (int i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
|
||||
res[i].value = amplitude * sinf(current_phase);
|
||||
current_phase += delta_phase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 );
|
||||
float_word res;
|
||||
|
||||
|
||||
|
||||
|
||||
//float samples_per_period = 32.0;
|
||||
float samples_per_period = task ->samples_per_periode;
|
||||
float phase = task-> phase;
|
||||
float amplitude = task -> amplitude;
|
||||
|
||||
Result results[DATA_CHANNEL_DEPTH];
|
||||
|
||||
generateSinusCurve(samples_per_period, phase, amplitude, results);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
|
||||
//printf("Wert %d: %f\n", i, results[i].value);
|
||||
res.value = results[i].value;
|
||||
data_channel_write( data_channel_base, res.word);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ sine_config SINE_CONFIG = {
|
||||
.sink = DATA_CHANNEL_0_BASE,
|
||||
.cycle_count = 0 },
|
||||
.samples_per_periode = 32,
|
||||
.phase = 0.0,
|
||||
.phase = 0,
|
||||
.amplitude = 4.0 };
|
||||
|
||||
sine_config COSINE_CONFIG = {
|
||||
|
||||
Reference in New Issue
Block a user