1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// redboot_cmds.c
|
4 |
|
|
//
|
5 |
|
|
// OLPCE2294 [platform] specific RedBoot commands
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2008 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): Sergei Gavrikov
|
43 |
|
|
// Contributors: Sergei Gavrikov
|
44 |
|
|
// Date: 2008-08-31
|
45 |
|
|
// Purpose:
|
46 |
|
|
// Description:
|
47 |
|
|
//
|
48 |
|
|
// This code is part of RedBoot (tm).
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//
|
52 |
|
|
//========================================================================*/
|
53 |
|
|
|
54 |
|
|
#include <redboot.h>
|
55 |
|
|
|
56 |
|
|
#include <cyg/hal/hal_diag.h>
|
57 |
|
|
|
58 |
|
|
// CLI functions
|
59 |
|
|
local_cmd_entry ("clear", "Clean up LCD entires", "", lcd_clear, LCD_cmds);
|
60 |
|
|
|
61 |
|
|
local_cmd_entry ("dark", "Turn LCD lighting off", "", lcd_dark, LCD_cmds);
|
62 |
|
|
|
63 |
|
|
local_cmd_entry ("echo",
|
64 |
|
|
"Output the args. If -n is specified, the trailing newline is suppressed.",
|
65 |
|
|
"-n [arg ...]", lcd_echo, LCD_cmds);
|
66 |
|
|
|
67 |
|
|
local_cmd_entry ("light", "Turn LCD lighting on", "", lcd_light, LCD_cmds);
|
68 |
|
|
|
69 |
|
|
CYG_HAL_TABLE_BEGIN (__LCD_cmds_TAB__, LCD_cmds);
|
70 |
|
|
CYG_HAL_TABLE_END (__LCD_cmds_TAB_END__, LCD_cmds);
|
71 |
|
|
|
72 |
|
|
extern struct cmd __LCD_cmds_TAB__[], __LCD_cmds_TAB_END__;
|
73 |
|
|
|
74 |
|
|
static cmd_fun do_lcd;
|
75 |
|
|
RedBoot_nested_cmd ("lcd",
|
76 |
|
|
"Manage LCD display",
|
77 |
|
|
"{cmds}",
|
78 |
|
|
do_lcd, __LCD_cmds_TAB__, &__LCD_cmds_TAB_END__);
|
79 |
|
|
|
80 |
|
|
//--------------------------------------------------------------------------
|
81 |
|
|
// lcd_usage --
|
82 |
|
|
//
|
83 |
|
|
static void
|
84 |
|
|
lcd_usage (char *why)
|
85 |
|
|
{
|
86 |
|
|
diag_printf ("*** invalid 'lcd' command: %s\n", why);
|
87 |
|
|
cmd_usage (__LCD_cmds_TAB__, &__LCD_cmds_TAB_END__, "lcd ");
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
//--------------------------------------------------------------------------
|
91 |
|
|
// do_lcd --
|
92 |
|
|
//
|
93 |
|
|
static void
|
94 |
|
|
do_lcd (int argc, char *argv[])
|
95 |
|
|
{
|
96 |
|
|
struct cmd *cmd;
|
97 |
|
|
|
98 |
|
|
if (argc < 2) {
|
99 |
|
|
lcd_usage ("too few arguments");
|
100 |
|
|
return;
|
101 |
|
|
}
|
102 |
|
|
if ((cmd = cmd_search (__LCD_cmds_TAB__, &__LCD_cmds_TAB_END__,
|
103 |
|
|
argv[1])) != (struct cmd *) 0) {
|
104 |
|
|
(cmd->fun) (argc, argv);
|
105 |
|
|
return;
|
106 |
|
|
}
|
107 |
|
|
lcd_usage ("unrecognized command");
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
//--------------------------------------------------------------------------
|
111 |
|
|
// lcd_echo --
|
112 |
|
|
//
|
113 |
|
|
static void
|
114 |
|
|
lcd_echo (int argc, char *argv[])
|
115 |
|
|
{
|
116 |
|
|
bool newline;
|
117 |
|
|
int cur =
|
118 |
|
|
CYGACC_CALL_IF_SET_CONSOLE_COMM
|
119 |
|
|
(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
|
120 |
|
|
CYGACC_CALL_IF_SET_CONSOLE_COMM (2);
|
121 |
|
|
|
122 |
|
|
newline = true;
|
123 |
|
|
if (argc > 2) {
|
124 |
|
|
int i = 2;
|
125 |
|
|
if (strncmp (&argv[i][0], "-n", 2) == 0) {
|
126 |
|
|
newline = false;
|
127 |
|
|
i++;
|
128 |
|
|
}
|
129 |
|
|
for (; i < argc; i++) {
|
130 |
|
|
diag_write_string (&argv[i][0]);
|
131 |
|
|
if ((argc - i) > 1)
|
132 |
|
|
diag_write_char (' ');
|
133 |
|
|
}
|
134 |
|
|
}
|
135 |
|
|
if (newline)
|
136 |
|
|
diag_write_char ('\n');
|
137 |
|
|
|
138 |
|
|
CYGACC_CALL_IF_SET_CONSOLE_COMM (cur);
|
139 |
|
|
return;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
//--------------------------------------------------------------------------
|
143 |
|
|
// lcd_clear --
|
144 |
|
|
//
|
145 |
|
|
static void
|
146 |
|
|
lcd_clear (int argc, char *argv[])
|
147 |
|
|
{
|
148 |
|
|
// It clears a LCD screen. It doesn't touch a LCD controller, just a
|
149 |
|
|
// scrolling.
|
150 |
|
|
redboot_exec ("lcd", "echo", 0);
|
151 |
|
|
redboot_exec ("lcd", "echo", 0);
|
152 |
|
|
redboot_exec ("lcd", "echo", 0);
|
153 |
|
|
return;
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
//--------------------------------------------------------------------------
|
157 |
|
|
// lcd_dark --
|
158 |
|
|
//
|
159 |
|
|
static void
|
160 |
|
|
lcd_dark (int argc, char *argv[])
|
161 |
|
|
{
|
162 |
|
|
hal_diag_led (0);
|
163 |
|
|
return;
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
//--------------------------------------------------------------------------
|
167 |
|
|
// lcd_light --
|
168 |
|
|
//
|
169 |
|
|
static void
|
170 |
|
|
lcd_light (int argc, char *argv[])
|
171 |
|
|
{
|
172 |
|
|
hal_diag_led (1);
|
173 |
|
|
return;
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
// indent: --indent-level4 -br -nut; vim: expandtab tabstop=4 shiftwidth=4
|
177 |
|
|
//--------------------------------------------------------------------------
|
178 |
|
|
// EOF redboot_cmds.c
|