summaryrefslogtreecommitdiff
path: root/chip/stm32/usart_info_command.c
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2015-07-28 15:11:28 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-24 19:08:30 +0000
commit16f63703c9ccc46ec48abcc586a595456e99fc9a (patch)
tree17dc3fa9b72217675e64507facddb7395e91390c /chip/stm32/usart_info_command.c
parentf7fa6248bf170d2fffbf3fb067b6ed40f0a4d55f (diff)
downloadchrome-ec-16f63703c9ccc46ec48abcc586a595456e99fc9a.tar.gz
USART: Add usart_info command
This optional console command is enabled with CONFIG_USART_INFO_COMMAND. It will display and clear dropped character and overrun counts for all configured USARTs. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: Icf6061aaab2cda71e9d317455c897828b9daf844 Reviewed-on: https://chromium-review.googlesource.com/292770 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'chip/stm32/usart_info_command.c')
-rw-r--r--chip/stm32/usart_info_command.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/chip/stm32/usart_info_command.c b/chip/stm32/usart_info_command.c
new file mode 100644
index 0000000000..7b949b10c6
--- /dev/null
+++ b/chip/stm32/usart_info_command.c
@@ -0,0 +1,38 @@
+/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Console command to query USART state
+ */
+#include "atomic.h"
+#include "common.h"
+#include "console.h"
+#include "usart.h"
+
+static int command_usart_info(int argc, char **argv)
+{
+ struct usart_configs configs = usart_get_configs();
+ size_t i;
+
+ for (i = 0; i < configs.count; i++) {
+ struct usart_config const *config = configs.configs[i];
+
+ if (config == NULL)
+ continue;
+
+ ccprintf("USART%d\n"
+ " dropped %d bytes\n"
+ " overran %d times\n",
+ config->hw->index + 1,
+ atomic_read_clear(&(config->state->rx_dropped)),
+ atomic_read_clear(&(config->state->rx_overrun)));
+ }
+
+ return EC_SUCCESS;
+}
+
+DECLARE_CONSOLE_COMMAND(usart_info,
+ command_usart_info,
+ NULL,
+ "Display USART info",
+ NULL);