#include "system/task_sine.h" #include "system/data_channel.h" #include "system/float_word.h" #include #ifndef M_PI #define M_PI 3.14159265358979323846 #endif int task_sine_run(void *data) { sine_config *task = (sine_config *) data; uint32_t data_channel_base = task->base.sink; data_channel_clear(data_channel_base); float amplitude = task->amplitude; float phase_rad = task->phase * (float)M_PI / 180.0f; float step = 2.0f * (float)M_PI / (float)task->samples_per_periode; for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; i++) { float angle = phase_rad + i * step; float y = amplitude * sinf(angle); float_word res; res.value = y; data_channel_write(data_channel_base, res.word); } return 0; }