diff options
| author | Uri Shaked | 2020-05-29 11:23:49 +0300 |
|---|---|---|
| committer | Uri Shaked | 2020-05-29 11:23:49 +0300 |
| commit | db422fab7e38e769a164a67221634c9bfc77ee60 (patch) | |
| tree | f9bfb488e58d95e46d99d149df8505d358867bc7 /src/peripherals/gpio.ts | |
| parent | chore(deps): @wokwi/elements 0.16.1 (diff) | |
| download | avr8js-db422fab7e38e769a164a67221634c9bfc77ee60.tar.gz avr8js-db422fab7e38e769a164a67221634c9bfc77ee60.tar.bz2 avr8js-db422fab7e38e769a164a67221634c9bfc77ee60.zip | |
fix(gpio): port state not updated on DDR write
Calling `pinState()` inside a GPIO port listener returns incorrect values after changing DDR
close #47
Diffstat (limited to 'src/peripherals/gpio.ts')
| -rw-r--r-- | src/peripherals/gpio.ts | 2 |
1 files changed, 2 insertions, 0 deletions
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]; |
