- Main Page
- Modules
- Data Structures
- Files

Functions
GPIO Functions
GPIO

## Functions
GPIO_Handle | GPIO_open (CSL_GpioObj *GPIOobj, CSL_Status *status)
CSL_Status | GPIO_close (GPIO_Handle hGPIO)
CSL_Status | GPIO_config (GPIO_Handle GPIOHandle, CSL_GpioConfig *config)
CSL_Status | GPIO_getConfig (GPIO_Handle hGpio, CSL_GpioConfig *config)
CSL_Status | GPIO_read (GPIO_Handle hGPIO, CSL_GpioPinNum pinNum, Uint16 *buffer)
CSL_Status | GPIO_write (GPIO_Handle hGPIO, CSL_GpioPinNum pinNum, Uint16 buffer)
CSL_Status | GPIO_reset (GPIO_Handle hGPIO)
CSL_Status | GPIO_configBit (GPIO_Handle hGpio, CSL_GpioPinConfig *config)
CSL_Status | GPIO_disableInt (GPIO_Handle hGpio, CSL_GpioPinNum pin)
CSL_Status | GPIO_enableInt (GPIO_Handle hGpio, CSL_GpioPinNum pin)
CSL_Status | GPIO_clearInt (GPIO_Handle hGpio, CSL_GpioPinNum pin)
int | GPIO_statusBit (GPIO_Handle hGpio, CSL_GpioPinNum pin, CSL_Status *status)

## Function Documentation

CSL_Status GPIO_clearInt | ( | GPIO_Handle | hGpio,
|  | CSL_GpioPinNum | pinNum
| ) |  |

===========================================================================
GPIO_clearInt

Description
This function clears the GPIO interrupt flag bit for the particular pin .

Arguments

                hGpio            Handle to GPIO instance.
                pinNum           Pin Number

Return Value CSL_Status
CSL_SOK - GPIO_clearInt is successfull
CSL_ESYS_BADHANDLE - Invalid Handle
CSL_ESYS_INVPARAMS - Invalid Parameters

Pre Condition
GPIO_open and GPIO_configBit should be called before calling this API

Post Condition
Interrupt will be cleared

Modifies
GPIO Interrupt Flag Register

Example

            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);
            .....
            pinNum = config.pinNum;

            ...
           GPIO_clearInt(hGPIO,pinNum);

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_BIT_SET, CSL_GPIO_PIN0, CSL_GPIO_PIN16, and CSL_GPIO_PIN31.

CSL_Status GPIO_close | ( | GPIO_Handle | hGpio | ) |

============================================================================
GPIO_close

Description
This function closes the handle .

Arguments

                hGPIO            Handle to the GPIO

Return Value CSL_Status

- CSL_SOK - GPIO_close is successful
- CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
GPIO_open API should be called before calling this API call

Post Condition
The handler will be closed

Modifies
1. hGPIO - GPIO handle Example

                GPIO_Handle     hGPIO;
                CSL_status       status;
                ...

                status = GPIO_close(hGPIO);

============================================================================

References CSL_GpioObj::baseAddr, and CSL_GpioObj::numPins.

CSL_Status GPIO_config | ( | GPIO_Handle | hGpio,
|  | CSL_GpioConfig * | config
| ) |  |

============================================================================
GPIO_config

Description
It configures the GPIO Registers according to the corresponding config structure. Arguments

                GPIOHandle      Handle to GPIO module

                config          Config structure

     *

Return Value CSL_Status

- CSL_OK - GPIO_config call is successful
- CSL_ESYS_BADHANDLE - Invalid handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
GPIO_open API should be called before this API call

Post Condition
GPIO Registers will be configured according to config structure values Modifies
1. The status variable
2. GPIO Registers

Example

             CSL_Status     status;
             CSL_GpioObj    GpioObj;
             GPIO_Handle    GPIOHandle ;
             CSL_GpioConfig config;
             config.GPIODIRL = 0x0011;
             config.GPIODIRH = 0x0101;
             config.GPIOINTTRIGL = 0x0101;
             config.GPIOINTTRIGH = 0x0010;
             config.GPIOINTENAL = 0x1100;
             config.GPIOINTENAH = 0x1010;
             ...
             GPIOHandle = GPIO_open (&GpioObj,&status);
             if(CSL_SOK == status){
             ...
             status = GPIO_config(GPIOHandle,&config);
             }
             ...

============================================================================

References CSL_GpioObj::baseAddr, CSL_GpioConfig::GPIODIRH, CSL_GpioConfig::GPIODIRL, CSL_GpioConfig::GPIOINTENAH, CSL_GpioConfig::GPIOINTENAL, CSL_GpioConfig::GPIOINTTRIGH, and CSL_GpioConfig::GPIOINTTRIGL.

CSL_Status GPIO_configBit | ( | GPIO_Handle | hGpio,
|  | CSL_GpioPinConfig * | config
| ) |  |

===========================================================================
GPIO_configBit

Description
This function used to configure the direction and rising and falling edge trigger GPIO registers.

Arguments

                hGpio            Handle to GPIO instance
                config           Pointer to the CSL_GpioPinConfig structure.

Return Value CSL_Status

- CSL_SOK - GPIO_configBit is successfull
- CSL_ESYS_BADHANDLE - The handle is passed is invalid
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
GPIO_open should be called before calling this API

Post Condition
Configures any of the 32 GPIO signals

Modifies
GPIO Direction Register,GPIO Edge triggerInterrupt Registers

Example

            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_DIR_INPUT, CSL_GPIO_DIR_OUTPUT, CSL_GPIO_PIN0, CSL_GPIO_PIN16, CSL_GPIO_TRIG_CLEAR_EDGE, CSL_GPIO_TRIG_FALLING_EDGE, CSL_GPIO_TRIG_RISING_EDGE, CSL_GpioPinConfig::direction, CSL_GpioPinConfig::pinNum, and CSL_GpioPinConfig::trigger.

CSL_Status GPIO_disableInt | ( | GPIO_Handle | hGpio,
|  | CSL_GpioPinNum | pinNum
| ) |  |

===========================================================================
GPIO_disableInt

Description
This function disables the GPIO interrupt for the pin .

Arguments

                hGPIO            Handle to GPIO instance.
                pinNum           Pin Number

Return Value CSL_Status
CSL_SOK - GPIO_disableInt is successfull
CSL_ESYS_BADHANDLE - Invalid Handle
CSL_ESYS_INVPARAMS - Invalid Parameters Pre Condition
GPIO_open and GPIO_configBit should be called before calling this API

Post Condition
Interrupt will be disabled

Modifies
GPIO Interrupt Enable Register

Example

            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);
            pinNum = config.pinNum;
            GPIO_disableInt(hGPIO,pinNum);

============================================================================

===========================================================================
GPIO_disableInt

Description
This function disables the GPIO interrupt for the pin .

Arguments

                hGPIO            Handle to GPIO instance.
                pinNum           Pin Number

Return Value
CSL_SOK - GPIO_disableInt is successfull
CSL_ESYS_BADHANDLE - Invalid Handle
CSL_ESYS_INVPARAMS - Invalid Parameters Pre Condition
GPIO_open and GPIO_configBit should be called before calling this API

Post Condition
Interrupt will be disabled

Modifies
GPIO Interrupt Enable Register

Example

            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);
            pinNum = config.pinNum;
            GPIO_disableInt(hGPIO,pinNum);

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_BIT_RESET, CSL_GPIO_PIN0, CSL_GPIO_PIN16, and CSL_GPIO_PIN31.

CSL_Status GPIO_enableInt | ( | GPIO_Handle | hGpio,
|  | CSL_GpioPinNum | pinNum
| ) |  |

===========================================================================
GPIO_enableInt

Description
This function enables the GPIO interrupt .

Arguments

                hGPIO            Handle to GPIO instance.
                pinNum           Pin Number

Return Value CSL_Status
CSL_SOK - GPIO_enableInt is successfull
CSL_ESYS_BADHANDLE - Invalid Handle
CSL_ESYS_INVPARAMS - Invalid Parameters

Pre Condition
GPIO_open and GPIO_configBit should be called before calling this API

Post Condition
Interrupt will be enabled

Modifies
GPIO Interrupt Enable Register

Example

            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);
            .....
            pinNum = config.pinNum;
            GPIO_enableInt(hGpio,pinNum);

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_BIT_SET, CSL_GPIO_PIN0, CSL_GPIO_PIN16, and CSL_GPIO_PIN31.

CSL_Status GPIO_getConfig | ( | GPIO_Handle | hGpio,
|  | CSL_GpioConfig * | config
| ) |  |

============================================================================
GPIO_getConfig

Description
It stores the GPIO H/w Registers values in GPIO config structure

Arguments

                GPIOHandle      Handle to GPIO module

                config          Config structure

     *

Return Value CSL_Status

- CSL_OK - GPIO_getConfig call is successful
- CSL_ESYS_BADHANDLE - Invalid handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
GPIO_open API should be called before this API call

Post Condition
GPIO Registers values will be populated in config structure Modifies
1. The status variable
2. config structure

Example

             CSL_Status     status;
             CSL_GpioObj    GpioObj;
             GPIO_Handle    GPIOHandle ;
             CSL_GpioConfig config;
             ...
             GPIOHandle = GPIO_open (&GpioObj,&status);
             if(CSL_SOK == status){
             ...
             status = GPIO_getConfig(GPIOHandle,&config);
             }
             ...

============================================================================

References CSL_GpioObj::baseAddr, CSL_GpioConfig::GPIODIRH, CSL_GpioConfig::GPIODIRL, CSL_GpioConfig::GPIOINTENAH, CSL_GpioConfig::GPIOINTENAL, CSL_GpioConfig::GPIOINTTRIGH, and CSL_GpioConfig::GPIOINTTRIGL.

GPIO_Handle GPIO_open | ( | CSL_GpioObj * | GpioObj,
|  | CSL_Status * | status
| ) |  |

============================================================================
GPIO_Open

Description
This function returns the handle to the GPIO module, This handle is passed to all other CSL APIs.

Arguments

               GpioObj  -  GPIO object structure Pointer
               status   -  Pointer to CSL_Status
     *

Return Value GPIO_Handle
Valid GPIO handle will be returned

Pre Condition
None

Post Condition
This API call should return a valid handle to GPIO module

Modifies
1. The status variable
2. GPIO object structure Pointer

Example

                CSL_GpioObj           GpioObj
                GPIO_Handle           hGPIO;
                CSL_Status            *status;
                ...

                hGPIO = GPIO_open(&GpioObj,&status);
                ...

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_NUM_PIN, and CSL_GpioObj::numPins.

CSL_Status GPIO_read | ( | GPIO_Handle | hGpio,
|  | CSL_GpioPinNum | pinNum,
|  | Uint16 * | buffer
| ) |  |

============================================================================
GPIO_read

Description
It reads the pin value - high or low

Arguments

                hGPIO        Handle to the GPIO

                readBuffer   Pointer to the output buffer

Return Value CSL_Status

- CSL_SOK - GPIO_read is successfull

- CSL_ESYS_BADHANDLE - The handle is passed is invalid
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
GPIO_open and GPIO_config or(GPIO_configBit) should be called before calling this API

Post Condition
The output value of pin will be populated in the output buffer passed in the API

Modifies
buffer variable

Example

            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            CSL_GpioPinNum pinNum;
            Uint16   readBuffer;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);
            ...
            pinNum = config.pinNum;
            ....
           status = GPIO_read(hGPIO,pinNum,&readBuffer);

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_PIN0, CSL_GPIO_PIN16, and CSL_GPIO_PIN31.

CSL_Status GPIO_reset | ( | GPIO_Handle | hGpio | ) |

============================================================================
GPIO_reset

Description
It reset the given pin - 1) set pin dir as input 2) Disable the interrupt

Arguments

                hGPIO         Handle to the GPIO

                PinNumber     GPIO pin number

Return Value CSL_Status

- CSL_SOK - GPIO_write is successfull
- CSL_ESYS_BADHANDLE - The handle is passed is invalid
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
GPIO_open should be called before calling this API

Post Condition
It sets the default value in the Registers

Modifies
GPIO Direction,GPIO Interrupt Enable and GPIO Interrupt Flag Registers Example

                CSL_GpioObj    GpioObj;
                GPIO_Handle     hGPIO;
                CSL_GpioPinNum  pinNum;

                hGPIO = GPIO_open(&GpioObj,&status);
                if(CSL_SOK == status){
                ...

                status = GPIO_reset(hGPIO,pinNum);
                }

============================================================================

References CSL_GpioObj::baseAddr.

int GPIO_statusBit | ( | GPIO_Handle | hGpio,
|  | CSL_GpioPinNum | pinNum,
|  | CSL_Status * | status
| ) |  |

===========================================================================
GPIO_statusBit

Description
This function reads the GPIO interrupt flag bit for the particular pin .

Arguments

                hGpio            Handle to GPIO instance.
                pinNum           Pin Number

Return Value
Return the Interrupt Flag bit value for the pin 1 or 0

Pre Condition
GPIO_open and GPIO_configBit should be called before calling this API

Post Condition
Reads the Interrupt Bit

Modifies
1 Status variable
2 Return value

Example

            CSL_Status  status;
            int   flag;
            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);
            .....
            pinNum = config.pinNum;
            GPIO_enableInt(hGpio,pinNum);
             ...
            flag = GPIO_statusBit(hGpio,pinNum);

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_PIN0, CSL_GPIO_PIN16, and CSL_GPIO_PIN31.

CSL_Status GPIO_write | ( | GPIO_Handle | hGpio,
|  | CSL_GpioPinNum | pinNum,
|  | Uint16 | buffer
| ) |  |

============================================================================
GPIO_write

Description
It writes value to the o/p pin - high or low

Arguments

                hGPIO        Handle to the GPIO

                writeBuffer   Pointer to the output buffer

Return Value CSL_Status

- CSL_SOK - GPIO_write is successfull
- CSL_ESYS_BADHANDLE - The handle is passed is invalid
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
GPIO_open and GPIO_config or (GPIO_configBit) should be called before calling this API

Post Condition
It drives the o/p pin high or low according to writeBuffer

Modifies
GPIO DATA OUT Registers

Example

            CSL_GpioObj     GpioObj;
            GPIO_Handle     hGPIO;
            CSL_GpioPinConfig config;
            CSL_GpioPinNum pinNum;
            Uint16   writeBuffer = 1;
            ....
            hGPIO = GPIO_open(&GpioObj,&status);
            ....
            config.pinNum = CSL_GPIO_PIN1;
            config.direction = CSL_GPIO_DIR_OUTPUT;
            config.trigger  = CSL_GPIO_TRIG_FALLING_EDGE;
            GPIO_configBit (hGPIO, &config);
            ...
            pinNum = config.pinNum;
            ....

            status = GPIO_write(hGPIO,pinNum, writeBuffer);

============================================================================

References CSL_GpioObj::baseAddr, CSL_GPIO_PIN0, CSL_GPIO_PIN16, CSL_GPIO_PIN31, GPIO_DRIVE_HIGH, and GPIO_DRIVE_LOW.