/*  ============================================================================
 *   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_dmaxGetHwStatus.c
 *
 *    @brief    File for functional layer of CSL API @a CSL_dmaxGetHwStatus()
 *
 *  Description
 *    - The @a CSL_dmaxGetHwStatus() function definition & it's associated
 *      functions
 *
 *  Modification 1
 *    - Modified on: 18/1/2005
 *    - Reason: created the sources
 *
 *    @author Ramitha Mathew.
 */

#include <csl_dmax.h>
#include <csl_dmaxAux.h>

/** @brief Gets the status of the different operations.
 */
/** ============================================================================
 *   @n@b CSL_dmaxGetHwStatus
 *
 *   @b Description
 *   @n Gets the status of the different operations of DMAX.
 *
 *   @b Arguments
 *   @verbatim
 *          hDmax       Handle to the DMAX instance 
 *          query       The query to this API of DMAX which indicates the
 *                      status to be returned.
 *          response    Placeholder to return the status.
 *
 *   @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_SOK             - Status info return successful
 *   @li                    CSL_ESYS_BADHANDLE  - Invalid handle
 *   @li                    CSL_ESYS_INVQUERY   - Invalid query command
 *   @li                    CSL_ESYS_INVPARAMS  - Invalid parameter
 *
 *   <b> Pre Condition </b>
 *   @n  dmax opened properly
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n "response" variable holds the queried value
 *
 *   @b Example
 *   @verbatim
        CSL_DmaxHandle          hDmax;
        CSL_DmaxHwStatusQuery   query;
        void*                   reponse;

        status = CSL_GetdmaxHwStatus (hDmax, query, &response);

     @endverbatim
 * =============================================================================
 */
#pragma CODE_SECTION (CSL_dmaxGetHwStatus, ".text:csl_section:dmax")

CSL_Status CSL_dmaxGetHwStatus (
    CSL_DmaxHandle 			hDmax,
    CSL_DmaxHwStatusQuery 	query,
    void 					*response
)
{

    CSL_Status	status = CSL_SOK;

    if (hDmax == NULL)
        return CSL_ESYS_BADHANDLE;

    if (response == NULL) {
        return CSL_ESYS_INVPARAMS;
    }

    switch (query) {
	    case CSL_DMAX_QUERY_EVENTFLAG:
	        CSL_dmaxGetEventFlag (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_TCC:
	        CSL_dmaxGetTcc (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_TC:
	        CSL_dmaxGetTc (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_FMSC:
	        CSL_dmaxGetFmsc (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_EMSC:
	        CSL_dmaxGetEmsc (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_FIFO_ERROR:
	        CSL_dmaxGetFifoError (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_FIFO_ERROR_CODE:
	        CSL_dmaxGetFifoErrorCode (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_EVENT_ENTRY:
	        CSL_dmaxGetEventEntry (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_PARAMETER_ENTRY:
	        CSL_dmaxGetParameterEntry (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_HBC:
	        CSL_dmaxGetHbc (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_LBC:
	        CSL_dmaxGetLbc (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_FIFO_ADDR:
	        CSL_dmaxGetFifoAddr (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_EVENT_ENTRY_ADDR:
	        CSL_dmaxGetEventEntryAddr (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_PARAMETER_ENTRY_ADDR:
	        CSL_dmaxGetParameterEntryAddr (hDmax, response);
	        break;
	
	    case CSL_DMAX_QUERY_GET_FIFO_FULL:
	        CSL_dmaxGetFifoFull (hDmax, response);
	        break;
	
	    default:
	        status = CSL_ESYS_INVQUERY;
	        break;
    }
    return status;
}
