/*  ============================================================================
 *  Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005
 *
 *  Use of this software is controlled by the terms and conditions found in the
 *  license agreement under which this software has been supplied.
 *  ===========================================================================
 */

/** @file csl_dmaxHwSetupFifoParam.c
 *
 *  @brief File for functional layer of CSL API @a CSL_dmaxHwSetupFifoParam()
 *
 *  Description
 *    - The @a CSL_dmaxHwSetupFifoParam() function definition & it's associated
 *      functions
 *
 *  Modification 1
 *    - Modified on: 11/March/2005
 *    - Reason: created the sources
 * 
 *  @author asr.
 */

#include <csl_dmax.h>
/** =======================================================================
 *   @n@b CSL_dmaxHwSetupFifoParam
 *
 *   @b Description
 *   @n This function initializes the device registers with the appropriate
 *      values provided through the HwSetup Data structure. After the 
 *      Setup is completed, the device is ready for  operation.      
 *      For information passed through the HwSetup Data structure refer
 *   @a CSL_dmaxHwSetup.
 *
 *   @b Arguments
 *   @verbatim
 *    
 *          paramEntry  Pointer to Prameter Table Entry where data is to be 
 *						stored
 *          setup  		Pointer to a dmax FIFO Transfer Setup Object
 *           
 *   @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_SOK - Successful completion of hardware     
 *                                    setup
 *   @li                    CSL_ESYS_ INVPARAMS - Hardware structure is not 
 *                                    properly initialized
 *   @li                    CSL_ESYS_ BADHANDLE - Invalid CSL handle
 *
 *
 *   <b> Pre Condition </b>
 *   @n  Both CSL_dmaxInit() and a CSL_dmaxOpen() must be called
 *
 *   <b> Post Condition </b>
 *   @n  DMAX registers are configured 
 *
 *   @b  Modifies
 *   @n  DMAX registers
 *
 *   @b Example
 *   @verbatim  
      CSL_DmaxParameterEntry 	paramEntry;
      CSL_dmaxHwSetup 			hwSetup;
      
      hwSetup.linearReload0  = 0x10000100;
      .
      .
      hwSetup.count0         = 3;
    
      CSL_dmaxHwSetupFifoXFRParameterEntry(hDmax, &hwSetup);
     @endverbatim
 * 
 * ============================================================================
 */
#pragma CODE_SECTION \
    (CSL_dmaxSetupFifoXFRParameterEntry, ".text:csl_section:dmax");
CSL_Status CSL_dmaxSetupFifoXFRParameterEntry (
    CSL_DmaxParameterEntry 		*paramEntry,
    CSL_DmaxFifoParameterSetup	*setup
)
{
    CSL_Status	st;
    Uint32		*tmpPtr = (Uint32 *) paramEntry;

    st = CSL_SOK;
    /*
     * the linearReload0 address value copied into BOTH 
     * the reload address register AND the active address 
     * register.
     */
    tmpPtr[0] = setup->linearReload0;
    tmpPtr[1] = setup->pfd;
    tmpPtr[2] = CSL_FMK (DMAX_FIFORW_COUNT0, setup->count0) |
        		CSL_FMK (DMAX_FIFORW_COUNT1, setup->count1);
    tmpPtr[3] = setup->linearIndx0;
    tmpPtr[4] = setup->linearIndx1;
    tmpPtr[5] = CSL_FMK (DMAX_FIFORW_COUNT0, setup->count0) |
        		CSL_FMK (DMAX_FIFORW_COUNT1, setup->count1);
    tmpPtr[6] = setup->linearReload0;
    tmpPtr[7] = setup->linearReload1;
    tmpPtr[8] = setup->delayTabPtr0;
    tmpPtr[9] = setup->delayTabPtr1;

    return st;
}
