aboutsummaryrefslogtreecommitdiff
path: root/src/peripherals/gpio.spec.ts
diff options
context:
space:
mode:
authorUri Shaked2021-08-13 20:25:03 +0300
committerUri Shaked2021-08-13 20:25:03 +0300
commitd98b8fe7bcf77c0686749b57242901f41a4a1ac2 (patch)
tree85e965ccff2a2f09b34122e5e6eb8740b2986010 /src/peripherals/gpio.spec.ts
parentMerge pull request #100 from wokwi/dependabot/npm_and_yarn/path-parse-1.0.7 (diff)
downloadavr8js-d98b8fe7bcf77c0686749b57242901f41a4a1ac2.tar.gz
avr8js-d98b8fe7bcf77c0686749b57242901f41a4a1ac2.tar.bz2
avr8js-d98b8fe7bcf77c0686749b57242901f41a4a1ac2.zip
fix(gpio): timer outputs not reflected in PIN register #102
fix #102
Diffstat (limited to 'src/peripherals/gpio.spec.ts')
-rw-r--r--src/peripherals/gpio.spec.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/peripherals/gpio.spec.ts b/src/peripherals/gpio.spec.ts
index 692deaa..31963a9 100644
--- a/src/peripherals/gpio.spec.ts
+++ b/src/peripherals/gpio.spec.ts
@@ -1,5 +1,5 @@
import { CPU } from '../cpu/cpu';
-import { AVRIOPort, portBConfig, PinState, portDConfig } from './gpio';
+import { AVRIOPort, portBConfig, PinState, portDConfig, PinOverrideMode } from './gpio';
// CPU registers
const SREG = 95;
@@ -76,6 +76,18 @@ describe('GPIO', () => {
expect(cpu.data[PINB]).toEqual(0x4); // PINB should return port value
});
+ it('should update the PIN register on output compare (OCR) match (issue #102)', () => {
+ const cpu = new CPU(new Uint16Array(1024));
+ const port = new AVRIOPort(cpu, portBConfig);
+ cpu.writeData(DDRB, 1 << 1);
+ cpu.gpioTimerHooks[PORTB](1, PinOverrideMode.Set, PORTB);
+ expect(port.pinState(1)).toBe(PinState.High);
+ expect(cpu.data[PINB]).toBe(1 << 1);
+ cpu.gpioTimerHooks[PORTB](1, PinOverrideMode.Clear, PORTB);
+ expect(port.pinState(1)).toBe(PinState.Low);
+ expect(cpu.data[PINB]).toBe(0);
+ });
+
describe('removeListener', () => {
it('should remove the given listener', () => {
const cpu = new CPU(new Uint16Array(1024));