From 00cea56ab3d5f211aa738195de66139bd1a74f56 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Mon, 25 May 2020 16:20:24 +0300 Subject: feat(timer): Compare Match Output (#45) The Compare Match Output bits are used to generate hardware PWM signals on selected MCU pins. This is also the mechanism used by Arduino's analogWrite() method. See #32 for more details--- src/cpu/cpu.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/cpu') diff --git a/src/cpu/cpu.ts b/src/cpu/cpu.ts index 5663a1c..ed88e71 100644 --- a/src/cpu/cpu.ts +++ b/src/cpu/cpu.ts @@ -44,6 +44,7 @@ export type CPUMemoryReadHook = (addr: u16) => u8; export interface CPUMemoryReadHooks { [key: number]: CPUMemoryReadHook; } + export class CPU implements ICPU { readonly data: Uint8Array = new Uint8Array(this.sramBytes + registerSpace); readonly data16 = new Uint16Array(this.data.buffer); @@ -53,6 +54,9 @@ export class CPU implements ICPU { readonly writeHooks: CPUMemoryHooks = []; readonly pc22Bits = this.progBytes.length > 0x20000; + // This lets the Timer Compare output override GPIO pins: + readonly gpioTimerHooks: CPUMemoryHooks = []; + pc = 0; cycles = 0; -- cgit v1.2.3