📄 csl_gpioopen.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_gpioOpen.c
*
* @brief File for functional layer of CSL API @a CSL_gpioOpen()
*
* Description
* - The @a CSL_gpioOpen() function definition & it's associated functions
*
* Path: \\(CSLPATH)\\ipmodules\\gpio\\src
*
* @date 10 June, 2004
* @author Pratheesh Gangadhar
*/
/* ============================================================================
* Revision History
* ===============
* 21-Mar-2005 Nsr Updated according to TI PSG00000325 issue.
* 11-Oct-2004 Nsr renamed the local variable "st" as "status"
* 04-Sep-2004 Nsr Updated function and documentation for CSL_gpioOpen.
* - Removed the include file, csl_resource.h.
*
* ============================================================================
*/
#include <csl_gpio.h>
/** ===========================================================================
* @n@b CSL_gpioOpen
*
* @b Description
* @n This function populates the peripheral data object for the GPIO
* instance and returns a handle to the instance.
* The open call sets up the data structures for the particular instance
* of GPIO 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
pGpioObj Pointer to the GPIO instance object
gpioNum Instance of the GPIO to be opened
pGpioParam Pointer to module specific parameters
pStatus pointer for returning status of the function call
@endverbatim
*
* <b> Return Value </b> CSL_GpioHandle
* @n Valid GPIO instance handle will be returned if
status value is equal to CSL_SOK.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n 1. GPIO object structure is populated
* @n 2. The status is returned in the status variable. If status
* returned is
* @li CSL_SOK Valid gpio handle is returned
* @li CSL_ESYS_FAIL The gpio instance is invalid
* @li CSL_ESYS_INVPARAMS Invalid parameter
*
* @b Modifies
* @n 1. The status variable
* @n 2. GPIO object structure
*
* @b Example
* @verbatim
CSL_status status;
CSL_GpioObj gpioObj;
CSL_GpioHandle hGpio;
...
hGpio = CSL_gpioOpen (&gpioObj, CSL_GPIO_PER_CNT, NULL, &status);
...
@endverbatim
* ============================================================================
*/
#pragma CODE_SECTION (CSL_gpioOpen, ".text:csl_section:gpio");
CSL_GpioHandle CSL_gpioOpen (
CSL_GpioObj *pGpioObj,
CSL_InstNum gpioNum,
CSL_GpioParam *pGpioParam,
CSL_Status *pStatus
)
{
CSL_Status status;
CSL_GpioHandle hGpio;
CSL_GpioBaseAddress baseAddress;
if (pGpioObj == NULL) {
*pStatus = CSL_ESYS_INVPARAMS;
return NULL;
}
status = CSL_gpioGetBaseAddress(gpioNum, pGpioParam, &baseAddress);
if (status == CSL_SOK) {
pGpioObj->regs = baseAddress.regs;
pGpioObj->gpioNum = (CSL_InstNum)gpioNum;
pGpioObj->numBanks = CSL_GPIO_NUM_BANKS;
pGpioObj->numPins = CSL_GPIO_NUM_PINS;
hGpio = (CSL_GpioHandle)pGpioObj;
}
else {
pGpioObj->regs = (CSL_GpioRegsOvly)NULL;
pGpioObj->gpioNum = (CSL_InstNum)-1;
hGpio = (CSL_GpioHandle)NULL;
}
if (pStatus) {
*pStatus = status;
}
return hGpio;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -