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

📄 csl_spiaux.h

📁 基于ti tms320c672x下音频开发例子程式
💻 H
📖 第 1 页 / 共 3 页
字号:
}


/** ============================================================================
 *   @n@b CSL_spiEvtStatus
 *
 *   @b Description
 *   @n This function sets the flag status register of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *intVal         pointer to the flag register contents 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_spiEvtStatus (hSpi, &intval);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiEvtStatus(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                   hSpi,
    Uint8                           *intVal
)
{
    *intVal = CSL_FEXTR(hSpi->regs->SPIFLG, 8, 1);
    CSL_FINSR(hSpi->regs->SPIFLG, 8, 1, *intVal);
}


/** ============================================================================
 *   @n@b CSL_spiIntVector
 *
 *   @b Description
 *   @n This function gets the status of Interruipt Vector reg of SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            intType         type of interrupt
            *intVec         pointer to int vector 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_spiIntVector (hSpi, intType, &intVec);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiIntVector(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                   hSpi,
    CSL_SpiHwStatusQuery            intType,
    CSL_SpiIntVec                   *intVec
)
{
    Uint32 temp;

    if (CSL_SPI_QUERY_INT_VECTOR0 == intType) {
        temp = hSpi->regs->TGINTVECT[0];
    }
    else if (CSL_SPI_QUERY_INT_VECTOR1 == intType) {
        temp = hSpi->regs->TGINTVECT[1];
    }

    intVec->intVal  = CSL_FEXT(temp, SPI_TGINTVECT_INTVECT);
    intVec->suspend = CSL_FEXT(temp, SPI_TGINTVECT_SUSPEND);
}

/** ============================================================================
 *   @n@b CSL_spiCptDmaEnabled
 *
 *   @b Description
 *   @n This function gets the DMA Request mode from int reg of SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *dmaval         pointer to the value got from int register
     @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_spiCptDmaEnabled (hSpi, &dmaVal);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiCptDmaEnabled(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                   hSpi,
    Uint16                          *dmaVal
)
{
    *dmaVal = CSL_FEXT(hSpi->regs->SPIINT0, SPI_SPIINT0_DMAREQEN);
}

/** ============================================================================
 *   @n@b CSL_spiPriResetOut
 *
 *   @b Description
 *   @n This function does a soft reset of the SPI.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance

     @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_spiPriResetOut (hSpi);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiPriResetOut(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                   hSpi
)
{
    CSL_FINST(hSpi->regs->SPIGCR0, SPI_SPIGCR0_RESET, NO);
}

/** ============================================================================
 *   @n@b CSL_spiPwr
 *
 *   @b Description
 *   @n This function handles power down mode of the SPI module.
 *      0 : Active
 *      1 : Power down
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            pwrMod          powerdown mode

     @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_spiPwr (hSpi, pwrMod);

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

/** ============================================================================
 *   @n@b CSL_spiCptDma
 *
 *   @b Description
 *   @n This function handles the DMA request of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            dmaEn           Enable/disable DMA

     @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_spiCptDma (hSpi, dmaEn);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiCptDma(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    CSL_SpiCptDma                  dmaEn
)
{
    CSL_FINS(hSpi->regs->SPIINT0, SPI_SPIINT0_DMAREQEN, dmaEn);
}

/** ============================================================================
 *   @n@b CSL_spiCptWrite0
 *
 *   @b Description
 *   @n This function writes data on the SPI.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            val             data to be written

     @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_spiCptWrite0 (hSpi, val);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiCptWrite0(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    Uint16                         val
)
{
    CSL_FINS(hSpi->regs->SPIDAT0, SPI_SPIDAT0_SPIDAT0, val);
}


/** ============================================================================
 *   @n@b CSL_spiCptWrite1
 *
 *   @b Description
 *   @n This function writes data on the SPI.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            val             value to be written

     @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_spiCptWrite1 (hSpi, val);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiCptWrite1(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    Uint16                         val
)
{
    CSL_FINS(hSpi->regs->SPIDAT1, SPI_SPIDAT1_SPIDAT1, val);
}


/** ============================================================================
 *   @n@b CSL_spiCptRead
 *
 *   @b Description
 *   @n This function reads the SPI data buffer.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *data           pointer to the buffer that receives data
            *bufStat        pointer to the buffer status register

     @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_spiCptRead (hSpi, &data, &bufStat);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiCptRead(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    Uint16                         *data,
    CSL_SpiBufStat                 *bufStat
)
{
    Uint32 temp = hSpi->regs->SPIBUF;
    *data = CSL_FEXT(temp, SPI_SPIBUF_SPIBUF);
    if (bufStat) {
        bufStat->status = CSL_FEXTR(temp, 31, 25);
        bufStat->cSel   = CSL_FEXT(temp, SPI_SPIBUF_LCSNR);
    }
}


/** ============================================================================
 *   @n@b CSL_spiInt
 *
 *   @b Description
 *   @n This function initializes the SPI module.
 *
 *   @b Arguments
 *   @verbatim

⌨️ 快捷键说明

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