56 lines
952 B
C
Raw Normal View History

2023-10-31 07:47:27 +01:00
#include "system/task_sine.h"
#include "system/data_channel.h"
#include "system/float_word.h"
2024-01-09 08:41:42 +01:00
#include <math.h>
2023-10-31 07:47:27 +01:00
int task_sine_run( void * data ) {
2024-01-09 08:41:42 +01:00
sine_config * task = ( sine_config * ) data;
uint32_t data_channel_base = task->base.sink;
uint32_t samples_per_periode = task->samples_per_periode;
float phase = task->phase;
float amplitude = task->amplitude;
data_channel_clear( data_channel_base );
#if 0
for (uint32_t i = 0; i < (DATA_CHANNEL_DEPTH/samples_per_periode); ++i)
{
for(uint32_t j = 0; j < (samples_per_periode); ++j)
{
float_word res;
res.value = amplitude * sin((2.0*M_PI/samples_per_periode) * j + phase);
data_channel_write( data_channel_base, res.word );
}
}
#endif
for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i)
{
float_word res;
res.value = amplitude * sin((2.0*M_PI/samples_per_periode) * i + phase);
data_channel_write( data_channel_base, res.word );
}
2023-10-31 07:47:27 +01:00
2024-01-09 08:41:42 +01:00
return 0;
2023-10-31 07:47:27 +01:00
}