diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-01-21 19:46:42 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-01-21 19:46:42 +0000 |
commit | 921fd2865e785c53e3167f4588055c5a84d58b5a (patch) | |
tree | ccb01076119829e069fc1e677f1082e49134d1f1 | |
parent | 4a9500af0549cf544c608c1dde7dd92f86f00c5c (diff) | |
download | NoiseSilencer-921fd2865e785c53e3167f4588055c5a84d58b5a.tar.gz NoiseSilencer-921fd2865e785c53e3167f4588055c5a84d58b5a.zip |
Cleaning files
-rw-r--r-- | lab1/RTDSP/volume.c | 66 | ||||
-rw-r--r-- | lab1/RTDSP/volume.h | 12 | ||||
-rw-r--r-- | lab2/RTDSP/sine.c | 141 | ||||
-rw-r--r-- | lab3/RTDSP/intio.c | 151 |
4 files changed, 179 insertions, 191 deletions
diff --git a/lab1/RTDSP/volume.c b/lab1/RTDSP/volume.c index 3da8881..43958f8 100644 --- a/lab1/RTDSP/volume.c +++ b/lab1/RTDSP/volume.c @@ -1,20 +1,20 @@ /************************************************************************************* - DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING - IMPERIAL COLLEGE LONDON + DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING + IMPERIAL COLLEGE LONDON - EE 3.19: Real Time Digital Signal Processing - Dr Paul Mitcheson and Daniel Harvey + EE 3.19: Real Time Digital Signal Processing + Dr Paul Mitcheson and Daniel Harvey - LAB 1: Getting Started with the TI C6x DSP + LAB 1: Getting Started with the TI C6x DSP - ********* V O L U M E . C ********** + ********* V O L U M E . C ********** - Part of the volume example. Demonstrates connecting the DSK - to sinewave data stored on the host PC. - Sinewave is then processed by increasing its gain. - Additionally demonstrates calling an assembly routine from C. + Part of the volume example. Demonstrates connecting the DSK + to sinewave data stored on the host PC. + Sinewave is then processed by increasing its gain. + Additionally demonstrates calling an assembly routine from C. ************************************************************************************* - Updated for use on 6713 DSK by Danny Harvey: May-Aug 2006 + Updated for use on 6713 DSK by Danny Harvey: May-Aug 2006 ************************************************************************************/ /* "@(#) DSP/BIOS 4.90.270 01-08-04 (bios,dsk6713-c04)" */ @@ -24,19 +24,19 @@ #include "volume.h" /******************************* Global declarations ********************************/ -// note: for see volume.h for initialisaton of BUFSIZE, MINGAIN and BASELOAD +// note: for see volume.h for initialisaton of BUFSIZE, MINGAIN and BASELOAD // and defintion of PARMS -int inp_buffer[BUFSIZE]; // processing data buffers +int inp_buffer[BUFSIZE]; // processing data buffers int out_buffer[BUFSIZE]; -int gain = MINGAIN; // volume control variable -unsigned int processingLoad = BASELOAD; // processing routine load value - -struct PARMS str = // A structure of type PARMS is initialised. -{ // This struct is not used in the logic of - 2934, // the program, it is included to demonstrate - 9432, // how to use watch windows on structs. - 213, +int gain = MINGAIN; // volume control variable +unsigned int processingLoad = BASELOAD; // processing routine load value + +struct PARMS str = // A structure of type PARMS is initialised. +{ // This struct is not used in the logic of + 2934, // the program, it is included to demonstrate + 9432, // how to use watch windows on structs. + 213, 9432, &str }; @@ -50,23 +50,23 @@ static void dataIO(void); /********************************** Main routine ************************************/ void main() { - int *input = &inp_buffer[0]; // use pointers to point to first element in - int *output = &out_buffer[0]; // input and output buffers + int *input = &inp_buffer[0]; // use pointers to point to first element in + int *output = &out_buffer[0]; // input and output buffers - puts("volume example started\n"); // send a message to stdio + puts("volume example started\n"); // send a message to stdio - // loop forever + // loop forever while(TRUE) - { - // Read input data using a probe-point connected to a host file. + { + // Read input data using a probe-point connected to a host file. // Write output data to a graph connected through a probe-point. - + dataIO(); #ifdef FILEIO puts("begin processing") /****** deliberate syntax error ******/ #endif - + // process signal held in input buffer array (apply gain) // result is returned to output buffer array processing(input, output); @@ -80,15 +80,15 @@ static int processing(int *input, int *output) { int size = BUFSIZE; - /* loop through length of input array mutiplying by gain. Put the result in - the output array. */ + /* loop through length of input array mutiplying by gain. Put the result in + the output array. */ while(size--){ *output++ = *input++ * gain; } - + // apply additional processing load by calling assembly function load() load(processingLoad); - + return(TRUE); } diff --git a/lab1/RTDSP/volume.h b/lab1/RTDSP/volume.h index c70ae5d..9b46bf5 100644 --- a/lab1/RTDSP/volume.h +++ b/lab1/RTDSP/volume.h @@ -3,7 +3,7 @@ * All rights reserved. Property of Texas Instruments Incorporated. * Restricted rights to use, duplicate or disclose this code are * granted through contract. - * + * */ /* "@(#) DSP/BIOS 4.90.270 01-08-04 (bios,dsk6713-c04)" */ /* @@ -31,11 +31,11 @@ #define BASELOAD 1 struct PARMS { - int Beta; - int EchoPower; - int ErrorPower; - int Ratio; - struct PARMS *Link; + int Beta; + int EchoPower; + int ErrorPower; + int Ratio; + struct PARMS *Link; }; #endif /* __VOLUME_H */ diff --git a/lab2/RTDSP/sine.c b/lab2/RTDSP/sine.c index aa2653e..561ca0c 100644 --- a/lab2/RTDSP/sine.c +++ b/lab2/RTDSP/sine.c @@ -1,33 +1,33 @@ /************************************************************************************* - DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING - IMPERIAL COLLEGE LONDON + DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING + IMPERIAL COLLEGE LONDON - EE 3.19: Real Time Digital Signal Processing - Dr Paul Mitcheson and Daniel Harvey + EE 3.19: Real Time Digital Signal Processing + Dr Paul Mitcheson and Daniel Harvey - LAB 2: Learning C and Sinewave Generation + LAB 2: Learning C and Sinewave Generation - ********* S I N E . C ********** + ********* S I N E . C ********** - Demonstrates outputing data from the DSK's audio port. - Used for extending knowledge of C and using look up tables. + Demonstrates outputing data from the DSK's audio port. + Used for extending knowledge of C and using look up tables. ************************************************************************************* - Updated for use on 6713 DSK by Danny Harvey: May-Aug 06/Dec 07/Oct 09 - CCS V4 updates Sept 10 + Updated for use on 6713 DSK by Danny Harvey: May-Aug 06/Dec 07/Oct 09 + CCS V4 updates Sept 10 ************************************************************************************/ /* * Initialy this example uses the AIC23 codec module of the 6713 DSK Board Support - * Library to generate a 1KHz sine wave using a simple digital filter. - * You should modify the code to generate a sine of variable frequency. + * Library to generate a 1KHz sine wave using a simple digital filter. + * You should modify the code to generate a sine of variable frequency. */ /**************************** Pre-processor statements ******************************/ -// Included so program can make use of DSP/BIOS configuration tool. +// Included so program can make use of DSP/BIOS configuration tool. #include "dsp_bios_cfg.h" -/* The file dsk6713.h must be included in every program that uses the BSL. This - example also includes dsk6713_aic23.h because it uses the +/* The file dsk6713.h must be included in every program that uses the BSL. This + example also includes dsk6713_aic23.h because it uses the AIC23 codec module (audio interface). */ #include "dsk6713.h" #include "dsk6713_aic23.h" @@ -39,7 +39,7 @@ #include "helper_functions_polling.h" -// PI defined here for use in your code +// PI defined here for use in your code #define PI 3.141592653589793 // Contains the size of the sine table @@ -49,12 +49,12 @@ /******************************* Global declarations ********************************/ -/* Audio port configuration settings: these values set registers in the AIC23 audio +/* Audio port configuration settings: these values set registers in the AIC23 audio interface to configure it. See TI doc SLWS106D 3-3 to 3-10 for more info. */ DSK6713_AIC23_Config Config = { \ - /**********************************************************************/ - /* REGISTER FUNCTION SETTINGS */ - /**********************************************************************/\ + /**********************************************************************/ + /* REGISTER FUNCTION SETTINGS */ + /**********************************************************************/\ 0x0017, /* 0 LEFTINVOL Left line input channel volume 0dB */\ 0x0017, /* 1 RIGHTINVOL Right line input channel volume 0dB */\ 0x01f9, /* 2 LEFTHPVOL Left channel headphone volume 0dB */\ @@ -65,27 +65,27 @@ DSK6713_AIC23_Config Config = { \ 0x004f, /* 7 DIGIF Digital audio interface format 32 bit */\ 0x008d, /* 8 SAMPLERATE Sample rate control 8 KHZ */\ 0x0001 /* 9 DIGACT Digital interface activation On */\ - /**********************************************************************/ + /**********************************************************************/ }; -// Codec handle:- a variable used to identify audio interface +// Codec handle:- a variable used to identify audio interface DSK6713_AIC23_CodecHandle H_Codec; /* Sampling frequency in HZ. Must only be set to 8000, 16000, 24000 -32000, 44100 (CD standard), 48000 or 96000 */ +32000, 44100 (CD standard), 48000 or 96000 */ int sampling_freq = 16000; -// Array of data used by sinegen to generate sine. These are the initial values. +// Array of data used by sinegen to generate sine. These are the initial values. float y[3] = {0,0,0}; float x[1] = {1}; // impulse to start filter float a0 = 1.4142; // coefficients for difference equation float b0 = 0.707; -// Holds the value of the current sample -float sample; +// Holds the value of the current sample +float sample; /* Left and right audio channel gain values, calculated to be less than signed 32 bit maximum value. */ @@ -93,7 +93,7 @@ Int32 L_Gain = 2100000000; Int32 R_Gain = 2100000000; -/* Use this variable in your code to set the frequency of your sine wave +/* Use this variable in your code to set the frequency of your sine wave be carefull that you do not set it above the current nyquist frequency! */ float sine_freq = 1000.0; @@ -103,7 +103,7 @@ float table[SINE_TABLE_SIZE]; // Current index in the table, that can be used to calculate the next index int sine_index = 0; - + /******************************* Function prototypes ********************************/ void init_hardware(void); void sine_init(void); @@ -112,79 +112,72 @@ float sinegen(void); void main() { - // initialize board and the audio port - init_hardware(); - - // Initialize the sine table - sine_init(); - - // Loop endlessley generating a sine wave + // initialize board and the audio port + init_hardware(); + + // Initialize the sine table + sine_init(); + + // Loop endlessley generating a sine wave while(1) { - // Calculate next sample - sample = sinegen(); - - /* Send a sample to the audio port if it is ready to transmit. + // Calculate next sample + sample = sinegen(); + + /* Send a sample to the audio port if it is ready to transmit. Note: DSK6713_AIC23_write() returns false if the port if is not ready */ // send to LEFT channel (poll until ready) while (!DSK6713_AIC23_write(H_Codec, ((Int32)(sample * L_Gain)))) {}; - // send same sample to RIGHT channel (poll until ready) + + // send same sample to RIGHT channel (poll until ready) while (!DSK6713_AIC23_write(H_Codec, ((Int32)(sample * R_Gain)))) {}; - - // Set the sampling frequency. This function updates the frequency only if it - // has changed. Frequency set must be one of the supported sampling freq. - set_samp_freq(&sampling_freq, Config, &H_Codec); - - } + // Set the sampling frequency. This function updates the frequency only if it + // has changed. Frequency set must be one of the supported sampling freq. + set_samp_freq(&sampling_freq, Config, &H_Codec); + } } /******************************* init_hardware() ************************************/ void init_hardware() { - // Initialize the board support library, must be called first + // Initialize the board support library, must be called first DSK6713_init(); - - // Start the codec using the settings defined above in config + + // Start the codec using the settings defined above in config H_Codec = DSK6713_AIC23_openCodec(0, &Config); - /* Defines number of bits in word used by MSBSP for communications with AIC23 - NOTE: this must match the bit resolution set in in the AIC23 */ - MCBSP_FSETS(XCR1, XWDLEN1, 32BIT); - - /* Set the sampling frequency of the audio port. Must only be set to a supported - frequency (8000/16000/24000/32000/44100/48000/96000) */ - - DSK6713_AIC23_setFreq(H_Codec, get_sampling_handle(&sampling_freq)); + /* Defines number of bits in word used by MSBSP for communications with AIC23 + NOTE: this must match the bit resolution set in in the AIC23 */ + MCBSP_FSETS(XCR1, XWDLEN1, 32BIT); + /* Set the sampling frequency of the audio port. Must only be set to a supported + frequency (8000/16000/24000/32000/44100/48000/96000) */ + DSK6713_AIC23_setFreq(H_Codec, get_sampling_handle(&sampling_freq)); } -/******************************* sin_init() ************************************/ +/******************************* sin_init() *****************************************/ void sine_init() { - int i; - for(i = 0; i < SINE_TABLE_SIZE; i++) - { - table[i] = sin(2 * PI * i / SINE_TABLE_SIZE); - } + int i; + for(i = 0; i < SINE_TABLE_SIZE; i++) + { + table[i] = sin(2 * PI * i / SINE_TABLE_SIZE); + } } -/********************************** sinegen() ***************************************/ +/********************************** sinegen() ***************************************/ float sinegen(void) { - // temporary variable used to output values from function - float wave; - - wave = table[(int)((sine_freq / (float)sampling_freq) * (float)SINE_TABLE_SIZE * sine_index) % SINE_TABLE_SIZE]; - - sine_index++; - - return(wave); - -} + // temporary variable used to output values from function + float wave; + wave = table[(int)((sine_freq / (float)sampling_freq) * (float)SINE_TABLE_SIZE * sine_index) % SINE_TABLE_SIZE]; + sine_index++; + return wave; +} diff --git a/lab3/RTDSP/intio.c b/lab3/RTDSP/intio.c index 7c33ee8..4ee527a 100644 --- a/lab3/RTDSP/intio.c +++ b/lab3/RTDSP/intio.c @@ -1,32 +1,32 @@ /************************************************************************************* - DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING - IMPERIAL COLLEGE LONDON + DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING + IMPERIAL COLLEGE LONDON - EE 3.19: Real Time Digital Signal Processing - Dr Paul Mitcheson and Daniel Harvey + EE 3.19: Real Time Digital Signal Processing + Dr Paul Mitcheson and Daniel Harvey - LAB 3: Interrupt I/O + LAB 3: Interrupt I/O - ********* I N T I O. C ********** + ********* I N T I O. C ********** - Demonstrates inputing and outputing data from the DSK's audio port using interrupts. + Demonstrates inputing and outputing data from the DSK's audio port using interrupts. ************************************************************************************* - Updated for use on 6713 DSK by Danny Harvey: May-Aug 2006 - Updated for CCS V4 Sept 10 + Updated for use on 6713 DSK by Danny Harvey: May-Aug 2006 + Updated for CCS V4 Sept 10 ************************************************************************************/ /* - * You should modify the code so that interrupts are used to service the + * You should modify the code so that interrupts are used to service the * audio port. */ /**************************** Pre-processor statements ******************************/ #include <stdlib.h> -// Included so program can make use of DSP/BIOS configuration tool. +// Included so program can make use of DSP/BIOS configuration tool. #include "dsp_bios_cfg.h" -/* The file dsk6713.h must be included in every program that uses the BSL. This - example also includes dsk6713_aic23.h because it uses the +/* The file dsk6713.h must be included in every program that uses the BSL. This + example also includes dsk6713_aic23.h because it uses the AIC23 codec module (audio interface). */ #include "dsk6713.h" #include "dsk6713_aic23.h" @@ -40,17 +40,17 @@ // Some functions to help with configuring hardware #include "helper_functions_polling.h" -// PI defined here for use in your code +// PI defined here for use in your code #define PI 3.141592653589793 /******************************* Global declarations ********************************/ -/* Audio port configuration settings: these values set registers in the AIC23 audio +/* Audio port configuration settings: these values set registers in the AIC23 audio interface to configure it. See TI doc SLWS106D 3-3 to 3-10 for more info. */ DSK6713_AIC23_Config Config = { \ - /**********************************************************************/ - /* REGISTER FUNCTION SETTINGS */ - /**********************************************************************/\ + /**********************************************************************/ + /* REGISTER FUNCTION SETTINGS */ + /**********************************************************************/\ 0x0017, /* 0 LEFTINVOL Left line input channel volume 0dB */\ 0x0017, /* 1 RIGHTINVOL Right line input channel volume 0dB */\ 0x01f9, /* 2 LEFTHPVOL Left channel headphone volume 0dB */\ @@ -61,19 +61,19 @@ DSK6713_AIC23_Config Config = { \ 0x0043, /* 7 DIGIF Digital audio interface format 16 bit */\ 0x008d, /* 8 SAMPLERATE Sample rate control 8 KHZ */\ 0x0001 /* 9 DIGACT Digital interface activation On */\ - /**********************************************************************/ + /**********************************************************************/ }; -// Codec handle:- a variable used to identify audio interface +// Codec handle:- a variable used to identify audio interface DSK6713_AIC23_CodecHandle H_Codec; /* Sampling frequency in HZ. Must only be set to 8000, 16000, 24000 -32000, 44100 (CD standard), 48000 or 96000 */ +32000, 44100 (CD standard), 48000 or 96000 */ int sampling_freq = 16000; -/* Use this variable in your code to set the frequency of your sine wave +/* Use this variable in your code to set the frequency of your sine wave be carefull that you do not set it above the current nyquist frequency! */ float sine_freq = 2000.0; @@ -90,104 +90,99 @@ Int32 R_Gain = 2100000000; unsigned sine_phase_ind = 0; /******************************* Function prototypes ********************************/ -void init_hardware(void); -void init_HWI(void); +void init_hardware(void); +void init_HWI(void); float sinegen(void); void ISR_AIC(void); void sine_init(void); /********************************** Main routine ************************************/ void main(){ - - // initialize board and the audio port + // initialize board and the audio port init_hardware(); - sine_init(); - /* initialize hardware interrupts */ - init_HWI(); - - /* loop indefinitely, waiting for interrupts */ - while(1) { - - }; + sine_init(); + /* initialize hardware interrupts */ + init_HWI(); + /* loop indefinitely, waiting for interrupts */ + while(1) {}; } - -/********************************** init_hardware() **********************************/ + +/********************************** init_hardware() **********************************/ void init_hardware() { - // Initialize the board support library, must be called first + // Initialize the board support library, must be called first DSK6713_init(); - - // Start the AIC23 codec using the settings defined above in config + + // Start the AIC23 codec using the settings defined above in config H_Codec = DSK6713_AIC23_openCodec(0, &Config); - /* Function below sets the number of bits in word used by MSBSP (serial port) for - receives from AIC23 (audio port). We are using a 32 bit packet containing two - 16 bit numbers hence 32BIT is set for receive */ - MCBSP_FSETS(RCR1, RWDLEN1, 32BIT); + /* Function below sets the number of bits in word used by MSBSP (serial port) for + receives from AIC23 (audio port). We are using a 32 bit packet containing two + 16 bit numbers hence 32BIT is set for receive */ + MCBSP_FSETS(RCR1, RWDLEN1, 32BIT); - /* Configures interrupt to activate on each consecutive available 32 bits - from Audio port hence an interrupt is generated for each L & R sample pair */ - MCBSP_FSETS(SPCR1, RINTM, FRM); + /* Configures interrupt to activate on each consecutive available 32 bits + from Audio port hence an interrupt is generated for each L & R sample pair */ + MCBSP_FSETS(SPCR1, RINTM, FRM); - /* These commands do the same thing as above but applied to data transfers to - the audio port */ - MCBSP_FSETS(XCR1, XWDLEN1, 32BIT); - MCBSP_FSETS(SPCR1, XINTM, FRM); + /* These commands do the same thing as above but applied to data transfers to + the audio port */ + MCBSP_FSETS(XCR1, XWDLEN1, 32BIT); + MCBSP_FSETS(SPCR1, XINTM, FRM); } -/********************************** init_HWI() **************************************/ +/********************************** init_HWI() **************************************/ void init_HWI(void) { - IRQ_globalDisable(); // Globally disables interrupts - IRQ_nmiEnable(); // Enables the NMI interrupt (used by the debugger) - IRQ_map(IRQ_EVT_XINT1,4); // Maps an event to a physical interrupt - IRQ_enable(IRQ_EVT_XINT1); // Enables the event - IRQ_globalEnable(); // Globally enables interrupts - -} + IRQ_globalDisable(); // Globally disables interrupts + IRQ_nmiEnable(); // Enables the NMI interrupt (used by the debugger) + IRQ_map(IRQ_EVT_XINT1,4); // Maps an event to a physical interrupt + IRQ_enable(IRQ_EVT_XINT1); // Enables the event + IRQ_globalEnable(); // Globally enables interrupts +} //Populates the table with appropriate sine values void sine_init(void) { - int i; - for(i = 0; i < SINE_TABLE_SIZE; i++) - { - table[i] = sin(2 * PI * i / SINE_TABLE_SIZE); - } + int i; + for(i = 0; i < SINE_TABLE_SIZE; i++) + { + table[i] = sin(2 * PI * i / SINE_TABLE_SIZE); + } } //Returns the sample according to the sampling frequency float sinegen(void) { - unsigned sample_index = sine_phase_ind * sine_freq * SINE_TABLE_SIZE / sampling_freq; - sample_index = sample_index % SINE_TABLE_SIZE; - sine_phase_ind++; - return table[sample_index]; + unsigned sample_index = sine_phase_ind * sine_freq * SINE_TABLE_SIZE / sampling_freq; + sample_index = sample_index % SINE_TABLE_SIZE; + sine_phase_ind++; + return table[sample_index]; } -/******************** INTERRUPT SERVICE ROUTINE ***********************/ +/******************** INTERRUPT SERVICE ROUTINE ***********************/ /********************************** Ex2 ***************************************/ void ISR_AIC(void) { - // temporary variable used to output values from function - float wave_out, wave; - sine_phase_ind = sine_phase_ind % sampling_freq; - wave = sinegen(); - wave_out = wave < 0 ? wave : -wave; + // temporary variable used to output values from function + float wave_out, wave; + sine_phase_ind = sine_phase_ind % sampling_freq; + wave = sinegen(); + wave_out = wave < 0 ? wave : -wave; - mono_write_16Bit((short)(wave_out*32767)); + mono_write_16Bit((short)(wave_out*32767)); } /********************************** Ex1 ***************************************/ /*void ISR_AIC() { - short mono_out, mono_in; - mono_in = mono_read_16Bit(); - mono_out = mono_in; //mono_in < 0 ? -mono_in : mono_in; - mono_write_16Bit(mono_out); + short mono_out, mono_in; + mono_in = mono_read_16Bit(); + mono_out = mono_in; //mono_in < 0 ? -mono_in : mono_in; + mono_write_16Bit(mono_out); } */ |