summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2018-10-01 15:49:00 +0200
committerLeo C2018-10-01 15:49:00 +0200
commitd2f546c134b8c7ae6e2068aaf9316bb8835c13c2 (patch)
tree0f846ea2a82a91958975f36c306e298018e20342
parentf6154a3944b775a6d6846f132b184d94b44bc204 (diff)
parentdd1cc6f0b4a9cc2b49afb86c768813c087e46b4b (diff)
downloadz180-stamp-d2f546c134b8c7ae6e2068aaf9316bb8835c13c2.zip
Merge branch 'z80-if' of ssh://cb/home/leo/Projekte/stamp/z180-stamp into z80-if
-rw-r--r--avr/cmd_attach.c3
-rw-r--r--avr/cmd_boot.c6
-rw-r--r--avr/cmd_cpu.c8
-rw-r--r--avr/cmd_gpio.c3
-rw-r--r--avr/cmd_mem.c4
-rw-r--r--avr/cmd_misc.c28
-rw-r--r--avr/command.c6
-rw-r--r--avr/command_tbl.c7
-rw-r--r--avr/env.c3
-rw-r--r--avr/getopt-min.c2
-rw-r--r--avr/main.c3
-rw-r--r--include/cmd_misc.h1
12 files changed, 37 insertions, 37 deletions
diff --git a/avr/cmd_attach.c b/avr/cmd_attach.c
index 0949687..651404f 100644
--- a/avr/cmd_attach.c
+++ b/avr/cmd_attach.c
@@ -49,9 +49,6 @@ command_ret_t do_attach(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * co
return CMD_RET_SUCCESS;
}
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("darwo:"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_boot.c b/avr/cmd_boot.c
index e26a8b1..dcf834d 100644
--- a/avr/cmd_boot.c
+++ b/avr/cmd_boot.c
@@ -106,9 +106,6 @@ command_ret_t do_bootcf(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int a
memcpy_P(&boot_param, cfboot, sizeof boot_param);
default_stages = boot_param.stages;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("vna:s:c:t:i:"))) != -1) {
switch (opt) {
@@ -256,9 +253,6 @@ command_ret_t do_go(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc,
uint32_t addr;
bool hold = 0;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("h"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_cpu.c b/avr/cmd_cpu.c
index 61e3ec3..f343885 100644
--- a/avr/cmd_cpu.c
+++ b/avr/cmd_cpu.c
@@ -225,9 +225,6 @@ command_ret_t do_cpu_test(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int
uint32_t pulsewidth = 10; /* ms */
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
@@ -258,8 +255,6 @@ command_ret_t do_bus_test(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int
char ch;
#if 0
- /* reset getopt() */
- optind = 0;
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
@@ -363,9 +358,6 @@ command_ret_t do_cpu_freq(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int
uint8_t mem_save[ARRAY_SIZE(loop_code)];
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("swnuc:t:"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_gpio.c b/avr/cmd_gpio.c
index 65a71be..549654f 100644
--- a/avr/cmd_gpio.c
+++ b/avr/cmd_gpio.c
@@ -173,9 +173,6 @@ command_ret_t do_gpio(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int arg
uint_fast8_t pinarg[GPIO_MAX];
uint_fast8_t pinargc;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("s"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_mem.c b/avr/cmd_mem.c
index d641410..3e18770 100644
--- a/avr/cmd_mem.c
+++ b/avr/cmd_mem.c
@@ -204,9 +204,6 @@ command_ret_t do_mem_mw(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * co
(void) cmdtp; (void) flag;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("bwl"))) != -1) {
switch (opt) {
@@ -261,7 +258,6 @@ command_ret_t do_mem_mdc ( cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char *
(void) cmdtp;
(void) flag;
- optind = 0;
if (argv[0][1] != 'd') {
int opt;
while ((opt = getopt(argc, argv, PSTR("bwl"))) != -1)
diff --git a/avr/cmd_misc.c b/avr/cmd_misc.c
index a88ba72..ad913e8 100644
--- a/avr/cmd_misc.c
+++ b/avr/cmd_misc.c
@@ -22,9 +22,6 @@ command_ret_t do_echo(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * cons
(void) cmdtp; (void) flag;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("n"))) != -1) {
switch (opt) {
@@ -86,3 +83,28 @@ command_ret_t do_sleep(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * con
return CMD_RET_SUCCESS;
}
+
+command_ret_t do_time(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc, char * const argv[])
+{
+ uint32_t elapsed_ms = 0;
+ command_ret_t retval;
+ uint_fast8_t repeatable;
+
+ if (argc == 1)
+ return CMD_RET_USAGE;
+
+ elapsed_ms = get_timer(0);
+ retval = cmd_process(0, argc - 1, argv + 1, &repeatable);
+ elapsed_ms = get_timer(elapsed_ms);
+
+ uint32_t min;
+ uint16_t sec, ms;
+
+ min = elapsed_ms / 1000 / 60;
+ sec = (elapsed_ms / 1000) % 60;
+ ms = elapsed_ms % 1000;
+
+ printf_P(PSTR("\ntime: %lum%u.%03us\n"), min, sec, ms);
+
+ return retval;
+}
diff --git a/avr/command.c b/avr/command.c
index ff3a685..8eb5bb7 100644
--- a/avr/command.c
+++ b/avr/command.c
@@ -262,9 +262,6 @@ command_ret_t do_help(cmd_tbl_t *cmdtp, uint_fast8_t flag UNUSED, int argc, char
#define OPT_USAGE 0x08
#define OPT_LONG 0x10
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("afk"))) != -1) {
switch (opt) {
@@ -708,7 +705,7 @@ static cmd_tbl_t *cmd_invocation_ptr;
* @param argv Arguments
* @return 0 if command succeeded, else non-zero (CMD_RET_...)
*/
-command_ret_t cmd_call(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
+static command_ret_t cmd_call(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
{
command_ret_t result;
@@ -770,6 +767,7 @@ command_ret_t cmd_process(uint_fast8_t flag, int argc, char * const argv[],
/* If OK so far, then do the command */
if (!rc) {
+ optind = 0; /* reset getopt() */
cmd_invocation_ptr = cmdtp;
rc = cmd_call(cmdtp, flag, argc, argv);
*repeatable &= (cmdtp->flags & CTBL_RPT) != 0;
diff --git a/avr/command_tbl.c b/avr/command_tbl.c
index c526199..5a63e76 100644
--- a/avr/command_tbl.c
+++ b/avr/command_tbl.c
@@ -34,6 +34,11 @@ CMD_TBL_ITEM_TOP(
CMD_TBL_ITEM(
+ time, CONFIG_SYS_MAXARGS, 0, do_time,
+ "run command and print execution time",
+ "command [args...]\n"
+),
+CMD_TBL_ITEM(
date, 2, 1, do_date,
"get/set date & time",
"[MMDDhhmm[[CC]YY][.ss]]\n"
@@ -106,7 +111,7 @@ CMD_TBL_ITEM(
sleep , 2, 1, do_sleep,
"delay execution for some time",
"N[m][s]\n"
- " - delay execution for decimal N (milli) seconds"
+ " - delay execution for hexadecimal N (milli) seconds"
),
CMD_TBL_ITEM_COMPLETE(
run, CONFIG_SYS_MAXARGS, 1, do_run,
diff --git a/avr/env.c b/avr/env.c
index add281c..3bb04c2 100644
--- a/avr/env.c
+++ b/avr/env.c
@@ -693,9 +693,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) {
diff --git a/avr/getopt-min.c b/avr/getopt-min.c
index 8508f40..401beed 100644
--- a/avr/getopt-min.c
+++ b/avr/getopt-min.c
@@ -13,7 +13,7 @@
#include "common.h" /* definition of FLASH */
#include <string.h>
-int optind = 0; /* next argv[] index */
+int optind; /* next argv[] index */
char *optarg; /* option parameter if any */
diff --git a/avr/main.c b/avr/main.c
index 486e15c..486d992 100644
--- a/avr/main.c
+++ b/avr/main.c
@@ -84,7 +84,8 @@ void print_reset_reason(void)
ISR(INT5_vect)
{
- Stat |= S_MSG_PENDING + S_IO_0X40;
+ Stat |= S_MSG_PENDING;
+ Stat |= S_IO_0X40;
}
ISR(INT6_vect)
diff --git a/include/cmd_misc.h b/include/cmd_misc.h
index f0f56a7..8dd7d56 100644
--- a/include/cmd_misc.h
+++ b/include/cmd_misc.h
@@ -11,5 +11,6 @@
command_ret_t do_echo(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
command_ret_t do_sleep(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+command_ret_t do_time(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
#endif /* CMD_MISC_H */