Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*****************************************************************************
- ** **
- ** Name: BF537 C Talkthrough I2S **
- ** **
- ******************************************************************************
- Analog Devices, Inc. All rights reserved.
- File Name: Main.c
- Date Modified: 12/14/04 Rev 1.0
- 01/11/05 Rev 1.1 Updated to work on Rev 1.1 of the ADSP-BF537 EZ-Kit
- Hardware: ADSP-BF537 EZ-KIT Board Rev 1.1
- Users of ADSP-BF537 EZ-KIT Board Rev 1.0 must change the SPORT to
- generate internal clock and frame sync
- Purpose: This program sets up the ADSP-BF537 to reset the ADC and DAC.
- The data to/from the DAC/ADC are transfered over SPORT0 in I2S mode.
- Program Parameters:
- ******************************************************************************/
- #include "Talkthrough.h"
- #include <sysreg.h>
- #include <ccblkfn.h>
- /*****************************************************************************
- Variables
- Description: The variables ChannelxLeftIn and ChannelxRightIn contain
- the data coming from the codec ADC (AD1871). The (processed)
- playback data are written into the variables
- ChannelxLeftOut and ChannelxRightOut respectively, which
- are then sent back to the DAC (AD1854) in the SPORT0 ISR.
- ******************************************************************************/
- // left input data from AD1871
- int iChannel0LeftIn, iChannel1LeftIn;
- // right input data from AD1871
- int iChannel0RightIn, iChannel1RightIn;
- // left ouput data for AD1854
- int iChannel0LeftOut, iChannel1LeftOut;
- // right ouput data for AD1854
- int iChannel0RightOut, iChannel1RightOut;
- // SPORT0 DMA transmit buffer
- int iTxBuffer1[2];
- // SPORT0 DMA receive buffer
- int iRxBuffer1[2];
- int delayMilliseconds = 500; // half a second
- int delaySamples; // assumes 44800 Hz sample rate
- float decay = 0.5f;
- int buffer[5000];
- int current = 0;
- //--------------------------------------------------------------------------//
- // Function: main //
- // //
- // Description: After calling a few initalization routines, main() just //
- // waits in a loop forever. The code to process the incoming //
- // data can be placed in the function Process_Data() in the //
- // file "Process_Data.c". //
- //--------------------------------------------------------------------------//
- void main(void)
- {
- delaySamples = (int)((float)delayMilliseconds * 44.8f);
- Init_Flags();
- Audio_Reset();
- Init_Sport0();
- Init_DMA();
- Init_Interrupts();
- Enable_DMA_Sport0();
- while(1);
- }
- //////////////////////////////////////////////////////////////////
- #include "Talkthrough.h"
- extern float decay;
- extern int delaySamples;
- extern int current;
- extern int buffer[];
- //------------------------------------------------------------------//
- // Function: Process_Data() //
- // //
- // Description: This function is called from inside the SPORT0 ISR every //
- // time a complete audio frame has been received. The new //
- // input samples can be found in the variables iChannel0LeftIn,//
- // iChannel0RightIn, iChannel1LeftIn and iChannel1RightIn //
- // respectively. The processed data should be stored in //
- // iChannel0LeftOut, iChannel0RightOut, iChannel1LeftOut, //
- // iChannel1RightOut, iChannel2LeftOut and iChannel2RightOut //
- // respectively. //
- //--------------------------------------------------------------------------//
- void Process_Data(void)
- {
- int i;
- buffer[current] = iChannel0LeftIn;
- for (i = 0; i < 5000; i++)
- {
- buffer[i] += (int)((float)iChannel0LeftIn * decay);
- }
- iChannel0LeftOut = buffer[current];
- iChannel0RightOut = iChannel0LeftOut;
- if(current++ >= 5000){
- current = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement