Loesung des Praktikums Systementwurf - Bjarne Hoesch - Bernhard Schoeffel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sine.c 527B

1 year ago
1 year ago
1 year ago
1 year ago
12345678910111213141516171819202122
  1. #include "system/task_sine.h"
  2. #include "system/data_channel.h"
  3. #include "system/float_word.h"
  4. #include <math.h>
  5. int task_sine_run( void * data ) {
  6. sine_config* task = (sine_config*) data;
  7. uint32_t data_chnl_base = task->base.sink;
  8. data_channel_clear(data_chnl_base);
  9. for(uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
  10. float_word result;
  11. result.value = task->amplitude * sin(task->phase + ((2 * M_PI)/(double)task->samples_per_periode) * i);
  12. data_channel_write(data_chnl_base, result.word);
  13. }
  14. return 0;
  15. }