Other Parts Discussed in Thread: TM4C1231H6PGE
I am trying to implement effectively an open drain GPIO with the internal pull up enabled but every time I change the GPIO mode the library resets the pin state.
How do I change JUST the pin direction without the library changing other parameters of the GPIO?
I expect the below code to ultimately toggle the GPIO high/low but the "GPIODirModeSet(SPI_CSZ, GPIO_DIR_MODE_OUT);" seems to set the output state high too, not just the direction.
void TestGPIO()
{
#define SPI_CSZ GPIO_PORTA_BASE, GPIO_PIN_3
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPadConfigSet(SPI_CSZ, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPinWrite(SPI_CSZ, 0);
while(1)
{
GPIODirModeSet(SPI_CSZ, GPIO_DIR_MODE_OUT);//Set GPIO low
GPIODirModeSet(SPI_CSZ, GPIO_DIR_MODE_IN);//Let GPIO go high
}
}
It is not possible to simply add "GPIOPinWrite(SPI_CSZ, 0);" after then set mode out since if there is anything connected to the GPIO which is pulling it low then the moment between setting output mode and then setting the GPIO low will drive high, causing a contention and also a glitch on the GPIO.
How to I change the direction of a GPIO without touching anything else about the GPIO?
BR,
Steve