12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "system/task_sine.h"
- #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 ) {
-
-
- 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;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|