Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. /*
  2. * includes
  3. */
  4. #include "dsk6713.h"
  5. #include "dsk6713_aic23.h"
  6. #include "dsk6713_dip.h" // for reading off switches
  7.  
  8.  
  9. /*
  10. * Codec configuration settings
  11. */
  12. DSK6713_AIC23_Config config = {
  13. 0x0017, // 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume
  14. 0x0017, // 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume
  15. 0x0100, // 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume
  16. 0x0100, // 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume
  17. 0x0011, // 4 DSK6713_AIC23_ANAPATH Analog audio path control
  18. 0x0000, // 5 DSK6713_AIC23_DIGPATH Digital audio path control
  19. 0x0000, // 6 DSK6713_AIC23_POWERDOWN Power down control
  20. 0x0043, // 7 DSK6713_AIC23_DIGIF Digital audio interface format
  21. 0x0001, // 8 DSK6713_AIC23_SAMPLERATE Sample rate control 48kHz
  22. 0x0001 // 9 DSK6713_AIC23_DIGACT Digital interface activation
  23. };
  24.  
  25.  
  26.  
  27. #define SR 48000
  28.  
  29.  
  30. Int16 get_sine(Uint32 freq, Uint32 sample, Uint32 sample_rate)
  31. {
  32. double t = sample_rate/freq;
  33. double x = sample/t;
  34. double y = sin(x);
  35.  
  36. return (Int16)(y * 20000);
  37. }
  38.  
  39. void main()
  40. {
  41. // variable declarations
  42. DSK6713_AIC23_CodecHandle hCodec; // handle to the codec
  43.  
  44. // user defined variables
  45. Uint32 val;
  46. Uint32 s = 0;
  47.  
  48. /* Initialize the board support library, must be called first */
  49. DSK6713_init();
  50. DSK6713_DIP_init();
  51.  
  52.  
  53. /* Start the codec */
  54. hCodec = DSK6713_AIC23_openCodec(0, &config);
  55.  
  56.  
  57. while(1)
  58. {
  59. int l, r;
  60.  
  61. val = get_sine(30000, s, SR);
  62. s = ++s % SR;
  63.  
  64. while(!DSK6713_AIC23_read(hCodec, &val));
  65.  
  66. l = (val & 0xFFFF0000) >> 16;
  67. r = (val & 0x0000FFFF);
  68.  
  69. val *= l;
  70.  
  71. /* LPF */
  72.  
  73. DSK6713_AIC23_write(hCodec, val);
  74. }
  75.  
  76. /* Close the codec */
  77. DSK6713_AIC23_closeCodec(hCodec);
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement