📄 csl_spiaux.h
字号:
* <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n None * * @b Modifies * @n None * * @b Example * @verbatim CSL_spiPwr (hSpi, pwrMod); @endverbatim * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiPwr ( CSL_SpiHandle hSpi, CSL_SpiPwrStat pwrMod){ CSL_FINS(hSpi->regs->SPIGCR1, SPI_SPIGCR1_PWRDN, 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiCptDma ( CSL_SpiHandle hSpi, CSL_SpiCptDma dmaEn){ CSL_FINS(hSpi->regs->SPIINT0, SPI_SPIINT0_DMAREQ, 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiCptWrite0 ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiCptWrite1 ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiCptRead ( 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 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiInt ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiPins ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiXferCtrl ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiHwSetupPriFmt ( CSL_SpiHandle hSpi, Uint8 fmtNum, CSL_SpiHwSetupPriFmt *confFmt){ CSL_FINS(hSpi->regs->SPIFMT[fmtNum], SPI_SPIFMT_WDELAY, confFmt->wDelay); CSL_FINS(hSpi->regs->SPIFMT[fmtNum], SPI_SPIFMT_PRESCALE, confFmt->preScale); CSL_FINS(hSpi->regs->SPIFMT[fmtNum], SPI_SPIFMT_CHARLEN, confFmt->charLen); CSL_FINS(hSpi->regs->SPIFMT[fmtNum], SPI_SPIFMT_WAITEN, confFmt->waitEna); CSL_FINSR(hSpi->regs->SPIFMT[fmtNum], 23,22, confFmt->parity); CSL_FINS(hSpi->regs->SPIFMT[fmtNum], SPI_SPIFMT_POLARITY, confFmt->polarity); CSL_FINS(hSpi->regs->SPIFMT[fmtNum], SPI_SPIFMT_PHASE, confFmt->phase); CSL_FINS(hSpi->regs->SPIFMT[fmtNum], 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiHwSetupCptInt ( CSL_SpiHandle hSpi, 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiHwSetupGen ( 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_ENAHIGHZ, genPtr->enaHiZ); temp = CSL_FMK(SPI_SPIDELAY_C2T, genPtr->c2tDelay) | CSL_FMK(SPI_SPIDELAY_T2C, genPtr->t2cDelay) | CSL_FMK(SPI_SPIDELAY_T2E, genPtr->t2eTmout) | CSL_FMK(SPI_SPIDELAY_C2E, 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiHwSetupGpio ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiHwSetupCptFmtCtrl ( 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 + -