I've been doing some testing on the GPIO pins and found some very odd behaviour. On any micro I've used in the past, the GPIO data registers are buffered. So you can write a value to the data register, then set the data direction, and guarantee that you won't drive the wrong value to the pin momentarily. It appears that this doesn't work on the CC3200.
//configure GPIO pin as output, high, pushpull MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false); MAP_GPIODirModeSet(GPIOA1_BASE, 1 << 2, GPIO_DIR_MODE_OUT); GPIO_IF_Set(10, GPIOA1_BASE, 1<<2, 1);
works - the pin is driven high.
//configure GPIO pin as output, high, pushpull MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false); GPIO_IF_Set(10, GPIOA1_BASE, 1<<2, 1); MAP_GPIODirModeSet(GPIOA1_BASE, 1 << 2, GPIO_DIR_MODE_OUT);
Does not work. The pin is driven low. This is not good. The pin in question is a data line, that won't (gracefully) tolerate being driven low.
Then it got weirder. I added a hardware pullup to ensure that at least the pin would be high during boot, and ran the above code again. The pin did not go low when the direction was set to output.
It appears that the data register is retaining the read value! If the pin is externally pulled high when the direction is set to output, the pin will drive high. If it's pulled low, it will start driving low. If I'm correct, that's madness.
In my case, it fortunately seems to work out - the pullup holds it high, and then I want it to keep driving high. But I can imagine a whole range of scenarios where the pin is floating or unknown, but absolutely must not be driven to a random value. Please tell me I'm wrong.