/*
 * =============================================================================
 *
 *  ======== dspDma_int_mcbsp_dsp.c ========
 *
 *  Version 1.00
 *
 *	This example demonstrates two key features of the DSP DMA: double-indexing
 *	and auto-initialization with software channel context update control.
 
 *  Two DMA channels are used to copy data to/from internal DARAM to/from a McBSP
 *	operating in DLB mode. A double-buffered memory scheme is used where two
 *	PING/PONG buffers are used to receive data and a separate set of PING/PONG
 *  buffers are used to transmit data. While the DMA reads data from the PING 
 *  transmit buffer the DSP core is free to operate on the PONG transmit buffer.
 *  Similarly, while the DMA writes data to the PING receive buffer, the DSP core
 *  is free to process the PONG receive buffer. After the DMA is finished with
 *  the PING buffers, the DSP core reconfigures it such that it continues with
 *  the PONG buffers (or vice-versa).
 *
 *	Auto-initialization is used to reload the channel context after the block 
 *  transfer is completed. The ENDPROG bit is used to signal to the DMA that the
 *  DSP core has updated the channel context.
 *
 *	The data in the transmit buffers (PING or PONG) are initialized such that
 *  even numbers occupy the top half of the buffer and odd numbers occupy the
 *  bottom half. Using double indexing, the DMA channel assigned to copy data 
 *  from DARAM to the McBSP reads an even number from the transmit buffer (PING
 *  or PONG) and then an odd number. Therefore, the McBSP sees an even number, 
 *  an odd number, even, odd, even, odd, etc.
 *
 *	On the receive side, the DMA channel assigned to copy data from the McBSP to
 *	the receive buffers (PING or PONG) sorts the input stream (even, odd, even,
 *	odd, etc.) into even numbers and odd numbers once again (even numbers are
 *	written to the top half of the receive buffer and odd numbers to the bottom).
 *
 *  Note that the ping and pong buffers are linked to different DARAM blocks.
 *  This is done deliberately to avoid collisions between the DMA and the DSP
 *  core.
 * 
 *  Test Procedure (repeated on ARM-side code)
 *
 *  1. Connect the OMAP5912 OSK to the emulator on the host system.
 *  2. Power on the board.
 *  3. Configure CCS Setup to work with the OMAP5912 OSK using these GEL files:
       DSP: osk5912_dspside_no_reset.gel
       ARM: osk5912_prg.gel
 *  4. From the Parallel Debug Manager, launch the CCS window corresponding to 
 *     the ARM.
 *  5. On the ARM side CCS window, open the arm/dspDma_int_mcbsp_arm
 *     project.  (Don't worry about the missing files, you will specify a path
 *     to them next, hit Ignore All).
 *  6. Access the Debug build options for the project and specify the following:
 *     - Compiler Tab
 *       - the path for all the OMAP5912 ARM CSL include files
 *     - Linker Tab
 *       - library path for location of the TMS470 rts32e.lib
 *       - library path for the csl_OMAP5912.lib
 *  7. On the ARM side CCS window, compile, load, and execute the program.  The
 *     MPU code will configure the DMP MMU such that the DSP can see part of 
 *     the SDRAM on the OSK.
 *  8. From the Parallel Debug Manager, launch the CCS window corresponding to
 *     the DSP.
 *  9. On the DSP side CCS window, open the dsp/dspDma_int_mcbsp_dsp 
 *     project. (Don't worry about the missing files, you will specify a path to
 *     them next, hit Ignore All).
 *  10. Access the build options for the project and specify the following:
 *     - Compiler Tab
 *       - the path for all the CSL include files
 *     - Linker Tab
 *       - library path for location of the C55x rts55x.lib
 *       - library path for the csl_OMAP5912.lib
 *  11. On the DSP side CCS window, compile, load, and execute the program.
