]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/env.c
env var fmon (F_CPU)
[z180-stamp.git] / avr / env.c
index 44c5742afe3043a6054218eede24a7660436e62b..8896004c8effb9729732fe451c01fa842caaab39 100644 (file)
--- a/avr/env.c
+++ b/avr/env.c
@@ -14,7 +14,7 @@
 
 #define DEBUG_ENV      0       /* set to 1 to debug */
 
-#define debug_env(fmt, args...)                                                              \
+#define debug_env(fmt, args...)                                                \
        debug_cond(DEBUG_ENV, fmt, ##args)
 
 
 #define DELIM          "\0"
 
 const FLASH char default_env[] = {
-       ENV_BAUDRATE      "=" "115200" DELIM
-       ENV_BOOTDELAY     "=" "3" DELIM
+       ENV_BAUDRATE      "=" stringify(CONFIG_BAUDRATE) DELIM
+       ENV_BOOTDELAY     "=" stringify(CONFIG_BOOTDELAY) DELIM
        ENV_BOOTCMD               "=" "pin ${pins};loadcpm3;go ${startaddress}" DELIM
        ENV_CPM3_SYSFILE  "=" CONFIG_CPM3_SYSFILE DELIM
        ENV_PINALIAS      "=" "0:PG5,1:PG4,2:PB4,3:PB5,4:PB6,5:PB7,"
                                                  "6:PG3,7:PG2,8:PG1,9:PG0,10:PE7" DELIM
-       //ENV_STARTADDRESS  "=" "0" DELIM
        "pins"                    "=" "2,8 low 9 high 3 2" DELIM
        DELIM
 };
@@ -693,9 +692,6 @@ command_ret_t do_env_print(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED,
        bool mode = 0;
        command_ret_t rc = CMD_RET_SUCCESS;
 
-       /* reset getopt() */
-       optind = 0;
-
        int opt;
        while ((opt = getopt(argc, argv, PSTR("s"))) != -1) {
                switch (opt) {
@@ -795,3 +791,91 @@ int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf)
        return found;
 }
 #endif
+
+cmd_tbl_t cmd_tbl_env[] = {
+CMD_TBL_ITEM_COMPLETE(
+       printenv, CONFIG_SYS_MAXARGS,   1|CTBL_SUBCMDAUTO,      do_env_print,
+       "print environment variables",
+       "[-s] [name ...]\n"
+       "    Print value of environment variable(s) 'name'\n"
+       "    If no names are given, print values of all environment variables\n"
+       "    -s Print in setenv form",
+       var_complete
+),
+CMD_TBL_ITEM_COMPLETE(
+       setenv, CONFIG_SYS_MAXARGS,     CTBL_SUBCMDAUTO,        do_env_set,
+       "set environment variables",
+       "name value ...\n"
+       "    - set environment variable 'name' to 'value ...'\n"
+       "setenv name\n"
+       "    - delete environment variable 'name'",
+       var_complete
+),
+CMD_TBL_ITEM(
+       saveenv,        1,      CTBL_SUBCMDAUTO,        do_env_save,
+       "save environment variables to persistent storage",
+       ""
+),
+CMD_TBL_ITEM(
+       defaultenv,     1,      CTBL_SUBCMDAUTO,        do_env_default,
+       "set all environment variables to their default values",
+       ""
+),
+
+CMD_TBL_ITEM_COMPLETE(
+       print, CONFIG_SYS_MAXARGS,      1,      do_env_print,
+       "print environment variables",
+       "[-s] [name ...]\n"
+       "    Print value of environment variable(s) 'name'\n"
+       "    If no names are given, print values of all environment variables\n"
+       "    -s Print in setenv form",
+       var_complete
+),
+CMD_TBL_ITEM_COMPLETE(
+       set, CONFIG_SYS_MAXARGS,        0,      do_env_set,
+       "set environment variables",
+       "name value ...\n"
+       "    - set environment variable 'name' to 'value ...'\n"
+       "setenv name\n"
+       "    - delete environment variable 'name'",
+       var_complete
+),
+CMD_TBL_ITEM(
+       save,   1,      0,      do_env_save,
+       "save environment variables to persistent storage",
+       ""
+),
+CMD_TBL_ITEM(
+       default,        1,      0,      do_env_default,
+       "set all environment variables to their default values",
+       ""
+),
+
+CMD_TBL_ITEM(
+       help,   CONFIG_SYS_MAXARGS,     CTBL_RPT,       do_help,
+       "Print sub command description/usage",
+       "\n"
+       "       - print brief description of all sub commands\n"
+       "env help command ...\n"
+       "       - print detailed usage of sub cmd 'command'"
+),
+
+/* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */
+       {FSTR("?"),   CONFIG_SYS_MAXARGS, 1, do_help,
+        NULL,
+#ifdef  CONFIG_SYS_LONGHELP
+       FSTR(""),
+#endif /* CONFIG_SYS_LONGHELP */
+       NULL,
+#ifdef CONFIG_AUTO_COMPLETE
+       NULL,
+#endif
+},
+/* Mark end of table */
+CMD_TBL_END(cmd_tbl_env)
+};
+
+command_ret_t do_env(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc UNUSED, char * const argv[] UNUSED)
+{
+       return CMD_RET_USAGE;
+}