Macros | Functions
GPIO

General Purpose Input/Output to control port settings. More...

Macros

#define GPIO_PORT_P1   1
 
#define GPIO_PORT_P2   2
 
#define GPIO_PORT_P3   3
 
#define GPIO_PORT_P4   4
 
#define GPIO_PORT_P5   5
 
#define GPIO_PORT_P6   6
 
#define GPIO_PORT_P7   7
 
#define GPIO_PORT_P8   8
 
#define GPIO_PORT_P9   9
 
#define GPIO_PORT_P10   10
 
#define GPIO_PORT_PA   1
 
#define GPIO_PORT_PB   3
 
#define GPIO_PORT_PC   5
 
#define GPIO_PORT_PD   7
 
#define GPIO_PORT_PE   9
 
#define GPIO_PORT_PJ   11
 
#define GPIO_PIN0   (0x0001)
 
#define GPIO_PIN1   (0x0002)
 
#define GPIO_PIN2   (0x0004)
 
#define GPIO_PIN3   (0x0008)
 
#define GPIO_PIN4   (0x0010)
 
#define GPIO_PIN5   (0x0020)
 
#define GPIO_PIN6   (0x0040)
 
#define GPIO_PIN7   (0x0080)
 
#define GPIO_PIN8   (0x0100)
 
#define GPIO_PIN9   (0x0200)
 
#define GPIO_PIN10   (0x0400)
 
#define GPIO_PIN11   (0x0800)
 
#define GPIO_PIN12   (0x1000)
 
#define GPIO_PIN13   (0x2000)
 
#define GPIO_PIN14   (0x4000)
 
#define GPIO_PIN15   (0x8000)
 
#define PIN_ALL8   (0xFF)
 
#define PIN_ALL16   (0xFFFF)
 
#define GPIO_PRIMARY_MODULE_FUNCTION   (0x01)
 
#define GPIO_SECONDARY_MODULE_FUNCTION   (0x02)
 
#define GPIO_TERTIARY_MODULE_FUNCTION   (0x03)
 
#define GPIO_HIGH_TO_LOW_TRANSITION   (0x01)
 
#define GPIO_LOW_TO_HIGH_TRANSITION   (0x00)
 
#define GPIO_INPUT_PIN_HIGH   (0x01)
 
#define GPIO_INPUT_PIN_LOW   (0x00)
 
#define OFS_LIB_PAIN   ((uint32_t)&P1->IN - (uint32_t)P1)
 
#define OFS_LIB_PAOUT   ((uint32_t)&P1->OUT - (uint32_t)P1)
 
#define OFS_LIB_PADIR   ((uint32_t)&P1->DIR - (uint32_t)P1)
 
#define OFS_LIB_PAREN   ((uint32_t)&P1->REN - (uint32_t)P1)
 
#define OFS_LIB_PADS   ((uint32_t)&P1->DS - (uint32_t)P1)
 
#define OFS_LIB_PASEL0   ((uint32_t)&P1->SEL0 - (uint32_t)P1)
 
#define OFS_LIB_PASEL1   ((uint32_t)&P1->SEL1 - (uint32_t)P1)
 
#define OFS_LIB_PAIE   ((uint32_t)&P1->IE - (uint32_t)P1)
 
#define OFS_LIB_PAIES   ((uint32_t)&P1->IES - (uint32_t)P1)
 
#define OFS_LIB_PAIFG   ((uint32_t)&P1->IFG - (uint32_t)P1)
 
#define OFS_LIB_P1IE   ((uint32_t)&P1->IE - (uint32_t)P1)
 
#define OFS_LIB_P2IE   OFS_LIB_P1IE
 
#define GPIO_selectInterruptEdge   GPIO_interruptEdgeSelect
 
#define GPIO_clearInterrupt   GPIO_clearInterruptFlag
 

Functions

void GPIO_setAsOutputPin (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function configures the selected Pin as output pin. More...
 
void GPIO_setAsInputPin (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function configures the selected Pin as input pin. More...
 
void GPIO_setAsPeripheralModuleFunctionOutputPin (uint_fast8_t selectedPort, uint_fast16_t selectedPins, uint_fast8_t mode)
 This function configures the peripheral module function in the output direction for the selected pin for either primary, secondary or ternary module function modes. More...
 
void GPIO_setAsPeripheralModuleFunctionInputPin (uint_fast8_t selectedPort, uint_fast16_t selectedPins, uint_fast8_t mode)
 This function configures the peripheral module function in the input direction for the selected pin for either primary, secondary or ternary module function modes. More...
 
void GPIO_setOutputHighOnPin (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function sets output HIGH on the selected Pin. More...
 
void GPIO_setOutputLowOnPin (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function sets output LOW on the selected Pin. More...
 
void GPIO_toggleOutputOnPin (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function toggles the output on the selected Pin. More...
 
void GPIO_setAsInputPinWithPullDownResistor (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function sets the selected Pin in input Mode with Pull Down resistor. More...
 
void GPIO_setAsInputPinWithPullUpResistor (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function sets the selected Pin in input Mode with Pull Up resistor. More...
 
uint8_t GPIO_getInputPinValue (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function gets the input value on the selected pin. More...
 
void GPIO_enableInterrupt (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function enables the port interrupt on the selected pin. More...
 
void GPIO_disableInterrupt (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function disables the port interrupt on the selected pin. More...
 
uint_fast16_t GPIO_getInterruptStatus (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function gets the interrupt status of the selected pin. More...
 
void GPIO_clearInterruptFlag (uint_fast8_t selectedPort, uint_fast16_t selectedPins)
 This function clears the interrupt flag on the selected pin. More...
 
void GPIO_interruptEdgeSelect (uint_fast8_t selectedPort, uint_fast16_t selectedPins, uint_fast8_t edgeSelect)
 This function selects on what edge the port interrupt flag should be set for a transition. More...
 
uint_fast16_t GPIO_getEnabledInterruptStatus (uint_fast8_t selectedPort)
 This function gets the interrupt status of the provided PIN and masks it with the interrupts that are actually enabled. This is useful for inside ISRs where the status of only the enabled interrupts needs to be checked. More...
 
void GPIO_registerInterrupt (uint_fast8_t selectedPort, void(*intHandler)(void))
 
void GPIO_unregisterInterrupt (uint_fast8_t selectedPort)
 
void GPIO_setDriveStrengthHigh (uint_fast8_t selectedPort, uint_fast8_t selectedPins)
 
void GPIO_setDriveStrengthLow (uint_fast8_t selectedPort, uint_fast8_t selectedPins)
 

Detailed Description

General Purpose Input/Output to control port settings.


Module Operation


The Digital I/O (GPIO) API provides a set of functions for using the SDK L GPIO modules. Functions are provided to setup and enable use of input/output pins, setting them up with or without interrupts and those that access the pin value.


Key Features


The digital I/O features include:

Devices within the family may have up to twelve digital I/O ports implemented (P1 to P11 and PJ). Most ports contain eight I/O lines; however, some ports may contain less (see the device-specific data sheet for ports available). Each I/O line is individually configurable for input or output direction, and each can be individually read or written. Each I/O line is individually configurable for pullup or pulldown resistors. PJ contains only four I/O lines.

Individual ports can be accessed as byte-wide ports or can be combined into word-wide ports and accessed via word formats. Port pairs P1/P2, P3/P4, P5/P6, P7/P8, etc., are associated with the names PA, PB, PC, PD, etc., respectively. All port registers are handled in this manner with this naming convention.

When writing to port PA with word operations, all 16 bits are written to the port. When writing to the lower byte of the PA port using byte operations, the upper byte remains unchanged. Similarly, writing to the upper byte of the PA port using byte instructions leaves the lower byte unchanged. When writing to a port that contains less than the maximum number of bits possible, the unused bits are a "don't care". Ports PB, PC, PD, PE, and PF behave similarly.

Reading of the PA port using word operations causes all 16 bits to be transferred to the destination. Reading the lower or upper byte of the PA port (P1 or P2) and storing to memory using byte operations causes only the lower or upper byte to be transferred to the destination, respectively. Reading of the PA port and storing to a general-purpose register using byte operations causes the byte transferred to be written to the least significant byte of the register. The upper significant byte of the destination register is cleared automatically. Ports PB, PC, PD, PE, and PF behave similarly. When reading from ports that contain less than the maximum bits possible, unused bits are read as zeros (similarly for port PJ).

The GPIO pin may be configured as an I/O pin with GPIO_setAsOutputPin, GPIO_setAsInputPin, GPIO_setAsInputPinWithPullDownResistor or GPIO_setAsInputPinWithPullUpResistor . The GPIO pin may instead be configured to operate in the Peripheral Module assigned function by configuring the GPIO using GPIO_setAsPeripheralModuleFunctionOutputPin or GPIO_setAsPeripheralModuleFunctionInputPin.


Programming Example


The DriverLib package contains a variety of different code examples that demonstrate the usage of the GPIO module. These code examples are accessible under the examples/ folder of the SDK release as well as through TI Resource Explorer if using Code Composer Studio. These code examples provide a comprehensive list of use cases as well as practical applications involving each module.

Below is a simple example of how to set up a GPIO in output mode and toggle an LED using a simple delay:

Macro Definition Documentation

#define GPIO_PORT_P1   1
#define GPIO_PORT_P2   2
#define GPIO_PORT_P3   3
#define GPIO_PORT_P4   4
#define GPIO_PORT_P5   5
#define GPIO_PORT_P6   6
#define GPIO_PORT_P7   7
#define GPIO_PORT_P8   8
#define GPIO_PORT_P9   9
#define GPIO_PORT_P10   10
#define GPIO_PORT_PA   1
#define GPIO_PORT_PB   3
#define GPIO_PORT_PC   5
#define GPIO_PORT_PD   7
#define GPIO_PORT_PE   9
#define GPIO_PORT_PJ   11
#define GPIO_PIN0   (0x0001)
#define GPIO_PIN1   (0x0002)
#define GPIO_PIN2   (0x0004)
#define GPIO_PIN3   (0x0008)
#define GPIO_PIN4   (0x0010)
#define GPIO_PIN5   (0x0020)
#define GPIO_PIN6   (0x0040)
#define GPIO_PIN7   (0x0080)
#define GPIO_PIN8   (0x0100)
#define GPIO_PIN9   (0x0200)
#define GPIO_PIN10   (0x0400)
#define GPIO_PIN11   (0x0800)
#define GPIO_PIN12   (0x1000)
#define GPIO_PIN13   (0x2000)
#define GPIO_PIN14   (0x4000)
#define GPIO_PIN15   (0x8000)
#define PIN_ALL8   (0xFF)
#define PIN_ALL16   (0xFFFF)
#define GPIO_PRIMARY_MODULE_FUNCTION   (0x01)
#define GPIO_SECONDARY_MODULE_FUNCTION   (0x02)
#define GPIO_TERTIARY_MODULE_FUNCTION   (0x03)
#define GPIO_HIGH_TO_LOW_TRANSITION   (0x01)
#define GPIO_LOW_TO_HIGH_TRANSITION   (0x00)
#define GPIO_INPUT_PIN_HIGH   (0x01)

Referenced by GPIO_getInputPinValue().

#define GPIO_INPUT_PIN_LOW   (0x00)

Referenced by GPIO_getInputPinValue().

#define OFS_LIB_PAIN   ((uint32_t)&P1->IN - (uint32_t)P1)

Referenced by GPIO_getInputPinValue().

#define OFS_LIB_PAOUT   ((uint32_t)&P1->OUT - (uint32_t)P1)
#define OFS_LIB_PADIR   ((uint32_t)&P1->DIR - (uint32_t)P1)
#define OFS_LIB_PAREN   ((uint32_t)&P1->REN - (uint32_t)P1)
#define OFS_LIB_PADS   ((uint32_t)&P1->DS - (uint32_t)P1)
#define OFS_LIB_PASEL0   ((uint32_t)&P1->SEL0 - (uint32_t)P1)
#define OFS_LIB_PASEL1   ((uint32_t)&P1->SEL1 - (uint32_t)P1)
#define OFS_LIB_PAIE   ((uint32_t)&P1->IE - (uint32_t)P1)
#define OFS_LIB_PAIES   ((uint32_t)&P1->IES - (uint32_t)P1)
#define OFS_LIB_PAIFG   ((uint32_t)&P1->IFG - (uint32_t)P1)
#define OFS_LIB_P1IE   ((uint32_t)&P1->IE - (uint32_t)P1)
#define OFS_LIB_P2IE   OFS_LIB_P1IE
#define GPIO_selectInterruptEdge   GPIO_interruptEdgeSelect
#define GPIO_clearInterrupt   GPIO_clearInterruptFlag

Function Documentation

void GPIO_setAsOutputPin ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function configures the selected Pin as output pin.

This function selected pins on a selected port as output pins.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxDIR register and bits of PxSEL register.

Returns
None

References HWREG16, OFS_LIB_PADIR, OFS_LIB_PASEL0, and OFS_LIB_PASEL1.

void GPIO_setAsInputPin ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function configures the selected Pin as input pin.

This function selected pins on a selected port as input pins.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxDIR register, bits of PxREN register and bits of PxSEL register.

Returns
None

References HWREG16, OFS_LIB_PADIR, OFS_LIB_PAREN, OFS_LIB_PASEL0, and OFS_LIB_PASEL1.

void GPIO_setAsPeripheralModuleFunctionOutputPin ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins,
uint_fast8_t  mode 
)

This function configures the peripheral module function in the output direction for the selected pin for either primary, secondary or ternary module function modes.

This function configures the peripheral module function in the output direction for the selected pin for either primary, secondary or ternary module function modes. Accepted values for mode are GPIO_PRIMARY_MODULE_FUNCTION, GPIO_SECONDARY_MODULE_FUNCTION, and GPIO_TERTIARY_MODULE_FUNCTION

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15
modeis the specified mode that the pin should be configured for the module function. Valid values are:
  • GPIO_PRIMARY_MODULE_FUNCTION
  • GPIO_SECONDARY_MODULE_FUNCTION
  • GPIO_TERTIARY_MODULE_FUNCTION

Modified bits of PxDIR register and bits of PxSEL register.

Returns
None

References GPIO_PRIMARY_MODULE_FUNCTION, GPIO_SECONDARY_MODULE_FUNCTION, GPIO_TERTIARY_MODULE_FUNCTION, HWREG16, OFS_LIB_PADIR, OFS_LIB_PASEL0, and OFS_LIB_PASEL1.

void GPIO_setAsPeripheralModuleFunctionInputPin ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins,
uint_fast8_t  mode 
)

This function configures the peripheral module function in the input direction for the selected pin for either primary, secondary or ternary module function modes.

This function configures the peripheral module function in the input direction for the selected pin for either primary, secondary or ternary module function modes. Accepted values for mode are GPIO_PRIMARY_MODULE_FUNCTION, GPIO_SECONDARY_MODULE_FUNCTION, and GPIO_TERTIARY_MODULE_FUNCTION

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15
modeis the specified mode that the pin should be configured for the module function. Valid values are:
  • GPIO_PRIMARY_MODULE_FUNCTION
  • GPIO_SECONDARY_MODULE_FUNCTION
  • GPIO_TERTIARY_MODULE_FUNCTION

Modified bits of PxDIR register and bits of PxSEL register.

Returns
None

References GPIO_PRIMARY_MODULE_FUNCTION, GPIO_SECONDARY_MODULE_FUNCTION, GPIO_TERTIARY_MODULE_FUNCTION, HWREG16, OFS_LIB_PADIR, OFS_LIB_PASEL0, and OFS_LIB_PASEL1.

void GPIO_setOutputHighOnPin ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function sets output HIGH on the selected Pin.

This function sets output HIGH on the selected port's pin.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxOUT register.

Returns
None

References HWREG16, and OFS_LIB_PAOUT.

void GPIO_setOutputLowOnPin ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function sets output LOW on the selected Pin.

This function sets output LOW on the selected port's pin.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15
Returns
None

References HWREG16, and OFS_LIB_PAOUT.

void GPIO_toggleOutputOnPin ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function toggles the output on the selected Pin.

This function toggles the output on the selected port's pin.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxOUT register.

Returns
None

References HWREG16, and OFS_LIB_PAOUT.

void GPIO_setAsInputPinWithPullDownResistor ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function sets the selected Pin in input Mode with Pull Down resistor.

This function sets the selected Pin in input Mode with Pull Down resistor.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxDIR register, bits of PxOUT register and bits of PxREN register.

Returns
None

References HWREG16, OFS_LIB_PADIR, OFS_LIB_PAOUT, OFS_LIB_PAREN, OFS_LIB_PASEL0, and OFS_LIB_PASEL1.

void GPIO_setAsInputPinWithPullUpResistor ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function sets the selected Pin in input Mode with Pull Up resistor.

This function sets the selected Pin in input Mode with Pull Up resistor.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxDIR register, bits of PxOUT register and bits of PxREN register.

Returns
None

References HWREG16, OFS_LIB_PADIR, OFS_LIB_PAOUT, OFS_LIB_PAREN, OFS_LIB_PASEL0, and OFS_LIB_PASEL1.

uint8_t GPIO_getInputPinValue ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function gets the input value on the selected pin.

This function gets the input value on the selected pin.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Valid values are:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15
Returns
One of the following:
  • GPIO_INPUT_PIN_HIGH
  • GPIO_INPUT_PIN_LOW
    indicating the status of the pin

References GPIO_INPUT_PIN_HIGH, GPIO_INPUT_PIN_LOW, HWREG16, and OFS_LIB_PAIN.

void GPIO_enableInterrupt ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function enables the port interrupt on the selected pin.

This function enables the port interrupt on the selected pin. Note that only Port 1,2, A have this capability.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_PA
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxIE register.

Returns
None

References HWREG16, and OFS_LIB_PAIE.

void GPIO_disableInterrupt ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function disables the port interrupt on the selected pin.

This function disables the port interrupt on the selected pin. Note that only Port 1,2, A have this capability.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_PA
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxIE register.

Returns
None

References HWREG16, and OFS_LIB_PAIE.

uint_fast16_t GPIO_getInterruptStatus ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function gets the interrupt status of the selected pin.

This function gets the interrupt status of the selected pin.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_PA
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15
Returns
Logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15
    indicating the interrupt status of the selected pins [Default: 0]

References HWREG16, and OFS_LIB_PAIFG.

Referenced by GPIO_getEnabledInterruptStatus().

void GPIO_clearInterruptFlag ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins 
)

This function clears the interrupt flag on the selected pin.

This function clears the interrupt flag on the selected pin.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_PA
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15

Modified bits of PxIFG register.

Returns
None

References HWREG16, and OFS_LIB_PAIFG.

void GPIO_interruptEdgeSelect ( uint_fast8_t  selectedPort,
uint_fast16_t  selectedPins,
uint_fast8_t  edgeSelect 
)

This function selects on what edge the port interrupt flag should be set for a transition.

This function selects on what edge the port interrupt flag should be set for a transition. Values for edgeSelect should be GPIO_LOW_TO_HIGH_TRANSITION or GPIO_HIGH_TO_LOW_TRANSITION.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Mask value is the logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15
edgeSelectspecifies what transition sets the interrupt flag Valid values are:
  • GPIO_HIGH_TO_LOW_TRANSITION
  • GPIO_LOW_TO_HIGH_TRANSITION

Modified bits of PxIES register.

Returns
None

References GPIO_LOW_TO_HIGH_TRANSITION, HWREG16, and OFS_LIB_PAIES.

uint_fast16_t GPIO_getEnabledInterruptStatus ( uint_fast8_t  selectedPort)

This function gets the interrupt status of the provided PIN and masks it with the interrupts that are actually enabled. This is useful for inside ISRs where the status of only the enabled interrupts needs to be checked.

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1
  • GPIO_PORT_P2
  • GPIO_PORT_P3
  • GPIO_PORT_P4
  • GPIO_PORT_P5
  • GPIO_PORT_P6
  • GPIO_PORT_P7
  • GPIO_PORT_P8
  • GPIO_PORT_P9
  • GPIO_PORT_P10
  • GPIO_PORT_P11
  • GPIO_PORT_PJ
Returns
Logical OR of any of the following:
  • GPIO_PIN0
  • GPIO_PIN1
  • GPIO_PIN2
  • GPIO_PIN3
  • GPIO_PIN4
  • GPIO_PIN5
  • GPIO_PIN6
  • GPIO_PIN7
  • GPIO_PIN8
  • GPIO_PIN9
  • GPIO_PIN10
  • GPIO_PIN11
  • GPIO_PIN12
  • GPIO_PIN13
  • GPIO_PIN14
  • GPIO_PIN15,
  • PIN_ALL8,
  • PIN_ALL16
    indicating the interrupt status of the selected pins [Default: 0]

References ASSERT, GPIO_getInterruptStatus(), GPIO_PORT_P1, GPIO_PORT_P10, GPIO_PORT_P2, GPIO_PORT_P3, GPIO_PORT_P4, GPIO_PORT_P5, GPIO_PORT_P6, GPIO_PORT_P7, GPIO_PORT_P8, GPIO_PORT_P9, GPIO_PORT_PJ, HWREG16, HWREG8, OFS_LIB_P1IE, OFS_LIB_P2IE, and OFS_LIB_PAIE.

void GPIO_registerInterrupt ( uint_fast8_t  selectedPort,
void(*)(void)  intHandler 
)

Registers an interrupt handler for the port interrupt.

Parameters
selectedPortis the port to register the interrupt handler
intHandleris a pointer to the function to be called when the port interrupt occurs.

This function registers the handler to be called when a port interrupt occurs. This function enables the global interrupt in the interrupt controller; specific GPIO interrupts must be enabled via GPIO_enableInterrupt(). It is the interrupt handler's responsibility to clear the interrupt source via GPIO_clearInterruptFlag().

Clock System can generate interrupts when

See Also
Interrupt_registerInterrupt() for important information about registering interrupt handlers.
Returns
None.

References Interrupt_enableInterrupt(), and Interrupt_registerInterrupt().

void GPIO_unregisterInterrupt ( uint_fast8_t  selectedPort)

Unregisters the interrupt handler for the port.

Parameters
selectedPortis the port to unregister the interrupt handler

This function unregisters the handler to be called when a port interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

See Also
Interrupt_registerInterrupt() for important information about registering interrupt handlers.
Returns
None.

References Interrupt_disableInterrupt(), and Interrupt_unregisterInterrupt().

void GPIO_setDriveStrengthHigh ( uint_fast8_t  selectedPort,
uint_fast8_t  selectedPins 
)

This function sets the drive strength to high for the selected port

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1,
  • GPIO_PORT_P2,
  • GPIO_PORT_P3,
  • GPIO_PORT_P4,
  • GPIO_PORT_P5,
  • GPIO_PORT_P6,
  • GPIO_PORT_P7,
  • GPIO_PORT_P8,
  • GPIO_PORT_P9,
  • GPIO_PORT_P10,
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Valid values are:
  • GPIO_PIN0,
  • GPIO_PIN1,
  • GPIO_PIN2,
  • GPIO_PIN3,
  • GPIO_PIN4,
  • GPIO_PIN5,
  • GPIO_PIN6,
  • GPIO_PIN7,
  • GPIO_PIN8,
  • PIN_ALL8,
Returns
None

References HWREG8, and OFS_LIB_PADS.

void GPIO_setDriveStrengthLow ( uint_fast8_t  selectedPort,
uint_fast8_t  selectedPins 
)

This function sets the drive strength to low for the selected port

Parameters
selectedPortis the selected port. Valid values are:
  • GPIO_PORT_P1,
  • GPIO_PORT_P2,
  • GPIO_PORT_P3,
  • GPIO_PORT_P4,
  • GPIO_PORT_P5,
  • GPIO_PORT_P6,
  • GPIO_PORT_P7,
  • GPIO_PORT_P8,
  • GPIO_PORT_P9,
  • GPIO_PORT_P10,
  • GPIO_PORT_PJ
selectedPinsis the specified pin in the selected port. Valid values are:
  • GPIO_PIN0,
  • GPIO_PIN1,
  • GPIO_PIN2,
  • GPIO_PIN3,
  • GPIO_PIN4,
  • GPIO_PIN5,
  • GPIO_PIN6,
  • GPIO_PIN7,
  • GPIO_PIN8,
  • PIN_ALL8,
Returns
None

References HWREG8, and OFS_LIB_PADS.


Copyright 2018, Texas Instruments Incorporated