Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * includes
- */
- #include "dsk6713.h"
- #include "dsk6713_aic23.h"
- #include "dsk6713_dip.h" // for reading off switches
- /*
- * Codec configuration settings
- */
- DSK6713_AIC23_Config config = {
- 0x0017, // 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume
- 0x0017, // 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume
- 0x0100, // 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume
- 0x0100, // 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume
- 0x0011, // 4 DSK6713_AIC23_ANAPATH Analog audio path control
- 0x0000, // 5 DSK6713_AIC23_DIGPATH Digital audio path control
- 0x0000, // 6 DSK6713_AIC23_POWERDOWN Power down control
- 0x0043, // 7 DSK6713_AIC23_DIGIF Digital audio interface format
- 0x0001, // 8 DSK6713_AIC23_SAMPLERATE Sample rate control 48kHz
- 0x0001 // 9 DSK6713_AIC23_DIGACT Digital interface activation
- };
- #define SR 48000
- Int16 get_sine(Uint32 freq, Uint32 sample, Uint32 sample_rate)
- {
- double t = sample_rate/freq;
- double x = sample/t;
- double y = sin(x);
- return (Int16)(y * 20000);
- }
- void main()
- {
- // variable declarations
- DSK6713_AIC23_CodecHandle hCodec; // handle to the codec
- // user defined variables
- Uint32 val;
- Uint32 s = 0;
- /* Initialize the board support library, must be called first */
- DSK6713_init();
- DSK6713_DIP_init();
- /* Start the codec */
- hCodec = DSK6713_AIC23_openCodec(0, &config);
- while(1)
- {
- int l, r;
- val = get_sine(30000, s, SR);
- s = ++s % SR;
- while(!DSK6713_AIC23_read(hCodec, &val));
- l = (val & 0xFFFF0000) >> 16;
- r = (val & 0x0000FFFF);
- val *= l;
- /* LPF */
- DSK6713_AIC23_write(hCodec, val);
- }
- /* Close the codec */
- DSK6713_AIC23_closeCodec(hCodec);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement