📄 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 Header file for functional layer of CSL * * Description * - The defines inline function definitions * *//* ============================================================================ * Copyright (c) Texas Instruments Inc 2002, 2003, 2004
* * Use of this software is controlled by the terms and conditions found in the * license agreement under which this software has been supplied. * =========================================================================== */#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 * =========================================================================== */static 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_WAITENA); confFmt->phase = (CSL_SpiClkPhase)CSL_FEXT(temp, SPI_SPIFMT_PHASE); confFmt->polarity = (CSL_SpiClkPolarity) 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 * =========================================================================== */static 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 * =========================================================================== */static inlinevoid CSL_spiGetHwSetupGen( CSL_SpiHandle hSpi, CSL_SpiHwSetupGen *genPtr){ CSL_SpiRegsOvly regsPtr = hSpi->regs; Uint32 temp; genPtr->opMode = (CSL_SpiOpMod)CSL_FEXTR(regsPtr->SPIGCR1, 1, 0); genPtr->enaHiZ = (CSL_SpiEnaHiZ)CSL_FEXT(regsPtr->SPIINT0, SPI_SPIINT0_ENABLEHIGHZ); temp = regsPtr->SPIDELAY; genPtr->c2tDelay = CSL_FEXT(temp, SPI_SPIDELAY_C2TDELAY); genPtr->t2cDelay = CSL_FEXT(temp, SPI_SPIDELAY_T2CDELAY); genPtr->t2eTmout = CSL_FEXT(temp, SPI_SPIDELAY_T2EDELAY); genPtr->c2eTmout = CSL_FEXT(temp, SPI_SPIDELAY_C2EDELAY);}/** ============================================================================ * @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 * =========================================================================== */static inlinevoid CSL_spiGetHwSetupGpio( CSL_SpiHandle hSpi, CSL_SpiGpioType gpioType, Uint16 *value){ if(gpioType == CSL_SPI_GPIOTYPE_FUNC) { *value = hSpi->regs->SPIPC0; } if(gpioType == CSL_SPI_GPIOTYPE_DIR) { *value = hSpi->regs->SPIPC1; }}/** ============================================================================ * @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 * =========================================================================== */static 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_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 * =========================================================================== */static inlinevoid CSL_spiPinVal( /** pointer to the object that holds reference to the * instance of SPI requested after the call */ 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 * =========================================================================== */static inlinevoid CSL_spiIntEnabled( /** pointer to the object that holds reference to the * instance of SPI requested after the call */ 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 * =========================================================================== */static inlinevoid 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 inlinevoid 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); }/** ============================================================================ * @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 inlinevoid 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 inlinevoid 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_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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -