All files / src serial.js

100% Statements 16/16
100% Branches 0/0
100% Functions 4/4
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3139x       261x 261x       357x 357x 357x       28x 28x 28x 28x 28x 28x 28x 28x       1x 1x      
const table = [19200, 9600, 4800, 2400, 1200, 300, 150, 75];
 
export class Serial {
    constructor(acia) {
        this.acia = acia;
        this.reset();
    }
 
    reset() {
        this.reg = 0;
        this.transmitRate = 0;
        this.receiveRate = 0;
    }
 
    write(addr, val) {
        val &= 0xff;
        this.reg = val;
        this.transmitRate = val & 0x07;
        this.receiveRate = (val >>> 3) & 0x07;
        this.acia.setSerialReceive(table[this.receiveRate]);
        this.acia.setSerialTransmit(table[this.transmitRate]);
        this.acia.setMotor(!!(val & 0x80));
        this.acia.selectRs423(!!(val & 0x40));
    }
 
    read() {
        this.write(0, 0xfe);
        return 0;
    }
}