📄 csl_gpioaux.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_gpioAux.h
*
* Path: \\(CSLPATH)\\ipmodules\\gpio\\src
*
* @brief API Auxilary header file for GPIO CSL.
*
*/
/* ============================================================================
* Revision History
* ===============
* 03-Mar-2005 Nsr Updated changes (PSG00000289) in CSL_gpioSetBit and
* CSL_gpioClearBit.
* 22-Feb-2005 Nsr Added CSL_gpioGetBit API according to TI Issue PSG00000310.
* 11-Oct-2004 Nsr Changed this file according to review commnets.
* 04-Sep-2004 Nsr Added inline functions for query commands also.
* 04-Sep-2004 Nsr File Created from CSL_gpioHwControl.c And
* CSL_gpioGetHwStatus.c.
*
* ============================================================================
*/
#ifndef _CSL_GPIOAUX_H_
#define _CSL_GPIOAUX_H_
#include<csl_gpio.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Status Query Functions of gpio.
*/
/** ===========================================================================
* @n@b CSL_gpioBankIntEnable
*
* @b Description
* @n This function enables the GPIO bank interrupt .
*
* @b Arguments
* @verbatim
hGpio Handle to GPIO instance
bankNum This variable holds the GPIO bank number.
@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_gpioBankIntEnable (hGpio,bankNum);
@endverbatim
* ============================================================================
*/
static inline
CSL_Status CSL_gpioBankIntEnable (
/** Pointer to the object that holds reference to the
* instance of GPIO requested after the call
*/
CSL_GpioHandle hGpio,
CSL_GpioBankNum bankNum
)
{
CSL_Status status = CSL_SOK;
CSL_GpioRegsOvly gpioRegs = hGpio->regs;
if (bankNum <= hGpio->numBanks && bankNum >0) {
CSL_FINSR (gpioRegs->BINTEN, bankNum-1, bankNum-1, TRUE);
}
else {
status = CSL_EGPIO_INVPARAM;
}
return status;
}
/** ===========================================================================
* @n@b CSL_gpioBankIntDisable
*
* @b Description
* @n This function disables the GPIO bank interrupt .
*
* @b Arguments
* @verbatim
hGpio Handle to GPIO instance
bankNum this is variable to hold the GPIO bank number.
@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_gpioBankIntDisable (hGpio,bankNum);
@endverbatim
* ============================================================================
*/
static inline
CSL_Status CSL_gpioBankIntDisable (
/** Pointer to the object that holds reference to the
* instance of GPIO requested after the call
*/
CSL_GpioHandle hGpio,
CSL_GpioBankNum bankNum
)
{
CSL_Status status = CSL_SOK;
CSL_GpioRegsOvly gpioRegs = hGpio->regs;
if (bankNum <= hGpio->numBanks) {
CSL_FINSR (gpioRegs->BINTEN, bankNum-1, bankNum-1, FALSE);
}
else {
status = CSL_EGPIO_INVPARAM;
}
return status;
}
/** ===========================================================================
* @n@b CSL_gpioConfigBit
*
* @b Description
* @n This function used to configure the direction and rising and falling
edge trigger registers.
*
* @b Arguments
* @verbatim
hGpio Handle to GPIO instance
config Pointer to the CSL_GpioConfig 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_gpioConfigBit (hGpio,&config);
@endverbatim
* ============================================================================
*/
static inline
CSL_Status CSL_gpioConfigBit (
/** Pointer to the object that holds reference to the
* instance of GPIO requested after the call
*/
CSL_GpioHandle hGpio,
CSL_GpioConfig *config
)
{
CSL_Status status = CSL_SOK;
CSL_GpioPinNum pinNum;
CSL_GpioTriggerType trigger;
Uint32 index;
CSL_GpioRegsOvly gpioRegs = hGpio->regs;
pinNum = config->pinNum;
if (pinNum < hGpio->numPins) {
index = pinNum >> 5;
pinNum = (CSL_GpioPinNum) (pinNum & 0x1f);
trigger = config->trigger;
CSL_FINSR (gpioRegs->BANK[index].DIR, pinNum, pinNum,
config->direction);
if (trigger & CSL_GPIO_TRIG_RISING_EDGE) {
CSL_FINSR (gpioRegs->BANK[index].SET_RIS_TRIG,pinNum,pinNum, TRUE);
}
else {
CSL_FINSR (gpioRegs->BANK[index].CLR_RIS_TRIG,pinNum,pinNum, TRUE);
}
if (trigger & CSL_GPIO_TRIG_FALLING_EDGE) {
CSL_FINSR (gpioRegs->BANK[index].SET_FAL_TRIG,pinNum,pinNum, TRUE);
}
else {
CSL_FINSR (gpioRegs->BANK[index].CLR_FAL_TRIG,pinNum,pinNum, TRUE);
}
}
else {
status = CSL_EGPIO_INVPARAM;
}
return status;
}
/** ===========================================================================
* @n@b CSL_gpioSetBit
*
* @b Description
* @n This function sets the bit value of SET_DATA register in the GPIO
* module.
*
* @b Arguments
* @verbatim
hGpio Handle to GPIO instance
pinNum This variable holds the GPIO pin number.
@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_gpioSetBit (hGpio,pinNum);
@endverbatim
* ============================================================================
*/
static inline
CSL_Status CSL_gpioSetBit (
/** Pointer to the object that holds reference to the
* instance of GPIO requested after the call
*/
CSL_GpioHandle hGpio,
CSL_GpioPinNum pinNum
)
{
CSL_Status status = CSL_SOK;
Uint32 index;
CSL_GpioRegsOvly gpioRegs = hGpio->regs;
if (pinNum < hGpio->numPins) {
index = (pinNum >> 5);
pinNum = (CSL_GpioPinNum)(pinNum & 0x1f);
/* NSR: Modified according to TI comments */
/* CSL_FINSR(gpioRegs->BANK[index].SET_DATA, pinNum, pinNum, 1);
*/
gpioRegs->BANK[index].SET_DATA = (1<<pinNum);
}
else {
status = CSL_EGPIO_INVPARAM;
}
return status;
}
/** ===========================================================================
* @n@b CSL_gpioClearBit
*
* @b Description
* @n This function sets the bit value of CLR_DATA register.
*
* @b Arguments
* @verbatim
hGpio Handle to GPIO instance
pinNum This variable holds the GPIO pin number.
@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_gpioClearBit (hGpio,pinNum);
@endverbatim
* ============================================================================
*/
static inline
CSL_Status CSL_gpioClearBit (
/** Pointer to the object that holds reference to the
* instance of GPIO requested after the call
*/
CSL_GpioHandle hGpio,
CSL_GpioPinNum pinNum
)
{
CSL_Status status = CSL_SOK;
Uint32 index;
CSL_GpioRegsOvly gpioRegs = hGpio->regs;
if (pinNum < hGpio->numPins) {
index = (pinNum >> 5);
pinNum = (CSL_GpioPinNum)(pinNum & 0x1f);
/* NSR: Modified according to TI comments */
/* CSL_FINSR(gpioRegs->BANK[index].CLR_DATA, pinNum, pinNum, 1);
*/
gpioRegs->BANK[index].CLR_DATA = (1<<pinNum);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -