From 0747f5816c680502f9b8a314795fd341d0ce6166 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 16 May 2023 10:58:06 +0200 Subject: [PATCH] sys/shell: Add coreclk command to shell_cmd_sys The coreclk shell command now prints the CPU frequency in Hz, which can be useful for boards with RC generated CPU frequency (e.g. RP2040, FE310, or MPS430Fx1xx MCUs allow this) which may quite a bit off the target frequency. --- makefiles/pseudomodules.inc.mk | 1 + sys/shell/cmds/Kconfig | 5 +++++ sys/shell/cmds/coreclk.c | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 sys/shell/cmds/coreclk.c diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 639e804fbb..24f3228f02 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -448,6 +448,7 @@ PSEUDOMODULES += shell_cmd_benchmark_udp PSEUDOMODULES += shell_cmd_ccn-lite-utils PSEUDOMODULES += shell_cmd_conn_can PSEUDOMODULES += shell_cmd_cord_ep +PSEUDOMODULES += shell_cmd_coreclk PSEUDOMODULES += shell_cmd_cryptoauthlib PSEUDOMODULES += shell_cmd_dfplayer PSEUDOMODULES += shell_cmd_fib diff --git a/sys/shell/cmds/Kconfig b/sys/shell/cmds/Kconfig index e43852bdc4..794bca53d0 100644 --- a/sys/shell/cmds/Kconfig +++ b/sys/shell/cmds/Kconfig @@ -308,6 +308,11 @@ config MODULE_SHELL_CMD_SYS default y if MODULE_SHELL_CMDS_DEFAULT depends on MODULE_SHELL_CMDS +config MODULE_SHELL_CMD_CORECLK + bool "Shell command printing the CPU frequency" + default n + depends on MODULE_SHELL_CMDS + config MODULE_SHELL_CMD_VFS bool "Commands for the VFS module (ls, vfs)" default y if MODULE_SHELL_CMDS_DEFAULT diff --git a/sys/shell/cmds/coreclk.c b/sys/shell/cmds/coreclk.c new file mode 100644 index 0000000000..cc9c563341 --- /dev/null +++ b/sys/shell/cmds/coreclk.c @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Otto-von-Guericke Universität Magdeburg + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup sys_shell_commands + * @{ + * + * @file + * @brief Shell command printing the CPU frequency + * + * @author Marian Buschsieweke + * + * @} + */ + +#include +#include +#include + +#include "clk.h" +#include "shell.h" + +static int _coreclk(int argc, char **argv) +{ + (void)argc; + (void)argv; + printf("core clock: %" PRIu32 " Hz\n", coreclk()); + return 0; +} + +SHELL_COMMAND(coreclk, "Print the CPU frequency", _coreclk);