From 2fd9e6d4c040d4a54456b153f4523cab05adbf02 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Sun, 1 Dec 2019 15:18:25 +0200 Subject: feat: initial implementation of USART #6 --- demo/src/execute.ts | 8 +++++++- demo/src/index.css | 4 ++++ demo/src/index.html | 1 + demo/src/index.ts | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) (limited to 'demo') 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)); diff --git a/demo/src/index.css b/demo/src/index.css index a3fa8b8..6801204 100644 --- a/demo/src/index.css +++ b/demo/src/index.css @@ -46,3 +46,7 @@ body { margin: 0; white-space: pre-line; } + +#serial-output-text { + color: blue; +} diff --git a/demo/src/index.html b/demo/src/index.html index 935bcff..2a8e924 100644 --- a/demo/src/index.html +++ b/demo/src/index.html @@ -20,6 +20,7 @@