diff options
| author | Uri Shaked | 2020-12-09 00:51:13 +0200 |
|---|---|---|
| committer | Uri Shaked | 2020-12-09 00:51:58 +0200 |
| commit | 36c4134a26063248a2ef47f5ac8defe50d9476b1 (patch) | |
| tree | 44433290b0d684768216b33550a7af9a6fb4235f /src/peripherals/twi.spec.ts | |
| parent | test(cpu): improve test name (diff) | |
| download | avr8js-36c4134a26063248a2ef47f5ac8defe50d9476b1.tar.gz avr8js-36c4134a26063248a2ef47f5ac8defe50d9476b1.tar.bz2 avr8js-36c4134a26063248a2ef47f5ac8defe50d9476b1.zip | |
refactor: central interrupt handling #38
Diffstat (limited to '')
| -rw-r--r-- | src/peripherals/twi.spec.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/peripherals/twi.spec.ts b/src/peripherals/twi.spec.ts index 1a2b2ae..e43ae38 100644 --- a/src/peripherals/twi.spec.ts +++ b/src/peripherals/twi.spec.ts @@ -48,9 +48,11 @@ describe('TWI', () => { it('should trigger data an interrupt if TWINT is set', () => { const cpu = new CPU(new Uint16Array(1024)); const twi = new AVRTWI(cpu, twiConfig, FREQ_16MHZ); - cpu.writeData(TWCR, TWINT | TWIE); + cpu.writeData(TWCR, TWIE); cpu.data[SREG] = 0x80; // SREG: I------- + twi.completeStart(); // This will set the TWINT flag twi.tick(); + cpu.tick(); expect(cpu.pc).toEqual(0x30); // 2-wire Serial Interface Vector expect(cpu.cycles).toEqual(2); expect(cpu.data[TWCR] & TWINT).toEqual(0); @@ -63,6 +65,7 @@ describe('TWI', () => { jest.spyOn(twi.eventHandler, 'start'); cpu.writeData(TWCR, TWINT | TWSTA | TWEN); twi.tick(); + cpu.tick(); expect(twi.eventHandler.start).toHaveBeenCalledWith(false); }); |
