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

📄 csl_spiaux.h

📁 dsp在音频处理中的运用
💻 H
字号:

/** @file csl_spiAux.h
 *
 *    @brief File for defining auxillary functions used in CSL API 
 *           @a CSL_spiHwControl() and @a CSL_spiGetHwStatus()
 *
 *  Description
 *    - The definitions of functions associated with 
 *      @a CSL_spiHwControl() and @a CSL_spiGetHwStatus() functions
 *
 *  Modification 1
 *    - modified on: 26/12/2003
 *    - reason: created the sources
 *
 *  Modification 2
 *    - modified on: 05/01/2004
 *    - reason: created better documentation
 *
 *  @date 26th Dec, 2003
 *    @author Sumant S. NaikKhanvte
 *
 *  Modification 3
 *    - modified on 04/02/2005
 *    - reason: Removed MibSPI compatible code. 
 *              
 *  @date 4th Feb, 2005
 *    @author S Prasad
 */


#ifndef _CSL_SPIAUX_H_
#define _CSL_SPIAUX_H_

#include <csl_spi.h>

#ifdef __cplusplus
extern "C" {
#endif

static inline
void CSL_spiPriReset(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                         hSpi
)
{
    CSL_FINS(hSpi->regs->SPI_SCR, SPI_SPISCR_RESET, CSL_SPI_SPISCR_RESET_YES);

    while(0 == CSL_FEXT(hSpi->regs->SPI_SSR, SPI_SPISSR_RESET));
}

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->SPI_SET1, SPI_SPISET1_DMA, dmaEn);
}



static inline
void CSL_spiInt(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                         hSpi,
    CSL_SpiHwControlCmd                   cmd,
    Uint16                                intVal
)
{

    if (CSL_SPI_CMD_INT_ENABLE == cmd) {
        hSpi->regs->SPI_IER |= intVal;
    } else if (CSL_SPI_CMD_INT_DISABLE == cmd) {
        hSpi->regs->SPI_IER &= ~intVal;
    }

}


static inline
void CSL_spiEvtClear(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                         hSpi,
    Uint16                                evtVal
)
{
    Uint16 isrVal = hSpi->regs->SPI_ISR;

    hSpi->regs->SPI_ISR = (isrVal & evtVal);
}


static inline
void CSL_spiXferCtrl(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                         hSpi,
    Uint8                                 xferVal
)
{
    Uint32 ctrl = hSpi->regs->SPI_CTRL & (~(CSL_SPI_INT_TX_MASK|CSL_SPI_INT_RX_MASK));

    ctrl |= (xferVal & (CSL_SPI_INT_TX_MASK|CSL_SPI_INT_RX_MASK));
    hSpi->regs->SPI_CTRL = ctrl;
}


static inline
void CSL_spiEnable(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                       hSpi    	
)
{
     CSL_FINST(hSpi->regs->SPI_SET1, SPI_SPISET1_SPIEN, ENABLE);
}

static inline
void CSL_spiDisable(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                       hSpi    	
)
{
     CSL_FINST(hSpi->regs->SPI_SET1, SPI_SPISET1_SPIEN, DISABLE);
}

static inline
void CSL_spiStatusCptBuf(
    /* pointer to the object that holds reference to the
     * instance of MMCSD requested after the call */
    CSL_SpiHandle                    hSpi,
    Uint8                            *bufStat
)
{
    *bufStat = hSpi->regs->SPI_DSR;
}

static inline
void CSL_spiIntSource(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                         hSpi,
    Uint16                           	  *intVal
)
{
    *intVal = CSL_FEXT(hSpi->regs->SPI_ISR, SPI_SPIISR_FLAG);
}

static inline
void CSL_spiEvtStatus(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                         hSpi,
    Uint16                                *intVal
)
{
    *intVal = CSL_FEXT(hSpi->regs->SPI_ISR, SPI_SPIISR_FLAG);
}

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
)
{
    hSpi = hSpi;
    *dmaVal = CSL_FEXT(hSpi->regs->SPI_SET1, SPI_SPISET1_DMA);
}

static inline
void CSL_spiSetCSel(
    CSL_SpiHandle                   hSpi,
    Uint8                           csel
)
{
    CSL_FINS(hSpi->regs->SPI_CTRL, SPI_SPICTRL_CSEL, csel);
}


static inline
void CSL_spiSetNB(
    CSL_SpiHandle                   hSpi,
    Uint8                           nBits
)
{
    CSL_FINS(hSpi->regs->SPI_CTRL, SPI_SPICTRL_NBITS, (nBits - 1));
}


static inline
void CSL_spiLoopback(
    CSL_SpiHandle                   hSpi,
    Uint32                          pVal
)
{
    CSL_FINS(hSpi->regs->SPI_TEST, SPI_SPITEST_LOOPBK, pVal);
}

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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