diff options
| author | Uri Shaked | 2020-05-25 16:20:24 +0300 |
|---|---|---|
| committer | GitHub | 2020-05-25 16:20:24 +0300 |
| commit | 00cea56ab3d5f211aa738195de66139bd1a74f56 (patch) | |
| tree | 6ef5b22ca31863341b9d70c81234e56a7a87dbb9 /src/cpu | |
| parent | docs: walkthrough video link (diff) | |
| download | avr8js-00cea56ab3d5f211aa738195de66139bd1a74f56.tar.gz avr8js-00cea56ab3d5f211aa738195de66139bd1a74f56.tar.bz2 avr8js-00cea56ab3d5f211aa738195de66139bd1a74f56.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | src/cpu/cpu.ts | 4 |
1 files changed, 4 insertions, 0 deletions
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; |
