📄 csl_spiaux.h
字号:
/* ============================================================================ * Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005 * * Use of this software is controlled by the terms and conditions found in the * license agreement under which this software has been supplied. * =========================================================================== *//** @file csl_spiAux.h * * @brief API Auxilary header file for SPI CSL. * * Description * - The defines inline function definitions * * Path: \\(CSLPATH)\\ipmodules\\spi\\src *//* ============================================================================= * Revision History * =============== * 10-Sep-2004 Hs Added inline functions for query commands also. * 10-Sep-2004 Hs File Created from CSL_spiHwControl.c. * ============================================================================= */#ifndef _CSL_SPIAUX_H_#define _CSL_SPIAUX_H_#ifdef __cplusplusextern "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 * ============================================================================ */CSL_IDEF_INLINEvoid 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_SpiPhase) CSL_FEXT(temp, SPI_SPIFMT_PHASE); confFmt->polarity = (CSL_SpiPolarity) 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 * =========================================================================== */CSL_IDEF_INLINEvoid 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 * =========================================================================== */CSL_IDEF_INLINEvoid 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_ENAHIGHZ); temp = regsPtr->SPIDELAY; genPtr->c2tDelay = CSL_FEXT(temp, SPI_SPIDELAY_C2T); genPtr->t2cDelay = CSL_FEXT(temp, SPI_SPIDELAY_T2C); genPtr->t2eTmout = CSL_FEXT(temp, SPI_SPIDELAY_T2E); genPtr->c2eTmout = CSL_FEXT(temp, SPI_SPIDELAY_C2E);}/** ============================================================================ * @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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiGetHwSetupGpio ( CSL_SpiHandle hSpi, CSL_SpiGpioType gpioType, Uint32 *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 * =========================================================================== */CSL_IDEF_INLINEvoid 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiPwrStat ( CSL_SpiHandle hSpi, CSL_SpiPwrStat *pwrMod){ *pwrMod = (CSL_SpiPwrStat) CSL_FEXT(hSpi->regs->SPIGCR1, SPI_SPIGCR1_PWRDN);}/** ============================================================================ * @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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiPinVal ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiIntEnabled ( CSL_SpiHandle hSpi, Uint32 *intVal){ *intVal = CSL_FEXTR(hSpi->regs->SPIINT0, 8, 0);}/** ============================================================================ * @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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiEvtStatus ( 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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiIntVector ( CSL_SpiHandle hSpi, CSL_SpiHwStatusQuery intType, CSL_SpiIntVec *intVec){ Uint32 temp; if (CSL_SPI_QUERY_INT_VECTOR0 == intType) { temp = hSpi->regs->TGINTVEC[0]; } else if (CSL_SPI_QUERY_INT_VECTOR1 == intType) { temp = hSpi->regs->TGINTVEC[1]; } intVec->intVal = CSL_FEXT(temp, SPI_TGINTVEC_INTVECT); intVec->suspend = CSL_FEXT(temp, SPI_TGINTVEC_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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiCptDmaEnabled ( CSL_SpiHandle hSpi, Uint16 *dmaVal){ *dmaVal = CSL_FEXT(hSpi->regs->SPIINT0, SPI_SPIINT0_DMAREQ);}/** ============================================================================ * @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 * =========================================================================== */CSL_IDEF_INLINEvoid CSL_spiPriResetOut ( 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 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -