Using pins definitions in code
The Pins tool generates definitions of named constants that can be leveraged in the application code. Using such constants based on user-specified identifiers allows you to write code which is independent of configured routing. In the case you change the pin where the signal is routed, the application will still refer to the proper pin.
For example, when the LED_RED is specified an identifier of a pin routed to PTB22, the following defines are generated into the pin_mux.h:
#define BOARD_LED_RED_GPIO GPIOB /*!<@brief GPIO device name: GPIOB */
#define BOARD_LED_RED_PORT PORTB /*!<@brief PORT device name: PORTB *'/
#define BOARD_LED_RED_PIN 22U /*!<@brief PORTB pin index: 22 */
The name of the define is composed from function group prefix and pin identifier. For more details, see Functional groups and Labels and identifiers sections.
To write to this GPIO pin in application using the SDK driver (fsl_gpio.h), you can, for example, use the following code referring to the generated defines for the pin with identifier LED_RED:
GPIO_PinWrite(BOARD_LED_RED_GPIO, BOARD_LED_RED_PIN, true);