summaryrefslogtreecommitdiff
path: root/board/discovery-stm32f072
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2015-06-08 10:40:43 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-11 00:08:49 +0000
commitbd7e885ae780493e37a58418a6f0197a4a3b951a (patch)
tree218facf95bb3ccc6510139f00bbabee4858b6166 /board/discovery-stm32f072
parent7fab87e488f58e98dc3669b45eb068be8181ff77 (diff)
downloadchrome-ec-bd7e885ae780493e37a58418a6f0197a4a3b951a.tar.gz
Stream: Remove in_stream/out_stream interface
The in_stream and out_stream interfaces were a first attempt at providing an abstraction for multiple stream like devices (usart, USB, I2C/LPC host interfaces...). But, by baking the queue into the device it proved to be hard to use and required additional resources (task or deferred hook) to handle passing data from one stream to another. Since then the queue policy and producer/consumer interfaces have replaced the stream interfaces. This CL removes the old stream interfaces and updates the only users (deleting the test echo code from the discovery-stm32f072 board and updating the mcdp28x0 driver to use the queue interfaces). Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: Ic0d2abf81eafc4fb2e61172540151f2d0ba45caf Reviewed-on: https://chromium-review.googlesource.com/276163 Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'board/discovery-stm32f072')
-rw-r--r--board/discovery-stm32f072/board.h1
-rw-r--r--board/discovery-stm32f072/build.mk2
-rw-r--r--board/discovery-stm32f072/ec.tasklist3
-rw-r--r--board/discovery-stm32f072/echo.c175
4 files changed, 2 insertions, 179 deletions
diff --git a/board/discovery-stm32f072/board.h b/board/discovery-stm32f072/board.h
index 025c72de48..e8a83a47e7 100644
--- a/board/discovery-stm32f072/board.h
+++ b/board/discovery-stm32f072/board.h
@@ -12,7 +12,6 @@
#define CPU_CLOCK 48000000
/* Enable USART1,3,4 and USB streams */
-#define CONFIG_STREAM
#define CONFIG_STREAM_USART
#define CONFIG_STREAM_USART1
#define CONFIG_STREAM_USART3
diff --git a/board/discovery-stm32f072/build.mk b/board/discovery-stm32f072/build.mk
index d8a22a6ad5..f3d39ab655 100644
--- a/board/discovery-stm32f072/build.mk
+++ b/board/discovery-stm32f072/build.mk
@@ -10,4 +10,4 @@ CHIP:=stm32
CHIP_FAMILY:=stm32f0
CHIP_VARIANT:=stm32f07x
-board-y=board.o echo.o
+board-y=board.o
diff --git a/board/discovery-stm32f072/ec.tasklist b/board/discovery-stm32f072/ec.tasklist
index 6a623f151c..fa284f1a0c 100644
--- a/board/discovery-stm32f072/ec.tasklist
+++ b/board/discovery-stm32f072/ec.tasklist
@@ -18,5 +18,4 @@
*/
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(ECHO, echo_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE)
diff --git a/board/discovery-stm32f072/echo.c b/board/discovery-stm32f072/echo.c
deleted file mode 100644
index 63a0360d94..0000000000
--- a/board/discovery-stm32f072/echo.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* Copyright (c) 2014 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.
- */
-/*
- * Task to echo any characters from the three non-console USARTs back to all
- * non-console USARTs.
- */
-
-#include "atomic.h"
-#include "common.h"
-#include "compile_time_macros.h"
-#include "console.h"
-#include "panic.h"
-#include "task.h"
-#include "queue_policies.h"
-#include "stream_adaptor.h"
-#include "timer.h"
-#include "usart-stm32f0.h"
-#include "usb-stream.h"
-#include "util.h"
-
-static void in_ready(struct in_stream const *stream)
-{
- task_wake(TASK_ID_ECHO);
-}
-
-static void out_ready(struct out_stream const *stream)
-{
- task_wake(TASK_ID_ECHO);
-}
-
-/*
- * Forward declare all device configurations so that they can be used to
- * construct appropriate queue policies within the IO_STREAM_CONFIG macro.
- */
-struct usart_config const usart1;
-struct usart_config const usart3;
-struct usart_config const usart4;
-struct usb_stream_config const usb_stream1;
-
-IO_STREAM_CONFIG(usart1, 64, 64, in_ready, NULL)
-IO_STREAM_CONFIG(usart3, 64, 64, in_ready, NULL)
-IO_STREAM_CONFIG(usart4, 64, 64, in_ready, NULL)
-IO_STREAM_CONFIG(usb_stream1, 256, 256, in_ready, out_ready)
-
-USART_CONFIG(usart1, usart1_hw, 115200, usart1_rx_queue, usart1_tx_queue)
-USART_CONFIG(usart3, usart3_hw, 115200, usart3_rx_queue, usart3_tx_queue)
-USART_CONFIG(usart4, usart4_hw, 115200, usart4_rx_queue, usart4_tx_queue)
-
-USB_STREAM_CONFIG(usb_stream1,
- USB_IFACE_STREAM,
- USB_STR_STREAM_NAME,
- USB_EP_STREAM,
- 64,
- 64,
- usb_stream1_rx_queue,
- usb_stream1_tx_queue)
-
-struct stream_console_state {
- size_t wrote;
-};
-
-struct stream_console_config {
- struct stream_console_state *state;
-
- struct in_stream const *in;
- struct out_stream const *out;
-};
-
-#define STREAM_CONSOLE_CONFIG(IN, OUT) { \
- .state = &((struct stream_console_state){}), \
- .in = IN, \
- .out = OUT, \
- }
-
-static struct stream_console_config const consoles[] = {
- STREAM_CONSOLE_CONFIG(&usart1_in.in, &usart1_out.out),
- STREAM_CONSOLE_CONFIG(&usart3_in.in, &usart3_out.out),
- STREAM_CONSOLE_CONFIG(&usart4_in.in, &usart4_out.out),
- STREAM_CONSOLE_CONFIG(&usb_stream1_in.in, &usb_stream1_out.out)
-};
-
-static size_t echo(struct stream_console_config const consoles[],
- size_t consoles_count)
-{
- size_t total = 0;
- size_t i;
-
- for (i = 0; i < consoles_count; ++i) {
- size_t j;
- uint8_t buffer[64];
- size_t remaining = 0;
- size_t count = in_stream_read(consoles[i].in,
- buffer,
- sizeof(buffer));
-
- if (count == 0)
- continue;
-
- for (j = 0; j < consoles_count; ++j)
- consoles[j].state->wrote = 0;
-
- do {
- remaining = 0;
-
- for (j = 0; j < consoles_count; ++j) {
- size_t wrote = consoles[j].state->wrote;
-
- if (count == wrote)
- continue;
-
- wrote += out_stream_write(consoles[j].out,
- buffer + wrote,
- count - wrote);
-
- consoles[j].state->wrote = wrote;
-
- remaining += count - wrote;
- }
- } while (remaining);
-
- total += count;
- }
-
- return total;
-}
-
-void echo_task(void)
-{
- usart_init(&usart1);
- usart_init(&usart3);
- usart_init(&usart4);
-
- while (1) {
- while (echo(consoles, ARRAY_SIZE(consoles))) {
- /*
- * Make sure other tasks, like the HOOKS get to run.
- */
- msleep(1);
- }
-
- /*
- * There was nothing left to echo, go to sleep and be
- * woken up by the next input.
- */
- task_wait_event(-1);
- }
-}
-
-static int command_echo_info(int argc, char **argv)
-{
- char const message[] = "Hello World!\r\n";
- size_t i;
-
- ccprintf("USART1 RX dropped %d bytes\n",
- atomic_read_clear((uint32_t *) &(usart1.state->rx_dropped)));
-
- ccprintf("USART3 RX dropped %d bytes\n",
- atomic_read_clear((uint32_t *) &(usart3.state->rx_dropped)));
-
- ccprintf("USART4 RX dropped %d bytes\n",
- atomic_read_clear((uint32_t *) &(usart4.state->rx_dropped)));
-
- for (i = 0; i < ARRAY_SIZE(consoles); ++i)
- out_stream_write(consoles[i].out, message, strlen(message));
-
- return EC_SUCCESS;
-}
-
-DECLARE_CONSOLE_COMMAND(echo_info,
- command_echo_info,
- NULL,
- "Dump echo task debug info",
- NULL);