RybaSG

Untitled

Mar 24th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.99 KB | None | 0 0
  1. #include <csl.h>
  2. #include <csl_timer.h>
  3. #include <dsk6416.h>
  4. #include <dsk6416_led.h>
  5. #include <dsk6416_dip.h>
  6. #include <dsk6416_aic23.h>
  7.  
  8. #include <math.h>
  9.  
  10. #define PI (3.14159265358979323846)
  11.  
  12. DSK6416_AIC23_CodecHandle hCodec;
  13. DSK6416_AIC23_Config codecConfig = { \
  14.         0x0017,  /* 0 DSK6416_AIC23_LEFTINVOL  Left line input channel volume */ \
  15.         0x0017,  /* 1 DSK6416_AIC23_RIGHTINVOL Right line input channel volume */\
  16.         0x00d8,  /* 2 DSK6416_AIC23_LEFTHPVOL  Left channel headphone volume */  \
  17.         0x00d8,  /* 3 DSK6416_AIC23_RIGHTHPVOL Right channel headphone volume */ \
  18.         0x0015,  /* 4 DSK6416_AIC23_ANAPATH    Analog audio path control */      \
  19.         0x0000,  /* 5 DSK6416_AIC23_DIGPATH    Digital audio path control */     \
  20.         0x0000,  /* 6 DSK6416_AIC23_POWERDOWN  Power down control */             \
  21.         0x0043,  /* 7 DSK6416_AIC23_DIGIF      Digital audio interface format */ \
  22.         0x0001,  /* 8 DSK6416_AIC23_SAMPLERATE Sample rate control */            \
  23.         0x0001   /* 9 DSK6416_AIC23_DIGACT     Digital interface activation */   \
  24. };
  25.  
  26. float r, f, a, b;
  27. volatile int sample, amp;
  28. volatile float sample_0, sample_1, sample_2;
  29.  
  30. void CodecTransmit(void);
  31.  
  32. int main(void) {
  33.  
  34.     CSL_init();
  35.  
  36.     DSK6416_init();
  37.  
  38.     DSK6416_DIP_init();
  39.  
  40.     hCodec = DSK6416_AIC23_openCodec(0, &codecConfig);
  41.  
  42.     amp=32000;
  43.     r = 1.0;
  44.     f = 1000.0/48000.0;
  45.  
  46.     a = 2*r*cos(2*PI*f);
  47.     b = -r*r;
  48.  
  49.     sample_2 = 0;
  50.     sample_1 = sin(2*PI*f);
  51.  
  52.     sample_0 = a*sample_1+b*sample_2;
  53.     sample_2 = sample_1;
  54.     sample_1 = sample_0;
  55.     sample = amp*sample_0;
  56.  
  57.     IRQ_globalDisable();
  58.     IRQ_enable(IRQ_EVT_RINT2);
  59.     IRQ_globalEnable();
  60.  
  61. //  DSK6416_AIC23_closeCodec(hCodec);
  62.  
  63.     return 0;
  64. }
  65.  
  66. void CodecTransmit(void) {
  67.     static int mode = 1;
  68.  
  69.     if(mode == 0) {
  70.         DSK6416_AIC23_write(hCodec, sample);
  71.  
  72.         sample_0 = a*sample_1+b*sample_2;
  73.         sample_2 = sample_1;
  74.         sample_1 = sample_0;
  75.  
  76.         sample = amp*sample_0;
  77.     }
  78.     else {
  79.         DSK6416_AIC23_write(hCodec, sample);
  80.     }
  81.  
  82.     mode = !mode;
  83. }
Add Comment
Please, Sign In to add comment