34 lines
790 B
C
34 lines
790 B
C
#include "system/task_sine.h"
|
|
#include "system/data_channel.h"
|
|
#include "system/float_word.h"
|
|
#include "system/hardware_task.h"
|
|
#include "system/sine_config.h"
|
|
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
#include <limits.h>
|
|
#include <system.h>
|
|
|
|
int task_sine_run( void * data ) {
|
|
|
|
sine_config * task = ( sine_config * ) data;
|
|
|
|
// Daten aus Konfig holen
|
|
uint32_t data_channel_base = task->base.sink;
|
|
double period_len = (double)task->samples_per_periode;
|
|
float amp = task->amplitude;
|
|
double phase = (double)task->phase;
|
|
|
|
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
|
float_word res;
|
|
|
|
double angle = 2.0 * M_PI * ((double)i / period_len);
|
|
|
|
res.value = amp * (float)sin(angle + phase);
|
|
|
|
data_channel_write( data_channel_base, res.word);
|
|
}
|
|
|
|
return 0;
|
|
}
|