diff options
Diffstat (limited to 'src/peripherals/twi.ts')
| -rw-r--r-- | src/peripherals/twi.ts | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/peripherals/twi.ts b/src/peripherals/twi.ts index 914b67f..000bd2a 100644 --- a/src/peripherals/twi.ts +++ b/src/peripherals/twi.ts @@ -95,8 +95,6 @@ export class NoopTWIEventHandler implements TWIEventHandler { export class AVRTWI { public eventHandler: TWIEventHandler = new NoopTWIEventHandler(this); - private nextTick: (() => void) | null = null; - // Interrupts private TWI: AVRInterruptConfig = { address: this.config.twiInterrupt, @@ -116,7 +114,7 @@ export class AVRTWI { const { status } = this; if (clearInt && value & TWCR_TWEN) { const twdrValue = this.cpu.data[this.config.TWDR]; - this.nextTick = () => { + this.cpu.addClockEvent(() => { if (value & TWCR_TWSTA) { this.eventHandler.start(status !== STATUS_TWI_IDLE); } else if (value & TWCR_TWSTO) { @@ -129,19 +127,12 @@ export class AVRTWI { const ack = !!(value & TWCR_TWEA); this.eventHandler.readByte(ack); } - }; + }, 0); return true; } }; } - tick() { - if (this.nextTick) { - this.nextTick(); - this.nextTick = null; - } - } - get prescaler() { switch (this.cpu.data[this.config.TWSR] & TWSR_TWPS_MASK) { case 0: |
