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

📄 csl_spiopen.c

📁 TI达芬奇dm644x各硬件模块测试代码
💻 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_spiOpen.c * *  @brief    File for functional layer of CSL API @a CSL_spiOpen() * *  Description *    - The @a CSL_spiOpen() function definition & it's associated functions * *  Path: \\(CSLPATH)\\ipmodules\\spi\\src * *  Modification 1 *    - modified on: 15/12/2003 *    - reason: created the sources * *  Modification 2 *    - modified on: 19/12/2003 *    - 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 15th Dec, 2003 *    Author Sumant S. NaikKhanvte *//* ============================================================================= *  Revision History *  =============== *  11-oct-2004 Hs Updated code review comments *  10-sep-2004 Hs Updated function and documentation for CSL_spiOpen. *                 - Removed the include file, csl_resource.h. * ============================================================================= */#include <csl_spi.h>/** ============================================================================ *   @n@b CSL_spiOpen * *   @b Description *   @n This function populates the peripheral data object for the SPI instance *        and returns a handle to the instance. *        The open call sets up the data structures for the particular instance *      of SPI device. The device can be re-opened anytime after it has been *      normally closed if so required. The handle returned by this call is *      input as an essential argument for rest of the APIs described *      for this module. * *   @b Arguments *   @verbatim            spiObj          Pointer to SPI object.            spiNum          Instance of SPI CSL to be opened.            pSpiParam       Module specific parameters.            status          Status of the function call     @endverbatim * *   <b> Return Value </b>  CSL_SpiHandle *   @n                         Valid SPI handle will be returned if *                              status value is equal to CSL_SOK. * *   <b> Pre Condition </b> *   @n  None * *   <b> Post Condition </b> *   @n   1.    The status is returned in the status variable. If status *              returned is *   @li            CSL_SOK             Valid SPI handle is returned *   @li            CSL_ESYS_FAIL       The SPI instance is invalid * *        2.    SPI object structure is populated * *   @b Modifies *   @n    1. The status variable * *         2. SPI object structure * *   @b Example *   @verbatim            CSL_status              status;       CSL_SpiObj     spiObj;            CSL_SpiHandle           hSpi;            hSpi = CSL_spiOpen (&spiObj, CSL_SPI, NULL, &status);       ...       @endverbatim * ============================================================================= */#pragma CODE_SECTION (CSL_spiOpen, ".text:csl_section:spi");CSL_SpiHandle CSL_spiOpen (    CSL_SpiObj              *pSpiObj,    CSL_InstNum              spiNum,    CSL_SpiParam            *pSpiParam,    CSL_Status              *pStatus){    CSL_Status            status;    CSL_SpiHandle hSpi    = (CSL_SpiHandle) NULL;    CSL_SpiBaseAddress    baseAddress;    if ((pSpiObj == NULL) || (spiNum < CSL_SPI)) {        *pStatus = CSL_ESYS_INVPARAMS;        return NULL;    }    if (pStatus == NULL) {        return NULL;    }    *pSpiParam = *pSpiParam;    status = CSL_spiGetBaseAddress(spiNum, pSpiParam, &baseAddress);    if (status == CSL_SOK) {        pSpiObj->regs   = baseAddress.regs;        pSpiObj->perNum = (CSL_InstNum)spiNum;        hSpi            = (CSL_SpiHandle)pSpiObj;    }    else {        pSpiObj->regs   = (CSL_SpiRegsOvly)NULL;        pSpiObj->perNum = (CSL_InstNum)-1;        hSpi            = (CSL_SpiHandle)NULL;    }    if (pStatus) {        *pStatus = status;    }    return (hSpi);}

⌨️ 快捷键说明

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