all repos — mgba @ 90a3872552de56c4b98945df29feb9f826e9bbb3

mGBA Game Boy Advance Emulator

GBA: Fix GPIO being readable when set to write-only
Jeffrey Pfau jeffrey@endrift.com
Thu, 25 Dec 2014 14:49:06 -0800
commit

90a3872552de56c4b98945df29feb9f826e9bbb3

parent

f25821524d79469e3589ab23340d7e6b4ae6a27f

1 files changed, 7 insertions(+), 5 deletions(-)

jump to
M src/gba/gba-gpio.csrc/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; } }