From db422fab7e38e769a164a67221634c9bfc77ee60 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Fri, 29 May 2020 11:23:49 +0300 Subject: fix(gpio): port state not updated on DDR write Calling `pinState()` inside a GPIO port listener returns incorrect values after changing DDR close #47 --- src/peripherals/gpio.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/peripherals/gpio.ts') diff --git a/src/peripherals/gpio.ts b/src/peripherals/gpio.ts index cb21669..e0861d7 100644 --- a/src/peripherals/gpio.ts +++ b/src/peripherals/gpio.ts @@ -110,8 +110,10 @@ export class AVRIOPort { constructor(private cpu: CPU, private portConfig: AVRPortConfig) { cpu.writeHooks[portConfig.DDR] = (value: u8) => { const portValue = cpu.data[portConfig.PORT]; + cpu.data[portConfig.DDR] = value; this.updatePinRegister(portValue, value); this.writeGpio(portValue, value); + return true; }; cpu.writeHooks[portConfig.PORT] = (value: u8) => { const ddrMask = cpu.data[portConfig.DDR]; -- cgit v1.2.3