aboutsummaryrefslogtreecommitdiff
path: root/demo/src/execute.ts
diff options
context:
space:
mode:
authorUri Shaked2019-12-01 15:18:25 +0200
committerUri Shaked2019-12-01 15:18:25 +0200
commit2fd9e6d4c040d4a54456b153f4523cab05adbf02 (patch)
treeaf194f254e818c1922efe6e135a071879821b32a /demo/src/execute.ts
parentchore: release 0.3.3 (diff)
downloadavr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.tar.gz
avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.tar.bz2
avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.zip
feat: initial implementation of USART
#6
Diffstat (limited to '')
-rw-r--r--demo/src/execute.ts8
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));