diff options
| author | Uri Shaked | 2020-12-09 15:55:12 +0200 |
|---|---|---|
| committer | GitHub | 2020-12-09 15:55:12 +0200 |
| commit | b2280efa5457685db66d6ce6b156f37d5e678204 (patch) | |
| tree | 1857fe48d3e2d32a39cfe810a0dfdd7d96526b3a /src/peripherals/twi.spec.ts | |
| parent | test(cpu): improve test name (diff) | |
| parent | perf!: centeral timekeeping (diff) | |
| download | avr8js-b2280efa5457685db66d6ce6b156f37d5e678204.tar.gz avr8js-b2280efa5457685db66d6ce6b156f37d5e678204.tar.bz2 avr8js-b2280efa5457685db66d6ce6b156f37d5e678204.zip | |
Merge pull request #71 from wokwi/interrupt-refactor
refactor: central interrupt handling #38
Diffstat (limited to '')
| -rw-r--r-- | src/peripherals/twi.spec.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/peripherals/twi.spec.ts b/src/peripherals/twi.spec.ts index 1a2b2ae..2628b57 100644 --- a/src/peripherals/twi.spec.ts +++ b/src/peripherals/twi.spec.ts @@ -48,9 +48,10 @@ 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.tick(); + twi.completeStart(); // This will set the TWINT flag + cpu.tick(); expect(cpu.pc).toEqual(0x30); // 2-wire Serial Interface Vector expect(cpu.cycles).toEqual(2); expect(cpu.data[TWCR] & TWINT).toEqual(0); @@ -62,7 +63,8 @@ describe('TWI', () => { const twi = new AVRTWI(cpu, twiConfig, FREQ_16MHZ); jest.spyOn(twi.eventHandler, 'start'); cpu.writeData(TWCR, TWINT | TWSTA | TWEN); - twi.tick(); + cpu.cycles++; + cpu.tick(); expect(twi.eventHandler.start).toHaveBeenCalledWith(false); }); @@ -170,7 +172,7 @@ describe('TWI', () => { `); const cpu = new CPU(program); const twi = new AVRTWI(cpu, twiConfig, FREQ_16MHZ); - const runner = new TestProgramRunner(cpu, twi, onTestBreak); + const runner = new TestProgramRunner(cpu, onTestBreak); twi.eventHandler = { start: jest.fn(), stop: jest.fn(), @@ -339,7 +341,7 @@ describe('TWI', () => { `); const cpu = new CPU(program); const twi = new AVRTWI(cpu, twiConfig, FREQ_16MHZ); - const runner = new TestProgramRunner(cpu, twi, onTestBreak); + const runner = new TestProgramRunner(cpu, onTestBreak); twi.eventHandler = { start: jest.fn(), stop: jest.fn(), |
