GBA: Fix GPIO being readable when set to write-only
Jeffrey Pfau jeffrey@endrift.com
Thu, 25 Dec 2014 14:49:06 -0800
1 files changed,
7 insertions(+),
5 deletions(-)
jump to
M
src/gba/gba-gpio.c
→
src/gba/gba-gpio.c
@@ -50,11 +50,6 @@ switch (address) {
case GPIO_REG_DATA: gpio->pinState &= ~gpio->direction; gpio->pinState |= value; - if (gpio->readWrite) { - uint16_t old = gpio->gpioBase[0]; - old &= ~gpio->direction; - gpio->gpioBase[0] = old | gpio->pinState; - } _readPins(gpio); break; case GPIO_REG_DIRECTION:@@ -65,6 +60,13 @@ gpio->readWrite = value;
break; default: GBALog(gpio->p, GBA_LOG_WARN, "Invalid GPIO address"); + } + if (gpio->readWrite) { + uint16_t old = gpio->gpioBase[0]; + old &= ~gpio->direction; + gpio->gpioBase[0] = old | gpio->pinState; + } else { + gpio->gpioBase[0] = 0; } }