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

📄 csl_spiaux.h

📁 基于ti tms320c672x下音频开发例子程式
💻 H
📖 第 1 页 / 共 3 页
字号:
            hSpi            Handle to SPI instance
            cmd             command to enable or disable interrupts
            intVal          interrupt 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_spiInt (hSpi, cmd, intVal);

     @endverbatim
 * ===========================================================================
 */
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->SPIINT0 |= intVal;
    }
    else if (CSL_SPI_CMD_INT_DISABLE == cmd) {
        hSpi->regs->SPIINT0 &= ~intVal;
    }
}

/** ============================================================================
 *   @n@b CSL_spiPins
 *
 *   @b Description
 *   @n This function sets/clears the PC3/4/5 registers of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            cmd             command to set the PC3/4/5 registers
            pinVal          value to be set

     @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_spiPins (hSpi, cmd, pinVal);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiPins(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    CSL_SpiHwControlCmd            cmd,
    Uint32                         pinVal
)
{
    if (CSL_SPI_CMD_PINS_VALUE == cmd) {
        hSpi->regs->SPIPC3 = pinVal;
    }
    else if (CSL_SPI_CMD_PINS_SET == cmd) {
        hSpi->regs->SPIPC4 = pinVal;
    }
    else if (CSL_SPI_CMD_PINS_CLEAR == cmd) {
        hSpi->regs->SPIPC5 = pinVal;
    }
}

/** ============================================================================
 *   @n@b CSL_spiXferCtrl
 *
 *   @b Description
 *   @n This function configures the transmission params for the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            xferEn          Enable/hiold the SPI in reset

     @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_spiXferCtrl (hSpi, xferEn);

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

/** ============================================================================
 *   @n@b CSL_spiHwSetupPriFmt
 *
 *   @b Description
 *   @n This function sets up the SPI a/c to Hwsetup structure of SPI.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            fmtNum          Format register
            *confFmt        pointer to h/w setup fmt 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_spiHwSetupPriFmt (hSpi, fmtNum, &conffmt);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiHwSetupPriFmt(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    /** instance number of the format register to setup */
    Uint8                          fmtNum,
    /** setup structure for the format register */
    CSL_SpiHwSetupPriFmt           *confFmt
)
{
    hSpi->regs->SPIFMT[fmtNum] = CSL_FMK(SPI_SPIFMT_WDELAY,
                        confFmt->wDelay) |
                                    CSL_FMK(SPI_SPIFMT_PRESCALE,
                        confFmt->preScale) |
                                    CSL_FMK(SPI_SPIFMT_CHARLEN,
                        confFmt->charLen) |
                                    CSL_FMK(SPI_SPIFMT_WAITEN,
                        confFmt->waitEna) |
                                    CSL_FMKR(confFmt->parity, 23, 22) |
                                    CSL_FMK(SPI_SPIFMT_POLARITY,
                        confFmt->polarity) |
                                    CSL_FMK(SPI_SPIFMT_PHASE,
                        confFmt->phase) |
                                    CSL_FMK(SPI_SPIFMT_SHIFTDIR,
                        confFmt->shiftDir);
}

/** ============================================================================
 *   @n@b CSL_spiHwSetupCptInt
 *
 *   @b Description
 *   @n This function sets the interrupt level of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            intVal          bit-vector for interrupts

     @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_spiHwSetupCptInt (hSpi, intVal);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiHwSetupCptInt(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    /** bit-vector for interrupts */
    Uint32                         intVal
)
{
    hSpi->regs->SPILVL = intVal;
}


/** ============================================================================
 *   @n@b CSL_spiHwSetupGen
 *
 *   @b Description
 *   @n This function does the hardware setup of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *genPtr         pointer to the HW setup gen 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_spiHwSetupGen (hSpi, &genPtr);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiHwSetupGen(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    CSL_SpiHwSetupGen              *genPtr
)
{
    CSL_SpiRegsOvly regsPtr = hSpi->regs;
    Uint32 temp;

    CSL_FINS(regsPtr->MIBSPIE, SPI_MIBSPIE_MIBSPIENA, genPtr->protocol);

    temp = regsPtr->SPIGCR1;
    CSL_FINS(temp, SPI_SPIGCR1_CLKMOD, CSL_FEXTR(genPtr->opMode, 1, 1));
    CSL_FINS(temp, SPI_SPIGCR1_MASTER, CSL_FEXTR(genPtr->opMode, 0, 0));
    regsPtr->SPIGCR1 = temp;

    CSL_FINS(regsPtr->SPIINT0, SPI_SPIINT0_ENABLEHIGHZ, genPtr->enaHiZ);

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

/** ============================================================================
 *   @n@b CSL_spiHwSetupGpio
 *
 *   @b Description
 *   @n This function sets up the PC0/1/6/7 registers of the SPI module.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            gpioType        gpiotype
            value           value to be set

     @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_spiHwSetupGpio (hSpi, gpioType, value);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiHwSetupGpio(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    CSL_SpiGpioType               gpioType,
    Uint32                         value
)
{
    switch (gpioType) {
        case CSL_SPI_GPIOTYPE_FUNC:
            hSpi->regs->SPIPC0 = value;
            break;

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

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

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

/** ============================================================================
 *   @n@b CSL_spiHwSetupCptFmtCtrl
 *
 *   @b Description
 *   @n This function sets up the SPI a/c to fmtCtrl structure.
 *
 *   @b Arguments
 *   @verbatim
            hSpi            Handle to SPI instance
            *fmtCtrlPtr     pointer to the fmtCtrl 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_spiHwSetupCptFmtCtrl (hSpi, &fmtCtrlPtr);

     @endverbatim
 * ===========================================================================
 */
static inline
void CSL_spiHwSetupCptFmtCtrl(
    /** pointer to the object that holds reference to the
     * instance of SPI requested after the call */
    CSL_SpiHandle                  hSpi,
    CSL_SpiHwSetupFmtCtrl          *fmtCtrlPtr
)
{
    Uint32 temp;
    temp = CSL_FMK(SPI_SPIDAT1_CSHOLD, fmtCtrlPtr->csHold) |
           CSL_FMK(SPI_SPIDAT1_WDEL, fmtCtrlPtr->wDel) |
           CSL_FMK(SPI_SPIDAT1_DFSEL, fmtCtrlPtr->fmtSel) |
           CSL_FMK(SPI_SPIDAT1_CSNR, fmtCtrlPtr->cSel);
    CSL_FINSR(hSpi->regs->SPIDAT1, 32, 16, CSL_FEXTR(temp, 32, 16));
}

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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