⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csl_spiaux.h

📁 基于ti tms320c672x下音频开发例子程式
💻 H
📖 第 1 页 / 共 3 页
字号:
/** @file csl_spiAux.h
 *
 * @brief   Header file for functional layer of CSL
 *
 * Description
 *    - The defines inline function definitions
 *
 */

/*  ============================================================================
 *   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
 *  ===============
 *  10-Sep-2004 Hs Added inline functions for query commands also.
 *  10-Sep-2004 Hs File Created from CSL_spiHwControl.c.
 *
 * =============================================================================
 */
#ifndef _CSLR_SPI_H_
#define _CSLR_SPI_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <csl_spi.h>


/** ============================================================================
 *   @n@b CSL_spiGetHwSetupPriFmt
 *
 *   @b Description
 *   @n This function gets the hardware setup of data format regs of the SPI.
 *
 *   @b Arguments
 *   @verbatim
            hSpi                    Handle to SPI instance
            fmtNum                  format number,
            *confFmt                pointer to config format

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiGetHwSetupPriFmt (hSpi, fmtNum, &confFmt);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiGetHwSetupPriFmt(
    CSL_SpiHandle                   hSpi,
    Uint8                           fmtNum,
    CSL_SpiHwSetupPriFmt            *confFmt
)
{

    Uint32 temp = hSpi->regs->SPIFMT[fmtNum];

    confFmt->wDelay   = CSL_FEXT(temp, SPI_SPIFMT_WDELAY);
    confFmt->preScale = CSL_FEXT(temp, SPI_SPIFMT_PRESCALE);
    confFmt->charLen  = CSL_FEXT(temp, SPI_SPIFMT_CHARLEN);
    confFmt->waitEna  = (CSL_SpiWaitEn)CSL_FEXT(temp, SPI_SPIFMT_WAITEN);
    confFmt->parity   = (CSL_SpiParity)CSL_FEXTR(temp, 23, 22);
    confFmt->phase    = (CSL_SpiClkPhase)CSL_FEXT(temp, SPI_SPIFMT_PHASE);
    confFmt->polarity = (CSL_SpiClkPolarity)
                    CSL_FEXT(temp, SPI_SPIFMT_POLARITY);
    confFmt->shiftDir = (CSL_SpiShDir)
                    CSL_FEXT(temp, SPI_SPIFMT_SHIFTDIR);
}


/** ============================================================================
 *   @n@b CSL_spiGetHwSetupCptInt
 *
 *   @b Description
 *   @n This function gets the hardware setup of interrupt levels of the SPI
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *intVal         pointer to the interrupt level

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiGetHwSetupCptInt (hSpi, &intVal);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiGetHwSetupCptInt(
    CSL_SpiHandle                   hSpi,
    Uint32                          *intVal
)
{
    *intVal = hSpi->regs->SPILVL;
}


/** ============================================================================
 *   @n@b CSL_spiGetHwSetupGen
 *
 *   @b Description
 *   @n This function gets the general hardware setup of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *genPtr         pointer to the structure

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiGetHwSetupGen (hSpi, &genPtr);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiGetHwSetupGen(
    CSL_SpiHandle                   hSpi,
    CSL_SpiHwSetupGen               *genPtr
)
{
    CSL_SpiRegsOvly regsPtr = hSpi->regs;
    Uint32 temp;

    genPtr->protocol = (CSL_SpiProtocol)CSL_FEXT(regsPtr->MIBSPIE,
                                                 SPI_MIBSPIE_MIBSPIENA);
    genPtr->opMode   = (CSL_SpiOpMod)CSL_FEXTR(regsPtr->SPIGCR1, 1, 0);
    genPtr->enaHiZ   = (CSL_SpiEnaHiZ)CSL_FEXT(regsPtr->SPIINT0,
                                                 SPI_SPIINT0_ENABLEHIGHZ);

    temp = regsPtr->SPIDELAY;
    genPtr->c2tDelay = CSL_FEXT(temp, SPI_SPIDELAY_C2TDELAY);
    genPtr->t2cDelay = CSL_FEXT(temp, SPI_SPIDELAY_T2CDELAY);
    genPtr->t2eTmout = CSL_FEXT(temp, SPI_SPIDELAY_T2EDELAY);
    genPtr->c2eTmout = CSL_FEXT(temp, SPI_SPIDELAY_C2EDELAY);
}

/** ============================================================================
 *   @n@b CSL_spiGetHwSetupGpio
 *
 *   @b Description
 *   @n This function gets the hardware setup of Global Pin config regs of SPI.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            gpioType        GPIO type
            *value          return value

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiGetHwSetupGpio (hSpi, gpioType, &value);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiGetHwSetupGpio(
    CSL_SpiHandle                   hSpi,
    CSL_SpiGpioType                gpioType,
    Uint16                          *value
)
{
    switch (gpioType) {
        case CSL_SPI_GPIOTYPE_FUNC:
            *value = hSpi->regs->SPIPC0;
            break;

        case CSL_SPI_GPIOTYPE_DIR:
            *value = hSpi->regs->SPIPC1;
            break;

        case CSL_SPI_GPIOTYPE_PULLCTRL:
            *value = hSpi->regs->SPIPC7;
            break;

        case CSL_SPI_GPIOTYPE_OPNDRAIN:
            *value = hSpi->regs->SPIPC6;
            break;
    }
}

/** ============================================================================
 *   @n@b CSL_spiGetHwSetupCptFmtCtrl
 *
 *   @b Description
 *   @n This function gets the hardwar setup of the DAT1 reg of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *fmtCtrlPtr     pointer to the format controller structure

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiGetHwSetupCptFmtCtrl (hSpi, &fmtCtrlPtr);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiGetHwSetupCptFmtCtrl(
    CSL_SpiHandle                   hSpi,
    CSL_SpiHwSetupFmtCtrl           *fmtCtrlPtr
)
{
    Uint32 temp = hSpi->regs->SPIDAT1;

    fmtCtrlPtr->csHold = (CSL_SpiCsHold)CSL_FEXT(temp, SPI_SPIDAT1_CSHOLD);
    fmtCtrlPtr->wDel   = (CSL_SpiWDelayEn)CSL_FEXT(temp, SPI_SPIDAT1_WDEL);
    fmtCtrlPtr->fmtSel = (CSL_SpiFmtSel)CSL_FEXT(temp, SPI_SPIDAT1_DFSEL);
    fmtCtrlPtr->cSel   = CSL_FEXT(temp, SPI_SPIDAT1_CSNR);
}

/** ============================================================================
 *   @n@b CSL_spiPwrStat
 *
 *   @b Description
 *   @n This function gets the power down mode of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *pwrMod         pointer to the power down mode value

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiPwrStat (hSpi, &pwrMod);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiPwrStat(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                   hSpi,
    CSL_SpiPwrStat                  *pwrMod
)
{
    *pwrMod = (CSL_SpiPwrStat)CSL_FEXT(hSpi->regs->SPIGCR1, SPI_SPIGCR1_POWERDOWN);
}


/** ============================================================================
 *   @n@b CSL_spiPinVal
 *
 *   @b Description
 *   @n This function returns the value of pin control reg 2 of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *pinVal         pointer to the SPI PC2 register content value

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiPinVal (hSpi, &pinVal);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiPinVal(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                   hSpi,
    Uint32                          *pinVal
)
{
    *pinVal = hSpi->regs->SPIPC2;
}


/** ============================================================================
 *   @n@b CSL_spiIntEnabled
 *
 *   @b Description
 *   @n This function returns the interrupt register value of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *intVal         pointer to the interrupt reg content value

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_spiIntEnabled (hSpi, &intVal);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiIntEnabled(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                   hSpi,
    Uint32                          *intVal
)
{
    *intVal = CSL_FEXTR(hSpi->regs->SPIINT0, 8, 0);

⌨️ 快捷键说明

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