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 952B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_channel_base = task->base.sink;
  8. uint32_t samples_per_periode = task->samples_per_periode;
  9. float phase = task->phase;
  10. float amplitude = task->amplitude;
  11. data_channel_clear( data_channel_base );
  12. #if 0
  13. for (uint32_t i = 0; i < (DATA_CHANNEL_DEPTH/samples_per_periode); ++i)
  14. {
  15. for(uint32_t j = 0; j < (samples_per_periode); ++j)
  16. {
  17. float_word res;
  18. res.value = amplitude * sin((2.0*M_PI/samples_per_periode) * j + phase);
  19. data_channel_write( data_channel_base, res.word );
  20. }
  21. }
  22. #endif
  23. for (uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i)
  24. {
  25. float_word res;
  26. res.value = amplitude * sin((2.0*M_PI/samples_per_periode) * i + phase);
  27. data_channel_write( data_channel_base, res.word );
  28. }
  29. return 0;
  30. }