diff options
| author | Uri Shaked | 2019-12-01 15:18:25 +0200 |
|---|---|---|
| committer | Uri Shaked | 2019-12-01 15:18:25 +0200 |
| commit | 2fd9e6d4c040d4a54456b153f4523cab05adbf02 (patch) | |
| tree | af194f254e818c1922efe6e135a071879821b32a /demo/src/execute.ts | |
| parent | chore: release 0.3.3 (diff) | |
| download | avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.tar.gz avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.tar.bz2 avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.zip | |
feat: initial implementation of USART
#6
Diffstat (limited to 'demo/src/execute.ts')
| -rw-r--r-- | demo/src/execute.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/demo/src/execute.ts b/demo/src/execute.ts index 4568839..f2c7d82 100644 --- a/demo/src/execute.ts +++ b/demo/src/execute.ts @@ -4,9 +4,11 @@ import { CPU, timer0Config, AVRIOPort, + AVRUSART, portBConfig, portCConfig, - portDConfig + portDConfig, + usart0Config } from 'avr8js'; import { loadHex } from './intelhex'; @@ -20,6 +22,8 @@ export class AVRRunner { readonly portB: AVRIOPort; readonly portC: AVRIOPort; readonly portD: AVRIOPort; + readonly usart: AVRUSART; + readonly speed = 16e6; // 16 MHZ private stopped = false; @@ -30,6 +34,7 @@ export class AVRRunner { this.portB = new AVRIOPort(this.cpu, portBConfig); this.portC = new AVRIOPort(this.cpu, portCConfig); this.portD = new AVRIOPort(this.cpu, portDConfig); + this.usart = new AVRUSART(this.cpu, usart0Config, this.speed); } async execute(callback: (cpu: CPU) => void) { @@ -37,6 +42,7 @@ export class AVRRunner { for (;;) { avrInstruction(this.cpu); this.timer.tick(); + this.usart.tick(); if (this.cpu.cycles % 50000 === 0) { callback(this.cpu); await new Promise((resolve) => setTimeout(resolve, 0)); |
