]> cloudbase.mooo.com Git - z180-stamp.git/blob - avr/command_tbl.c
336c608b326c72a530a99e824ecaa4b52ce63a24
[z180-stamp.git] / avr / command_tbl.c
1
2 #include "common.h"
3
4 #include "command.h"
5 #include "cmd_mem.h"
6
7
8 extern command_ret_t do_help(cmd_tbl_t *, int, int, char * const []);
9 extern command_ret_t do_echo(cmd_tbl_t *, int, int, char * const []);
10 extern command_ret_t do_sleep(cmd_tbl_t *, int, int, char * const []);
11 extern command_ret_t do_env_print(cmd_tbl_t *, int, int, char * const []);
12 extern command_ret_t do_env_default(cmd_tbl_t *, int, int, char * const []);
13 extern command_ret_t do_env_set(cmd_tbl_t *, int, int, char * const []);
14 extern command_ret_t do_env_save(cmd_tbl_t *, int, int, char * const []);
15 extern command_ret_t do_loadf(cmd_tbl_t *, int, int, char * const []);
16 extern command_ret_t do_go(cmd_tbl_t *, int, int, char * const []);
17 extern command_ret_t do_restart(cmd_tbl_t *, int, int, char * const []);
18 extern command_ret_t do_console(cmd_tbl_t *, int, int, char * const []);
19 extern command_ret_t do_dump_mem(cmd_tbl_t *, int, int, char * const []);
20 extern command_ret_t do_eep_cp(cmd_tbl_t *, int, int, char * const []);
21 extern command_ret_t do_busreq_pulse(cmd_tbl_t *, int, int, char * const []);
22 extern command_ret_t do_date(cmd_tbl_t *, int, int, char * const []);
23 extern command_ret_t do_pin(cmd_tbl_t *, int, int, char * const []);
24
25
26 cmd_tbl_t cmd_tbl[] = {
27
28 CMD_TBL_ITEM(
29 date, 2, 1, do_date,
30 "get/set/reset date & time",
31 "[MMDDhhmm[[CC]YY][.ss]]\ndate reset\n"
32 " - without arguments: print date & time\n"
33 " - with numeric argument: set the system date & time\n"
34 " - with 'reset' argument: reset the RTC"
35 ),
36
37 #ifdef DEBUG
38 CMD_TBL_ITEM(
39 !mdr, 3, 1, do_dump_mem,
40 "RAM dump",
41 "address [count]"
42 ),
43 CMD_TBL_ITEM(
44 !mde, 3, 1, do_dump_mem,
45 "EEPROM dump",
46 "address [count]"
47 ),
48 CMD_TBL_ITEM(
49 !cpe, 4, 0, do_eep_cp,
50 "EEPROM copy",
51 "source target count"
52 ),
53 #endif
54 CMD_TBL_ITEM(
55 mstep, 2, 1, do_busreq_pulse,
56 "execute one M cycle",
57 "[count]\n"
58 " - repeat count times"
59 ),
60 CMD_TBL_ITEM(
61 echo, CONFIG_SYS_MAXARGS, 1, do_echo,
62 "echo args to console",
63 "[args..]\n"
64 " - echo args to console; \\c suppresses newline"
65 ),
66 CMD_TBL_ITEM(
67 sleep , 2, 1, do_sleep,
68 "delay execution for some time",
69 "N[m][s]\n"
70 " - delay execution for decimal N (milli) seconds"
71 ),
72 CMD_TBL_ITEM_COMPLETE(
73 run, CONFIG_SYS_MAXARGS, 1, do_run,
74 "run commands in an environment variable",
75 "var [...]\n"
76 " - run the commands in the environment variable(s) 'var'",
77 var_complete
78 ),
79 CMD_TBL_ITEM_COMPLETE(
80 printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
81 "print environment variables",
82 "\n"
83 " - print values of all environment variables\n"
84 "printenv name ...\n"
85 " - print value of environment variable 'name'",
86 var_complete
87 ),
88 CMD_TBL_ITEM_COMPLETE(
89 setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
90 "set environment variables",
91 "name value ...\n"
92 " - set environment variable 'name' to 'value ...'\n"
93 "setenv name\n"
94 " - delete environment variable 'name'",
95 var_complete
96 ),
97 CMD_TBL_ITEM(
98 saveenv, 1, 0, do_env_save,
99 "save environment variables to persistent storage",
100 ""
101 ),
102 CMD_TBL_ITEM(
103 defaultenv, 1, 0, do_env_default,
104 "set all environment variables to their default values",
105 ""
106 ),
107
108 CMD_TBL_ITEM(
109 loadf, 1, 0, do_loadf,
110 "load srec_cat prepared image from controller flash",
111 ""
112 ),
113 CMD_TBL_ITEM(
114 go, 2, 0, do_go,
115 "start application at address 'addr'",
116 "addr\n"
117 " - start application at address 'addr'"
118 // "\n"
119 // " passing 'arg' as arguments"
120 ),
121 CMD_TBL_ITEM(
122 reset, 1, 0, do_reset,
123 "Keep CPU in RESET state",
124 ""
125 ),
126 CMD_TBL_ITEM(
127 restart, 1, 1, do_restart,
128 "Perform RESET of the CPU",
129 ""
130 ),
131 CMD_TBL_ITEM(
132 connect, 1, 1, do_console,
133 "Connect to CPU console i/o",
134 ""
135 ),
136
137 #if 0
138 CMD_TBL_ITEM(
139 clock, 2, 0, do_clock,
140 "Set or get CPU frequency",
141 "\n"
142 " - print frequency or state of clock pin\n"
143 "clock value[K|M]\n"
144 " - set frequency of clock pin to value\n"
145 "clock [high|low]\n"
146 " - set clock pin level high or low"
147 ),
148 CMD_TBL_ITEM(
149 clk2, 3, 0, do_clock2,
150 "Set or get clk2 frequency",
151 "\n"
152 " - print frequency or state of clk2 pin\n"
153 "clk2 [-d] value[K|M]\n"
154 " - set frequency of clk2 pin to value\n"
155 "clk2 [high|low]\n"
156 " - set clk2 pin level high or low"
157 ),
158 #endif
159
160 CMD_TBL_ITEM(
161 pin, CONFIG_SYS_MAXARGS, 0, do_pin,
162 "Set or query pin state",
163 "[-s] [<pins>]\n"
164 " - print cofiguration and state or frequency of pins\n"
165 " print all pins, if argument is omitted\n"
166 "pin <pins> h[igh]|l[ow]\n"
167 " - config pins as output and set to level high or low\n"
168 "pin <pins> ts|i[n]|p[ullup]\n"
169 " - config pins as input/tristate or input with pullup\n"
170 "pin <pins> value[K|M][Hz]\n"
171 " - output a clock on pins\n"
172 " value is system clock divider or frequency, if 'Hz' is appended\n"
173 " divider is rounded down to next possible value (depends on pin)\n"
174 "\n"
175 "<pins> is a comma separated list of numbers or ranges, i.e. \"0,9,3-6\"\n"
176 ),
177
178 CMD_TBL_ITEM(
179 md, 3, 1, do_mem_md,
180 "memory display",
181 "address [# of objects]"
182 ),
183 CMD_TBL_ITEM(
184 mm, 2, 1, do_mem_mm,
185 "memory modify (auto-incrementing address)",
186 "address"
187 ),
188 CMD_TBL_ITEM(
189 nm, 2, 1, do_mem_nm,
190 "memory modify (constant address)",
191 "address"
192 ),
193 CMD_TBL_ITEM(
194 mw, 4, 1, do_mem_mw,
195 "memory write (fill)",
196 "address value [count]"
197 ),
198 CMD_TBL_ITEM(
199 cp, 4, 1, do_mem_cp,
200 "memory copy",
201 "source target count"
202 ),
203 CMD_TBL_ITEM(
204 cmp, 4, 1, do_mem_cmp,
205 "memory compare",
206 "addr1 addr2 count"
207 ),
208 CMD_TBL_ITEM(
209 base, 2, 1, do_mem_base,
210 "print or set address offset",
211 "\n"
212 " - print address offset for memory commands\n"
213 "base offset\n"
214 " - set address offset for memory commands to 'offset'"
215 ),
216 CMD_TBL_ITEM(
217 loop, 3, 1, do_mem_loop,
218 "infinite loop on address range",
219 "address number_of_bytes"
220 ),
221 #ifdef CONFIG_LOOPW
222 CMD_TBL_ITEM(
223 loopw, 4, 1, do_mem_loopw,
224 "infinite write loop on address range",
225 "address number_of_bytes data_to_write"
226 ),
227 #endif /* CONFIG_LOOPW */
228
229 #ifdef CONFIG_CMD_MEMTEST
230 CMD_TBL_ITEM(
231 mtest, 5, 1, do_mem_mtest,
232 "simple RAM read/write test",
233 "[start [end [pattern [iterations]]]]"
234 ),
235 #endif /* CONFIG_CMD_MEMTEST */
236
237 #ifdef CONFIG_MX_CYCLIC
238 CMD_TBL_ITEM(
239 mdc, 4, 1, do_mem_mdc,
240 "memory display cyclic",
241 "address count delay(ms)"
242 ),
243 CMD_TBL_ITEM(
244 mwc, 4, 1, do_mem_mwc,
245 "memory write cyclic",
246 "address value delay(ms)"
247 ),
248 #endif /* CONFIG_MX_CYCLIC */
249
250
251 CMD_TBL_ITEM(
252 help, CONFIG_SYS_MAXARGS, 1, do_help,
253 "print command description/usage",
254 "\n"
255 " - print brief description of all commands\n"
256 "help command ...\n"
257 " - print detailed usage of 'command'"
258 ),
259
260 /* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */
261 {FSTR("?"), CONFIG_SYS_MAXARGS, 1, do_help,
262 FSTR("alias for 'help'"),
263 #ifdef CONFIG_SYS_LONGHELP
264 FSTR(""),
265 #endif /* CONFIG_SYS_LONGHELP */
266 #ifdef CONFIG_AUTO_COMPLETE
267 0,
268 #endif
269 },
270 /* Mark end of table */
271 { 0 },
272 };