MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the FGPIO driver. The FGPIO driver configures the FGPIO module and provides a functional interface to build the GPIO application.

Note
FGPIO (Fast GPIO) is only available in a few MCUs. FGPIO and GPIO share the same peripheral but use different registers. FGPIO is closer to the core than the regular GPIO and it's faster to read and write.

Typical use case

Output Operation

/* Output pin configuration */
gpio_pin_config_t led_config =
{
kGpioDigitalOutput,
1,
};
/* Sets the configuration */
FGPIO_PinInit(FGPIO_LED, LED_PINNUM, &led_config);

Input Operation

/* Input pin configuration */
PORT_SetPinInterruptConfig(BOARD_SW2_PORT, BOARD_SW2_FGPIO_PIN, kPORT_InterruptFallingEdge);
NVIC_EnableIRQ(BOARD_SW2_IRQ);
gpio_pin_config_t sw1_config =
{
kGpioDigitalInput,
0,
};
/* Sets the input pin configuration */
FGPIO_PinInit(FGPIO_SW1, SW1_PINNUM, &sw1_config);

FGPIO Configuration

void FGPIO_PinInit (FGPIO_Type *base, uint32_t pin, const gpio_pin_config_t *config)
 Initializes a FGPIO pin used by the board. More...
 

FGPIO Output Operations

static void FGPIO_WritePinOutput (FGPIO_Type *base, uint32_t pin, uint8_t output)
 Sets the output level of the multiple FGPIO pins to the logic 1 or 0. More...
 
static void FGPIO_SetPinsOutput (FGPIO_Type *base, uint32_t mask)
 Sets the output level of the multiple FGPIO pins to the logic 1. More...
 
static void FGPIO_ClearPinsOutput (FGPIO_Type *base, uint32_t mask)
 Sets the output level of the multiple FGPIO pins to the logic 0. More...
 
static void FGPIO_TogglePinsOutput (FGPIO_Type *base, uint32_t mask)
 Reverses the current output logic of the multiple FGPIO pins. More...
 

FGPIO Input Operations

static uint32_t FGPIO_ReadPinInput (FGPIO_Type *base, uint32_t pin)
 Reads the current input value of the FGPIO port. More...
 

FGPIO Interrupt

uint32_t FGPIO_GetPinsInterruptFlags (FGPIO_Type *base)
 Reads the FGPIO port interrupt status flag. More...
 
void FGPIO_ClearPinsInterruptFlags (FGPIO_Type *base, uint32_t mask)
 Clears the multiple FGPIO pin interrupt status flag. More...
 

Function Documentation

void FGPIO_PinInit ( FGPIO_Type *  base,
uint32_t  pin,
const gpio_pin_config_t config 
)

To initialize the FGPIO driver, define a pin configuration, as either input or output, in the user file. Then, call the FGPIO_PinInit() function.

This is an example to define an input pin or an output pin configuration:

* // Define a digital input pin configuration,
* {
* 0,
* }
* //Define a digital output pin configuration,
* {
* 0,
* }
*
Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
pinFGPIO port pin number
configFGPIO pin configuration pointer
static void FGPIO_WritePinOutput ( FGPIO_Type *  base,
uint32_t  pin,
uint8_t  output 
)
inlinestatic
Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
pinFGPIO pin number
outputFGPIOpin output logic level.
  • 0: corresponding pin output low-logic level.
  • 1: corresponding pin output high-logic level.
static void FGPIO_SetPinsOutput ( FGPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
maskFGPIO pin number macro
static void FGPIO_ClearPinsOutput ( FGPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
maskFGPIO pin number macro
static void FGPIO_TogglePinsOutput ( FGPIO_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
maskFGPIO pin number macro
static uint32_t FGPIO_ReadPinInput ( FGPIO_Type *  base,
uint32_t  pin 
)
inlinestatic
Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
pinFGPIO pin number
Return values
FGPIOport input value
  • 0: corresponding pin input low-logic level.
  • 1: corresponding pin input high-logic level.
uint32_t FGPIO_GetPinsInterruptFlags ( FGPIO_Type *  base)

If a pin is configured to generate the DMA request, the corresponding flag is cleared automatically at the completion of the requested DMA transfer. Otherwise, the flag remains set until a logic one is written to that flag. If configured for a level-sensitive interrupt that remains asserted, the flag is set again immediately.

Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
Return values
Thecurrent FGPIO port interrupt status flags, for example, 0x00010001 means the pin 0 and 17 have the interrupt.
void FGPIO_ClearPinsInterruptFlags ( FGPIO_Type *  base,
uint32_t  mask 
)
Parameters
baseFGPIO peripheral base pointer (FGPIOA, FGPIOB, FGPIOC, and so on.)
maskFGPIO pin number macro