3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
15 static int do_sleep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
17 ulong start = get_timer(0);
25 delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ;
27 frpart = strchr(argv[1], '.');
30 uint mult = CONFIG_SYS_HZ / 10;
31 for (frpart++; *frpart != '\0' && mult > 0; frpart++) {
32 if (*frpart < '0' || *frpart > '9') {
36 mdelay += (*frpart - '0') * mult;
43 while (get_timer(start) < delay) {
54 sleep , 2, 1, do_sleep,
55 "delay execution for some time",
57 " - delay execution for N seconds (N is _decimal_ and can be\n"
61 #ifdef CONFIG_CMD_TIMER
62 static int do_timer(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
69 if (!strcmp(argv[1], "start"))
72 if (!strcmp(argv[1], "get")) {
73 ulong msecs = get_timer(start) * 1000 / CONFIG_SYS_HZ;
74 printf("%ld.%03d\n", msecs / 1000, (int)(msecs % 1000));
81 timer, 2, 1, do_timer,
82 "access the system timer",
83 "start - Reset the timer reference.\n"
84 "timer get - Print the time since 'start'."