From 958691d82600406110b49b41b5ca11d4c4597a00 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Thu, 2 Apr 2020 13:18:05 +0300 Subject: fix: GPIO port listeners not invoked when writing to DDR registers close #28 --- src/peripherals/gpio.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/peripherals/gpio.ts') diff --git a/src/peripherals/gpio.ts b/src/peripherals/gpio.ts index a667967..35030b8 100644 --- a/src/peripherals/gpio.ts +++ b/src/peripherals/gpio.ts @@ -94,6 +94,10 @@ export class AVRIOPort { private listeners: GPIOListener[] = []; constructor(private cpu: CPU, private portConfig: AVRPortConfig) { + cpu.writeHooks[portConfig.DDR] = (value, oldValue) => { + const portValue = cpu.data[portConfig.PORT]; + this.writeGpio(value & portValue, oldValue & oldValue); + }; cpu.writeHooks[portConfig.PORT] = (value: u8, oldValue: u8) => { const ddrMask = cpu.data[portConfig.DDR]; cpu.data[portConfig.PORT] = value; -- cgit v1.2.3