From dd18276e5ddc17fe6156e46428e34652537ba2c4 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Sat, 11 Jan 2020 02:58:50 +0200 Subject: fix(gpio): pinState() value incorrect in GPIO listeners fix #9 --- src/gpio.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gpio.ts') diff --git a/src/gpio.ts b/src/gpio.ts index 293c559..d0df06d 100644 --- a/src/gpio.ts +++ b/src/gpio.ts @@ -96,10 +96,11 @@ export class AVRIOPort { constructor(private cpu: CPU, private portConfig: AVRPortConfig) { cpu.writeHooks[portConfig.PORT] = (value: u8, oldValue: u8) => { const ddrMask = cpu.data[portConfig.DDR]; + cpu.data[portConfig.PORT] = value; value &= ddrMask; cpu.data[portConfig.PIN] = (cpu.data[portConfig.PIN] & ~ddrMask) | value; this.writeGpio(value, oldValue & ddrMask); - // TODO: activate pullups if configured as an input pin + return true; }; cpu.writeHooks[portConfig.PIN] = (value: u8) => { // Writing to 1 PIN toggles PORT bits -- cgit v1.2.3