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