]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - sw/app/rocon/cmd_uartcon.c
RoCoN: debug print includes actual action/PWM output for now.
[fpga/lx-cpu1/lx-rocon.git] / sw / app / rocon / cmd_uartcon.c
1 /*******************************************************************
2   Components for embedded applications builded for
3   laboratory and medical instruments firmware
4
5   cmd_uartcon.c - interconnection of text command processor
6                 with RS-232 line
7
8   Copyright (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
9             (C) 2002 by PiKRON Ltd. http://www.pikron.com
10
11  *******************************************************************/
12
13 #include <types.h>
14 #include <ctype.h>
15 #include <string.h>
16 #include <utils.h>
17 #include <cmd_proc.h>
18
19 #define ED_LINE_CHARS 512
20
21 cmd_io_t cmd_io_uartcon_dev;
22
23 char ed_line_chars_uartcon_in[ED_LINE_CHARS + 1];
24 char ed_line_chars_uartcon_out[ED_LINE_CHARS + 1];
25
26 ed_line_buf_t ed_line_buf_uartcon_in =
27 {
28 flg:
29   FL_ELB_ECHO,
30   inbuf: 0,
31 alloc:
32   sizeof(ed_line_chars_uartcon_in),
33   maxlen: 0,
34   lastch: 0,
35 buf:
36   ed_line_chars_uartcon_in
37 };
38
39 ed_line_buf_t ed_line_buf_uartcon_out =
40 {
41 flg:
42   FL_ELB_NOCRLF,
43   inbuf: 0,
44 alloc:
45   sizeof(ed_line_chars_uartcon_out),
46   maxlen: 0,
47   lastch: 0,
48 buf:
49   ed_line_chars_uartcon_out
50 };
51
52 cmd_io_t cmd_io_uartcon =
53 {
54 putc:
55   cmd_io_line_putc,
56 getc:
57   NULL,
58 write:
59   cmd_io_write_bychar,
60 read:
61   NULL,
62 priv:
63   {
64   ed_line:
65     {
66     in:
67       &ed_line_buf_uartcon_in,
68     out:
69       &ed_line_buf_uartcon_out,
70     io_stack:
71       &cmd_io_uartcon_dev
72     }
73   }
74 };
75
76 int cmd_io_putc_uartcon(struct cmd_io *cmd_io, int ch)
77 {
78   int uartch = cmd_io->priv.uart.uartch;
79
80   ch = uart0PutchNW(ch);
81
82   if (ch == -1)
83     return -1;
84   else
85     return ch;
86 }
87
88 int cmd_io_getc_uartcon(struct cmd_io *cmd_io)
89 {
90   int ch;
91   int uartch = cmd_io->priv.uart.uartch;
92
93   ch = uart0Getch();
94
95   if (ch == -1)
96     return -1;
97   else
98     return ch;
99 }
100
101 cmd_io_t cmd_io_uartcon_dev =
102 {
103   .putc = cmd_io_putc_uartcon,
104   .getc = cmd_io_getc_uartcon,
105   .write = cmd_io_write_bychar,
106   .read = cmd_io_read_bychar,
107   .priv.uart = { -1}
108 };
109