[ucsim] Intro -U, -u options and configurable NL in UART display
[sdcc.git] / sdcc / sim / ucsim / src / core / sim.src / serial_hwcl.h
blob531c91e35902531fe200c223787a97eb3540042d
1 /*
2 * Simulator of microcontrollers (sim.src/serial_hwcl.h)
4 * Copyright (C) 2016,16 Drotos Daniel, Talker Bt.
5 *
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
8 */
10 /* This file is part of microcontroller simulator: ucsim.
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.
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.
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@*/
28 #ifndef SERIAL_HWCL_HEADER
29 #define SERIAL_HWCL_HEADER
31 #include "newcmdposixcl.h"
33 #include "hwcl.h"
36 enum serial_cfg {
37 serconf_on = 0,
38 serconf_check_often = 1,
39 serconf_escape = 2,
40 serconf_common = 3,
41 serconf_received = 4,
42 serconf_flowctrl = 5,
43 serconf_able_receive = 6,
44 serconf_nl = 7,
45 serconf_nr = 8
49 class cl_serial_io: public cl_hw_io
51 public:
52 cl_serial_io(class cl_hw *ihw):
53 cl_hw_io(ihw)
55 //virtual bool prevent_quit(void) { return true; }
56 virtual bool input_avail(void);
59 class cl_serial_hw: public cl_hw
61 friend class cl_serial_listener;
62 protected:
63 class cl_optref *serial_in_file_option;
64 class cl_optref *serial_out_file_option;
65 class cl_optref *serial_port_option;
66 class cl_optref *serial_iport_option;
67 class cl_optref *serial_oport_option;
68 class cl_optref *serial_ifirst_option;
69 class cl_optref *serial_raw_option;
70 class cl_serial_listener *listener_io, *listener_i, *listener_o;
71 //class cl_hw_io *io;
72 char input;
73 bool input_avail;
74 char menu;
75 bool is_raw;
76 bool sending_nl;
77 int skip_nl;
78 u32_t nl_value;
79 int nl_send_idx;
80 public:
81 cl_serial_hw(class cl_uc *auc, int aid, chars aid_string);
82 virtual ~cl_serial_hw(void);
83 virtual int init(void);
84 virtual unsigned int cfg_size(void) { return serconf_nr; }
85 virtual const char *cfg_help(t_addr addr);
87 virtual bool set_cmd(class cl_cmdline *cmdline, class cl_console_base *con);
88 virtual void set_help(class cl_console_base *con);
89 virtual t_mem conf_op(cl_memory_cell *cell, t_addr addr, t_mem *val);
90 virtual bool is_nl(char c) { return (c=='\n') || (c=='\r'); }
91 virtual char opposite_nl(char c) { return (c=='\n')?'\r':((c=='\r')?'\n':c); }
92 virtual u8_t get_input(void);
94 virtual void make_io(void);
95 virtual void new_io(class cl_f *f_in, class cl_f *f_out);
96 virtual void new_i(class cl_f *f_in);
97 virtual void new_o(class cl_f *f_out);
98 virtual void set_raw(void);
99 virtual void del_listener_i(void);
100 virtual void del_listener_o(void);
101 virtual bool proc_input(void);
102 virtual void refresh_display(bool force) {}
103 virtual void draw_state_time(bool force) {}
104 virtual void draw_display(void) {}
106 virtual void reset(void);
109 enum ser_listener_for
111 sl_io,
112 sl_i,
113 sl_o
116 class cl_serial_listener: public cl_listen_console
118 protected:
119 enum ser_listener_for sl_for;
120 public:
121 class cl_serial_hw *serial_hw;
122 cl_serial_listener(int serverport, class cl_app *the_app,
123 class cl_serial_hw *the_serial,
124 enum ser_listener_for slf);
125 virtual int init(void);
126 virtual int proc_input(class cl_cmdset *cmdset);
127 virtual bool prevent_quit(void) { return false; }
131 #endif
133 /* End of sim.src/serial_hwcl.h */