Studentenversion des ESY6/A Praktikums "signal_processing".
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 759B

12345678910111213141516171819202122232425262728
  1. //Aus dem Skript kopiert:
  2. #include "system/task_sine.h"
  3. #include "system/hardware_task.h"
  4. #include "system/sine_config.h"
  5. #include "system/data_channel.h"
  6. #include "system/float_word.h"
  7. #include <math.h>
  8. #include <stdio.h>
  9. #include <limits.h>
  10. #include <system.h>
  11. int task_sine_run( void * data) {
  12. // Nachfolgende Anweisungen Schreiben 1024 Mal den Wert 4 in den FIFO für Sinus
  13. sine_config * task = (sine_config * ) data;
  14. uint32_t data_channel_base = task->base.sink;
  15. data_channel_clear( data_channel_base );
  16. for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i) {
  17. float_word res;
  18. res.value = task->amplitude * sin(task->phase + i *2 * M_PI / task->samples_per_periode);
  19. data_channel_write( data_channel_base, res.word );
  20. }
  21. return 0;
  22. }