I know it is possible, but I haven't found the documentation referring to it.
How can we determine the Peripheral uint32 value of a GPIO port, given the port base?
Briefly, I'd like to make a small GPIO config function, which can be simplified for this example to the following code:
void SystemUtilitiesGPIOSetAsOutput(BASE, PIN)
{
// First, determine PERIPH from BASE/PIN information (not done here)
if (!(SysCtlPeripheralReady(PERIPH)))
{
SysCtlPeripheralDisable(PERIPH);
SysCtlPeripheralReset(PERIPH);
SysCtlPeripheralEnable(PERIPH);
while(!SysCtlPeripheralReady(PERIPH));
}
GPIOPinTypeGPIOOutput(BASE, PIN);
}
Just for clarity, what I refer to PERIPH here are the likes of SYSCTL_PERIPH_GPIOA.
It just seems ugly to force the application to pass the peripheral parameter, as it can certainly be "created" by the fact that we know it is a GPIO port, and we know the port address (of course, by looking up proper Tivaware included files)
I posted something similar in the past, on the thread below. While Veikko Immonen came up with an interesting suggestion, it is still not exactly what I was looking for - not would it apply to GPIO's, only to alternative peripheral mux settings.
https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/580747
Regards
Bruno
