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