'TM4C123G launchpad: How to modify one pin (e.g. PE1) without knowing its GPIO and its position in the byte

Please allow me to clarify the title: I'm writing a function to connect 16x2 LCD pins to TM4C123G pins. Users should be able to select any TM4C123G pin they want. As the function writer, I need the user to pass the information of that pin to me so that I can connect the pins.

Now I know there are two ways to modify a pin:

Method 1: Reference the full register and AND/OR with a certain value:

// Want to set PE1 to high
#define GPIO_PORTE_DATA_R       (*((volatile unsigned long *)0x400243FC))
GPIO_PORTE_DATA_R |= 0x02;

Method 2: Use bit-specific addressing and reference PE1:

// Want to set PE1 to high
#define PE1       (*((volatile unsigned long *)0x40024008))
PE1 = 0x02;

Now consider the function I need to write: the user has to pass two pieces of information to it -- 1) Which GPIO is used (Port E), and 2) Which bit is used (PE1 the second bit from low end).

My question: Is there a way for the user to just pass me a memory address and I can simply set it to 0x01 for high and 0x00 for low?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source