Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "usbstk5505.h"
- #include "aic3204.h"
- #include "PLL.h"
- #include "FIR_Filters_asm.h"
- #include "LEDFlasher.h"
- #include "Hamming.h"
- #include "Hanning.h"
- #include "Kaiser.h"
- #include "Rectangular.h"
- #include "stereo.h"
- Int16 left_input;
- Int16 right_input;
- Int16 left_output;
- Int16 right_output;
- Int16 mono_input;
- int k=0;
- Int16 mono[512];
- Int16 right[512];
- Int16 left[512];
- #define SAMPLES_PER_SECOND 48000
- #define GAIN_IN_dB 30
- unsigned long int i = 0;
- unsigned int step = 0;
- /* ------------------------------------------------------------------------ *
- * *
- * main( ) *
- * *
- * ------------------------------------------------------------------------ */
- void main( void )
- {
- /* Initialize BSL */
- USBSTK5505_init( );
- /* Initialize the Phase Locked Loop in EEPROM */
- pll_frequency_setup(100);
- /* Initialise hardware interface and I2C for code */
- aic3204_hardware_init();
- /* Initialise the AIC3204 codec */
- aic3204_init();
- printf("\n\nRunning FIR Filters Project\n");
- printf( "<-> Audio Loopback from Stereo Line IN --> to HP/Lineout\n\n" );
- /* Set sampling frequency in Hz and ADC gain in dB */
- set_sampling_frequency_and_gain(SAMPLES_PER_SECOND, GAIN_IN_dB);
- puts("1 Flash = Straight through, no processing");
- puts("2 Flashes = Hamming filter 500 Hz");
- puts("3 Flashes = Hamming filter 1000 Hz");
- puts("4 Flashes = Hamming filter 2000 Hz");
- puts("5 Flashes = Hamming filter 3000 Hz");
- asm(" bclr XF");
- for ( i = 0 ; i < SAMPLES_PER_SECOND * 600L ;i++ )
- {
- aic3204_codec_read(&left_input, &right_input); // Configured for one interrupt per two channels.
- mono_input = stereo_to_mono(left_input, right_input);
- step = LEDFlasher(5); // 5 Different filter settings.
- step=2;
- switch (step)
- {
- case 1:
- left_output = mono_input; // Straight through, no processing.
- right_output = mono_input;
- break;
- case 2:
- left_output = FIR_filter_asm(&Hamming_Low_Pass_Filter_500Hz[0], mono_input);
- right_output = FIR_filter_asm_2(&Hamming_High_Pass_Filter_500Hz[0], mono_input);
- break;
- case 3:
- left_output = FIR_filter_asm(&Hamming_Low_Pass_Filter_1000Hz[0], mono_input);
- right_output = FIR_filter_asm_2(&Hamming_High_Pass_Filter_1000Hz[0], mono_input);
- break;
- case 4:
- left_output = FIR_filter_asm(&Hamming_Low_Pass_Filter_2000Hz[0], mono_input);
- right_output = FIR_filter_asm_2(&Hamming_High_Pass_Filter_2000Hz[0], mono_input);
- break;
- case 5:
- left_output = FIR_filter_asm(&Hamming_Low_Pass_Filter_3000Hz[0], mono_input);
- right_output = FIR_filter_asm_2(&Hamming_High_Pass_Filter_3000Hz[0], mono_input);
- break;
- }
- mono[k]=mono_input;
- left[k]=left_output;
- right[k]=right_output;
- k=k+1;
- if (k==512){
- k=0;
- }
- aic3204_codec_write(left_output, right_output);
- }
- /* Disable I2S and put codec into reset */
- aic3204_disable();
- printf( "\n***Program has Terminated***\n" );
- SW_BREAKPOINT;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement