csl_mbxaux.h

来自「dsp在音频处理中的运用」· C头文件 代码 · 共 222 行

H
222
字号
/** ============================================================================
 *   @file  csl_mbxAux.h
 *
 *   @path  $(CSLPATH)\arm\mailbox\src
 *
 *   @desc  API Auxilary header file for mailbox CSL on ARM side.
 *
 */

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

/* =============================================================================
 *  Revision History
 *  ===============
 *  22-Jun-2004 sp File Created.
 *
 * =============================================================================
 */

#ifndef _CSL_MBXAUX_H_
#define _CSL_MBXAUX_H_

/* Inline Functions */

#include<csl_mbx.h>

/**============================================================================
 *   @n@b CSL_mbxWriteDataRegs
 *
 *   @b Description
 *   @n This function writes the data into the data registers of the mailbox.
 *
 *   @b Arguments
     @verbatim
            hMbx        Handle to mailbox instance

            mbxData     Pointer to the buffer containing data to be written to
                        mailbox registers
     @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li        CSL_SOK : Write operation successful
 *   @li        CSL_ESYS_INVPARAMS : Invalid parameters
 *   @li        CSL_ESYS_NOTSUPPORTED : Operation invalid on instance
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n         1. If the return status is CSL_SOK, the Mailbox registers are
                   populated with the values pointed by pMbxData.
 *
 *   @b Modifies
 *   @n  CSL_MbxObj structure
 *
 *   @b Example
 *   @verbatim
            CSL_MbxData*        pMbxData;
            CSL_Status          status;
            ...
            status = CSL_mbxWriteDataRegs(hMbx, pMbxData);
     @endverbatim
 * ===========================================================================
 */

 #ifdef __cplusplus
 extern "C" {
 #endif


static inline CSL_Status CSL_mbxWriteDataRegs (
    CSL_MbxHandle hMbx,
    CSL_MbxData* pMbxData
)
{
    CSL_Status status = CSL_SOK;

    if (hMbx->accessType == CSL_MBX_RDWR){
        switch(pMbxData->dataWidth)
        {
            case CSL_MBX_DATA_32BIT:
                {
                    Uint32 dataValue;
                    
                    dataValue = (Uint32)(pMbxData->data);
                    hMbx->dataRegs->MBXDATA_REGA = \
                                (Uint16)((dataValue & 0xFFFF0000) >> 16);
                    hMbx->dataRegs->MBXDATA_REGB = \
                                (Uint16) (dataValue & 0x0000FFFF);
                }
                break;
            case CSL_MBX_DATA_16BIT:
                {
                    hMbx->dataRegs->MBXDATA_REGA = (Uint16)0x0000;
                    hMbx->dataRegs->MBXDATA_REGB = (Uint16) (pMbxData->data);
                }
                break;
            default:
                status = CSL_ESYS_INVPARAMS;
        }
    }
    else
        status = CSL_ESYS_NOTSUPPORTED;

    return status;
}

/**============================================================================
 *   @n@b CSL_mbxGetFlagStatus
 *
 *   @b Description
 *   @n This function gets the status of the interrupt flag register of
 *      the mailbox.
 *
 *   @b Arguments
     @verbatim
            hMbx            Handle to mailbox instance
     @endverbatim
 *
 *   <b> Return Value </b>  Bool
 *   @li       TRUE    : Flag is set
 *   @li       FLASE   : Flag is reset
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
            Bool flag;

            flag = CSL_mbxGetFlagStatus (hMbx);
     @endverbatim
 * ===========================================================================
 */

static inline Bool CSL_mbxGetFlagStatus (
    CSL_MbxHandle hMbx
)
{
    Bool response = (Bool) CSL_FEXT(hMbx->intrRegs->MBXFLAG_REG, MBX_MBXFLAG_REG_INT);
    return response;
}

/**============================================================================
 *   @n@b CSL_mbxGetData
 *
 *   @b Description
 *   @n This function fetches the data from the data registers of the mailbox.
 *
 *   @b Arguments
     @verbatim
            hMbx        Handle to mailbox instance

            dataWidth   Width of the data to be fetched
     @endverbatim
 *
 *   <b> Return Value </b>  Data
 *   @li       Data : If successful
 *   @li       NULL : If the data width is other than CSL_MBX_DATA_32BIT or
                      CSL_MBX_DATA_16BIT
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
            Uint32              data;
            CSL_MbxDataWidth    dataWidth;
            ...
           data = CSL_mbxGetData (hMbx, dataWidth);
     @endverbatim
 * ===========================================================================
 */

static inline Uint32 CSL_mbxGetData (
    CSL_MbxHandle hMbx,
    CSL_MbxDataWidth dataWidth
)
{
    Uint32 data;

    switch(dataWidth)
    {
        case CSL_MBX_DATA_32BIT:
            data = (((Uint32)hMbx->dataRegs->MBXDATA_REGA << 16) |
                     (Uint32)hMbx->dataRegs->MBXDATA_REGB);
            break;
        case CSL_MBX_DATA_16BIT:
            data = (Uint32)hMbx->dataRegs->MBXDATA_REGB;
            break;;
        default:
            data = 0;
    }

    return data;
}

#ifdef __cplusplus
}
#endif


#endif /*_CSL_MBXAUX_H_*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?