📄 csl_spihwsetup.c
字号:
/* ============================================================================ * 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_spiHwSetup.c * * @brief File for functional layer of CSL API @a CSL_spiHwSetup() * * Description * - The @a CSL_spiHwSetup() function definition & it's associated * functions * * Path: \\(CSLPATH)\\ipmodules\\spi\\src * * Modification 1 * - modified on: 26/12/2003 * - reason: created the sources * * Modification 2 * - modified on: 05/01/2004 * - reason: created better documentation * * Modification 3 * - modified on: 01/03/2004 * - reason: modified according to review comments * * Modification 4 * - modified on: 10/05/2004 * - reason: removed MIB from code & documentation * * Date 26th Dec, 2003 * Author Sumant S. NaikKhanvte *//* ============================================================================= * Revision History * =============== * 11-oct-2004 HMM Updated code review comments * 01-Sep-2004 HMM File Updated. * ============================================================================= */#include <csl_spi.h>#include <csl_spiAux.h>/** @brief Format number */#define CSL_SPI_FMT_NO 4/** ============================================================================ * @n@b CSL_spiHwSetup * * @b Description * @n It configures the SPI instance registers as per the values passed * in the hardware setup structure. * * @b Arguments * @verbatim hSpi Handle to the SPI instance setup Pointer to hardware setup structure @endverbatim * * <b> Return Value </b> CSL_Status * @li CSL_SOK - Hardware setup successful * @li CSL_ESYS_BADHANDLE - Invalid handle * @li CSL_ESYS_INVPARAMS - Hardware structure is not * properly initialized * * <b> Pre Condition </b> * @n None * * <b> Post Condition </b> * @n The specified instance will be setup according to value passed * * @b Modifies * @n Hardware registers for the specified instance * * @b Example * @verbatim CSL_status status; CSL_spiHwSetup hwSetup; status = CSL_spiHwSetup (hSpi, &hwSetup); @endverbatim * =========================================================================== */#pragma CODE_SECTION (CSL_spiHwSetup, ".text:csl_section:spi")CSL_Status CSL_spiHwSetup ( CSL_SpiHandle hSpi, CSL_SpiHwSetup *setup){ int fmtNo; CSL_Status status = CSL_SOK; if (hSpi == NULL) { return CSL_ESYS_BADHANDLE; } if ((setup == NULL) || (setup->cptPtr == NULL) || (setup->genPtr == NULL) || (setup->pinsPtr == NULL) || (setup->priPtr == NULL)) { return CSL_ESYS_INVPARAMS; } if (setup->genPtr) { CSL_spiHwSetupGen(hSpi, setup->genPtr); } if (setup->priPtr) { CSL_SpiHwSetupPri *priPtr = setup->priPtr; CSL_SpiHwSetupPriFmt **fmt = priPtr->fmt; for (fmtNo = 0; fmtNo < CSL_SPI_FMT_NO; fmtNo++) { if (*fmt) { CSL_spiHwSetupPriFmt(hSpi, fmtNo, *fmt); } fmt++; } } if (setup->pinsPtr) { CSL_SpiHwSetupPins *pinsPtr = setup->pinsPtr; if (pinsPtr->func) { CSL_spiHwSetupGpio(hSpi, CSL_SPI_GPIOTYPE_FUNC, *(pinsPtr->func)); } if (pinsPtr->dir) { CSL_spiHwSetupGpio(hSpi, CSL_SPI_GPIOTYPE_DIR, *(pinsPtr->dir)); } if (pinsPtr->pullCtrl) { CSL_spiHwSetupGpio(hSpi, CSL_SPI_GPIOTYPE_PULLCTRL, *(pinsPtr->pullCtrl)); } if (pinsPtr->opnDrain) { CSL_spiHwSetupGpio(hSpi, CSL_SPI_GPIOTYPE_OPNDRAIN, *(pinsPtr->opnDrain)); } } if (setup->cptPtr) { CSL_SpiHwSetupCpt *cptPtr = setup->cptPtr; if (cptPtr->lvl) { CSL_spiHwSetupCptInt(hSpi, *(cptPtr->lvl)); } if (cptPtr->fmtCtrlPtr) { /* assuming that SPIDAT1 bug will get fixed */ CSL_spiHwSetupCptFmtCtrl(hSpi, cptPtr->fmtCtrlPtr); } } return status;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -