diff options
| author | Uri Shaked | 2020-01-11 02:58:50 +0200 |
|---|---|---|
| committer | Uri Shaked | 2020-01-11 02:58:50 +0200 |
| commit | dd18276e5ddc17fe6156e46428e34652537ba2c4 (patch) | |
| tree | a1c0cdefc018da75af62293bb2413d1b07415201 /src/gpio.ts | |
| parent | chore: release 0.5.1 (diff) | |
| download | avr8js-dd18276e5ddc17fe6156e46428e34652537ba2c4.tar.gz avr8js-dd18276e5ddc17fe6156e46428e34652537ba2c4.tar.bz2 avr8js-dd18276e5ddc17fe6156e46428e34652537ba2c4.zip | |
fix(gpio): pinState() value incorrect in GPIO listeners
fix #9
Diffstat (limited to 'src/gpio.ts')
| -rw-r--r-- | src/gpio.ts | 3 |
1 files changed, 2 insertions, 1 deletions
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 |
