OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [emuThor/] [source/] [clsUart.cpp] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 robfinch
#include "stdafx.h"
2
#include "clsUart.h"
3
 
4
void clsUart::Reset()
5
{
6
        ls = 0x60;
7
}
8
bool clsUart::IsSelected(unsigned int ad)
9
{
10 35 robfinch
        return (ad & 0xFFFFFFF0LL)==0xFFDC0A00;
11 32 robfinch
}
12
 
13
unsigned int clsUart::Read(unsigned int ad)
14
{
15
        if (IsSelected(ad)) {
16
                switch(ad & 0xF) {
17
                case 0:          ls &= 0xFE; return rb;
18
                case 1:         return ls;
19
                case 2:         return ms;
20
                case 3:         return is;
21
                default:        return 0x00;
22
                }
23
        }
24
        else
25
                return 0;
26
}
27
 
28
int clsUart::Write(unsigned int ad, unsigned int dat, unsigned int mask)
29
{
30
        if (IsSelected(ad)) {
31
                switch(ad & 0xF) {
32
                case 0:          tb = dat; ls &= 0x9F; break;
33
                case 4:         ier = dat; break;
34
                case 6:         mc = dat; break;
35
                case 7:         ctrl = dat; break;
36
                case 9:         cm1 = dat; break;
37
                case 10:        cm2 = dat; break;
38
                case 11:        cm3 = dat; break;
39
                case 12:        fc = dat; break;
40
                }
41
        }
42
        return 0;
43
}
44
 
45
int clsUart::TxPort()
46
{
47
        int d;
48
 
49
        if ((ls & 0x60)==0x60)
50
                d = 0xff;
51
        else
52
                d = tb;
53
        ls |= 0x60;
54
        if (ier & 2) {
55
                irq = true;
56
                system1.pic1.irqUart = true;
57
        }
58
        return d;
59
}
60
 
61
void clsUart::RxPort(unsigned int dat)
62
{
63
        if (ls & 1)
64
                ls |= 2;
65
        ls |= 1;
66
        if (ier & 1) {
67
                irq = true;
68
                system1.pic1.irqUart = true;
69
        }
70
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.