MSP432E4 DriverLib API Guide  1.11.00.03
Programming Example

The following example shows how to use the GPIO API to initialize the GPIO, enable interrupts, read data from pins, and write data to pins.

Example: Configure pins for use as input, interrupt, and output GPIOs.

int32_t i32Val;
//
// Enable the GPIOA peripheral
//
//
// Wait for the GPIOA module to be ready.
//
{
}
//
// Register the port-level interrupt handler. This handler is the first
// level interrupt handler for all the pin interrupts.
//
GPIOIntRegister(GPIO_PORTA_BASE, PortAIntHandler);
//
// Initialize the GPIO pin configuration.
//
// Set pins 2, 4, and 5 as input, SW controlled.
//
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,
//
// Set pins 0 and 3 as output, SW controlled.
//
//
// Make pins 2 and 4 rising edge triggered interrupts.
//
//
// Make pin 5 high level triggered interrupts.
//
//
// Read some pins.
//
i32Val = GPIOPinRead(GPIO_PORTA_BASE,
//
// Write some pins. Even though pins 2, 4, and 5 are specified, those pins
// are unaffected by this write because they are configured as inputs. At
// the end of this write, pin 0 is low, and pin 3 is high.
//
GPIOPinWrite(GPIO_PORTA_BASE,
//
// Enable the pin interrupts.
//

Example: Configure Port B Pins for use as a UART 1.

//
// Enable the GPIOB peripheral
//
//
// Wait for the GPIOB module to be ready.
//
{
}
//
// Configure GPIO Port B pins 0 and 1 to be used as UART1.
//
//
// Enable UART1 functionality on GPIO Port B pins 0 and 1.
//
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale