ucsim-0.2.37-pre3 into cvs
[fw/sdcc] / sim / ucsim / s51.src / timer2.cc
1 /*
2  * Simulator of microcontrollers (timer2.cc)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27
28 #include "timer2cl.h"
29 #include "regs51.h"
30
31
32 cl_timer2::cl_timer2(class cl_uc *auc):
33   cl_hw(auc, HW_TIMER, 2, "timer2")
34 {}
35
36 /*int
37 cl_timer2::init(void)
38 {
39   return(0);
40 }*/
41
42 void
43 cl_timer2::print_info(class cl_console *con)
44 {
45   int t2con= uc->get_mem(MEM_SFR, T2CON);
46
47   con->printf("%s[%d] 0x%04x", id_string, id,
48               256*uc->get_mem(MEM_SFR, TH2)+uc->get_mem(MEM_SFR, TL2));
49   if (t2con & (bmRCLK|bmTCLK))
50     {
51       con->printf(" baud");
52       if (t2con & bmRCLK)
53         con->printf(" RCLK");
54       if (t2con & bmTCLK)
55         con->printf(" TCLK");
56     }
57   else
58     con->printf(" %s", (t2con&bmCP_RL2)?"capture":"reload");
59   con->printf(" 0x%04x",
60               256*uc->get_mem(MEM_SFR, RCAP2H)+uc->get_mem(MEM_SFR, RCAP2L));
61   con->printf(" %s", (t2con&bmC_T2)?"counter":"timer");
62   con->printf(" %s", (t2con&bmTR2)?"ON":"OFF");
63   con->printf(" irq=%c", (t2con&bmTF2)?'1':'0');
64   con->printf(" %s", (uc->get_mem(MEM_SFR, IE)&bmET2)?"en":"dis");
65   con->printf(" prio=%d", uc->it_priority(bmPT2));
66   con->printf("\n");
67 }
68
69
70 /* End of s51.src/timer2.cc */