# GPIO Functions
[GPIO]

## Functions

CSL_IDEF_INLINE void | CSL_GPIO_getPID (CSL_GpioHandle hGpio, Uint8 *scheme, Uint16 *function, Uint8 *rtl, Uint8 *major, Uint8 *custom, Uint8 *minor)
CSL_IDEF_INLINE void | CSL_GPIO_getPCR (CSL_GpioHandle hGpio, Uint8 *soft, Uint8 *free)
CSL_IDEF_INLINE void | CSL_GPIO_bankInterruptEnable (CSL_GpioHandle hGpio, Uint8 bankNum)
CSL_IDEF_INLINE void | CSL_GPIO_bankInterruptDisable (CSL_GpioHandle hGpio, Uint8 bankNum)
CSL_IDEF_INLINE Bool | CSL_GPIO_isBankInterruptEnabled (CSL_GpioHandle hGpio, Uint8 bankNum)
CSL_IDEF_INLINE void | CSL_GPIO_setPinDirOutput (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_setPinDirInput (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE Bool | CSL_GPIO_getPinDirection (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_getOutputData (CSL_GpioHandle hGpio, Uint8 pinNum, Uint8 *outData)
CSL_IDEF_INLINE void | CSL_GPIO_setOutputData (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_clearOutputData (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_getInputData (CSL_GpioHandle hGpio, Uint8 pinNum, Uint8 *inData)
CSL_IDEF_INLINE void | CSL_GPIO_setRisingEdgeDetect (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_clearRisingEdgeDetect (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE Bool | CSL_GPIO_isRisingEdgeDetect (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_setFallingEdgeDetect (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_clearFallingEdgeDetect (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE Bool | CSL_GPIO_isFallingEdgeDetect (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE Bool | CSL_GPIO_getInterruptStatus (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_IDEF_INLINE void | CSL_GPIO_clearInterruptStatus (CSL_GpioHandle hGpio, Uint8 pinNum)
CSL_GpioHandle | CSL_GPIO_open (Int32 instNum)

## Function Documentation

CSL_IDEF_INLINE void CSL_GPIO_bankInterruptDisable | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | bankNum |
| ) |  |  |

============================================================================
CSL_GPIO_bankInterruptDisable

Description
This function disables the GPIO per bank interrupt. Each bank supports 16 GPIO signals.

Arguments

              hGpio             Handle of the GPIO device
              bankNum           GPIO Bank Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_BINTEN_EN=0

Example

            CSL_GpioHandle  hGpio;
            Uint8           bankNum = 0;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Disable GPIO per bank interrupt for bank zero
            CSL_GPIO_bankInterruptDisable (hGpio, bankNum);
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_bankInterruptEnable | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | bankNum |
| ) |  |  |

============================================================================
CSL_GPIO_bankInterruptEnable

Description
This function enables the GPIO per bank interrupt. Each bank supports 16 GPIO signals.

Arguments

              hGpio             Handle of the GPIO device
              bankNum           GPIO Bank Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_BINTEN_EN=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           bankNum = 0;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Enable GPIO per bank interrupt for bank zero
            CSL_GPIO_bankInterruptEnable (hGpio, bankNum);
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_clearFallingEdgeDetect | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_clearFallingEdgeDetect

Description
This function clears falling edge interrupt detection for GPIO pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_CLR_FAL_TRIG_CLRFAL=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Clear falling edge interrupt detection on GPIO pin 1
            CSL_GPIO_clearFallingEdgeDetect (hGpio, pinNum));
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_clearInterruptStatus | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_clearInterruptStatus

Description
This function clears the GPIO pin interrupt status.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_INTSTAT_STAT=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Check interrupt status on pin 1
            CSL_GPIO_getInterruptStatus (hGpio, pinNum));
            ...
            // Clear interrupt status on pin 1
            CSL_GPIO_clearInterruptStatus (hGpio, pinNum));
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_clearOutputData | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_clearOutputData

Description
This function clears the output drive state of GPIO pin when it is configured as an output pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_CLR_DATA_CLR=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 0;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Clear output of GPIO pin number 0
            CSL_GPIO_clearOutputData (hGpio, pinNum);
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_clearRisingEdgeDetect | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_clearRisingEdgeDetect

Description
This function clears rising edge interrupt detection for GPIO pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_CLR_RIS_TRIG_CLRRIS=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Clear rising edge interrupt detection on GPIO pin 1
            CSL_GPIO_clearRisingEdgeDetect (hGpio, pinNum));
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_getInputData | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum,
|  | Uint8 * | inData |
| ) |  |  |

============================================================================
CSL_GPIO_getInputData

Description
This function gets the input bit data on GPIO pin when it is configured as an input pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number
              inData            Bit data when GPIO is configured as input pin

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_IN_DATA_IN

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1, inData;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Get the output data on pin 1
            CSL_GPIO_getInputData (hGpio, pinNum, &inData));
            ...

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

CSL_IDEF_INLINE Bool CSL_GPIO_getInterruptStatus | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_getInterruptStatus

Description
This function gets the GPIO pin interrupt status.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
0 - Interrupt has not occurred since last cleared
1 - Interrupt has occurred

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_INTSTAT_STAT

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Check interrupt status on pin 1
            if (CSL_GPIO_getInterruptStatus (hGpio, pinNum) == 0)
            {
                // Interrupt has not occured
            }
            else
            {
                // Interrupt has occured
            }
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_getOutputData | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum,
|  | Uint8 * | outData |
| ) |  |  |

============================================================================
CSL_GPIO_getOutputData

Description
This function gets the output drive state of GPIO pin when it is configured as an output pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number
              outData           Bit data when GPIO is configured as output pin

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_OUT_DATA_OUT

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1, outData;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Get the output data on pin 1
            CSL_GPIO_getOutputData (hGpio, pinNum, &outData));
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_getPCR | ( | CSL_GpioHandle | hGpio,
|  | Uint8 * | soft,
|  | Uint8 * | free |
| ) |  |  |

============================================================================
CSL_GPIO_getPCR

Description
This function reads the peripheral Control register which identifies the emulation mode.

Arguments

              soft          Used in conjunction with FREE bit to determine
                            the emulation suspend mode. GPIO has FREE bit set to 1
                            so SOFT bit does not affect functionality.
              free          For GPIO, the FREE bit is fixed at 1, which
                            means GPIO runs free in emulation suspend.

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_PCR_SOFT,GPIO_PCR_FREE

Example

            CSL_GpioHandle  hGpio;
            Uint8           soft, free;

            ...
            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);

            // Get the GPIO Peripheral Control register configuration.
            CSL_GPIO_getPCR (hGpio, &soft, &free);
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_getPID | ( | CSL_GpioHandle | hGpio,
|  | Uint8 * | scheme,
|  | Uint16 * | function,
|  | Uint8 * | rtl,
|  | Uint8 * | major,
|  | Uint8 * | custom,
|  | Uint8 * | minor |
| ) |  |  |

============================================================================
CSL_GPIO_getPID

Description
This function reads the peripheral ID register which identifies the scheme of PID encoding, function, rtl id, major id, custom id and minor id.

Arguments

              scheme        Scheme of PID encoding
              function      GPIO function
              rtl           RTL ID of GPIO module
              major         Major ID of GPIO module
              custom        Custom ID of GPIO module
              minor         Minor ID of GPIO module

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_PID_SCHEME,GPIO_PID_FUNC,GPIO_PID_RTL,GPIO_PID_MAJOR,GPIO_PID_CUSTOM,GPIO_PID_MINOR

Example

            CSL_GpioHandle  hGpio;
            Uint16          function;
            Uint8           scheme, rtl, major, custom, minor;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Get the GPIO Peripheral Identification.
            CSL_GPIO_getPID (hGpio, &scheme, &function, &rtl, &major, &custom, &minor);
            ...

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

CSL_IDEF_INLINE Bool CSL_GPIO_getPinDirection | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_getPinDirection

Description
This function gets the direction configuration of GPIO pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
0 - Pin is configured as output pin
1 - Pin is configured as input pin

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_DIR_DIR

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Check if pin 1 is configured as input or output pin
            if (CSL_GPIO_getPinDirection (hGpio, pinNum))
            {
                // GPIO pin is configured as INPUT
            }
            else
            {
                // GPIO pin is configured as OUTPUT
            }
            ...

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

CSL_IDEF_INLINE Bool CSL_GPIO_isBankInterruptEnabled | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | bankNum |
| ) |  |  |

============================================================================
CSL_GPIO_isBankInterruptEnabled

Description
This function returns the status of GPIO per bank interrupt. Each bank supports 16 GPIO signals.

Arguments

              hGpio             Handle of the GPIO device
              bankNum           GPIO Bank Number

Return Value
TRUE - Interrupt is enabled
FALSE - Interrupt is disabled

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_BINTEN_EN

Example

            CSL_GpioHandle  hGpio;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Check if GPIO per bank interrupt is enabled or disabled
            if (CSL_GPIO_isBankInterruptEnabled (hGpio) == TRUE)
            {
                // GPIO per bank interrupt is ENABLED
            }
            else
            {
                // GPIO per bank interrupt is DISABLED
            }
            ...

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

CSL_IDEF_INLINE Bool CSL_GPIO_isFallingEdgeDetect | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_isFallingEdgeDetect

Description
This function checks if the interrupt detection for GPIO pin is set to falling edge or not.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
TRUE - Interrupt detection is set to falling edge
FALSE - Interrupt detection is not set to falling edge

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_SET_FAL_TRIG_SETFAL

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Check interrupt detection state on GPIO pin 1
            if (CSL_GPIO_isFallingEdgeDetect (hGpio, pinNum) == TRUE)
            {
                // Interrupt detection is set to FALLING EDGE
            }
            else
            {
                // Interrupt detection is not set to FALLING EDGE
            }
            ...

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

CSL_IDEF_INLINE Bool CSL_GPIO_isRisingEdgeDetect | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_isRisingEdgeDetect

Description
This function checks if the interrupt detection for GPIO pin is set to rising edge or not.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
TRUE - Interrupt detection is set to rising edge
FALSE - Interrupt detection is not set to rising edge

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Reads
GPIO_SET_RIS_TRIG_SETRIS

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Check interrupt detection state on GPIO pin 1
            if (CSL_GPIO_isRisingEdgeDetect (hGpio, pinNum) == TRUE)
            {
                // Interrupt detection is set to RISING EDGE
            }
            else
            {
                // Interrupt detection is not set to RISING EDGE
            }
            ...

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

CSL_GpioHandle CSL_GPIO_open | ( | Int32 | instNum | ) |

============================================================================
CSL_GPIO_open

Description
This API opens the GPIO instance. This should always be the first call to the CSL GPIO Functional layer. The handle which is returned from this call should be passed in all subsequent CSL API's.

Return Value
CSL_GpioHandle - Handle to the GPIO Module
0 - Error.

Pre Condition
None

Post Condition
None

Affects
None

Example

            CSL_GpioHandle   hnd;
            ...
            hnd = CSL_GPIO_open (0);    // Opens GPIO Instance 0
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_setFallingEdgeDetect | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_setFallingEdgeDetect

Description
This function sets falling edge interrupt detection for GPIO pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_SET_FAL_TRIG_SETFAL=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Set interrupt detection on GPIO pin 1 to falling edge
            CSL_GPIO_setFallingEdgeDetect (hGpio, pinNum));
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_setOutputData | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_setOutputData

Description
This function sets the output drive state of GPIO pin when it is configured as an output pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_SET_DATA_SET=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 0;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Set output of GPIO pin number 0 to 1
            CSL_GPIO_setOutputData (hGpio, pinNum);
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_setPinDirInput | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_setPinDirInput

Description
This function sets the direction of GPIO pin as an input pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_DIR_DIR=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Set GPIO pin number 1 as an input pin
            CSL_GPIO_setPinDirInput (hGpio, pinNum);
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_setPinDirOutput | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_setPinDirOutput

Description
This function sets the direction of GPIO pin as an output pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_DIR_DIR=0

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Set GPIO pin number 1 as an output pin
            CSL_GPIO_setPinDirOutput (hGpio, pinNum);
            ...

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

CSL_IDEF_INLINE void CSL_GPIO_setRisingEdgeDetect | ( | CSL_GpioHandle | hGpio,
|  | Uint8 | pinNum |
| ) |  |  |

============================================================================
CSL_GPIO_setRisingEdgeDetect

Description
This function sets rising edge interrupt detection for GPIO pin.

Arguments

              hGpio             Handle of the GPIO device
              pinNum            GPIO Pin Number

Return Value
None

Pre Condition
CSL_GPIO_open() must be called

Post Condition
None

Writes
GPIO_SET_RIS_TRIG_SETRIS=1

Example

            CSL_GpioHandle  hGpio;
            Uint8           pinNum = 1;

            // Open the CSL GPIO Module 0
            hGpio = CSL_GPIO_open (0);
            ...
            // Set interrupt detection on GPIO pin 1 to rising edge
            CSL_GPIO_setRisingEdgeDetect (hGpio, pinNum));
            ...

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

Copyright 2012, Texas Instruments Incorporated