aboutsummaryrefslogtreecommitdiff
path: root/src/peripherals/gpio.ts
diff options
context:
space:
mode:
authorUri Shaked2020-04-02 13:18:05 +0300
committerUri Shaked2020-04-02 13:18:05 +0300
commit958691d82600406110b49b41b5ca11d4c4597a00 (patch)
tree20c4c670675e1e91486a52e506f65d08842041df /src/peripherals/gpio.ts
parenttest(instruction): use assembly in tests (diff)
downloadavr8js-958691d82600406110b49b41b5ca11d4c4597a00.tar.gz
avr8js-958691d82600406110b49b41b5ca11d4c4597a00.tar.bz2
avr8js-958691d82600406110b49b41b5ca11d4c4597a00.zip
fix: GPIO port listeners not invoked when writing to DDR registers
close #28
Diffstat (limited to '')
-rw-r--r--src/peripherals/gpio.ts4
1 files changed, 4 insertions, 0 deletions
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;