diff options
author | Chris Chen <twothreecc@google.com> | 2016-07-11 10:36:24 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-12 11:04:41 -0700 |
commit | 1b8fa6dbe41850a48c1271be3cf9d260b05f4c52 (patch) | |
tree | 2c48662b495ecb747122e09490746f0d2a2ac553 | |
parent | 730c7c469fc06264a67280a62185bfc9f06d88a6 (diff) | |
download | chrome-ec-1b8fa6dbe41850a48c1271be3cf9d260b05f4c52.tar.gz |
cts: Added sync() function
sync() involves 2 gpios on each board, each labeled
GPIO_HANDSHAKE_OUTPUT and GPIO_HANDSHAKE_INPUT on
their respective boards. They both start low,
then the th wiggles his line up and down, waiting
for the dut to mimic it.
BRANCH=None
BUG=None
TEST=manual
- Connect handshake lines to appropriate
pins on each board (pins found
in board's gpio.inc)
- Build tests
- Flash boards
- run 'cat /dev/ttyACM0' in one terminal
- run 'cat /dev/ttyACM1' in another
- They should each have printed
'successful sync'
Change-Id: I61233bca9605ba89c3628c2a65ca9013c56365ea
Reviewed-on: https://chromium-review.googlesource.com/359355
Commit-Ready: Chris Chen <twothreecc@google.com>
Tested-by: Chris Chen <twothreecc@google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | board/nucleo-f072rb/gpio.inc | 6 | ||||
-rw-r--r-- | board/stm32l476g-eval/gpio.inc | 8 | ||||
-rw-r--r-- | cts/build.mk | 2 | ||||
-rw-r--r-- | cts/common/cts_common.h | 26 | ||||
-rw-r--r-- | cts/common/dut_common.c | 31 | ||||
-rw-r--r-- | cts/common/dut_common.h | 13 | ||||
-rw-r--r-- | cts/common/th_common.c | 35 | ||||
-rw-r--r-- | cts/common/th_common.h | 13 | ||||
-rw-r--r-- | cts/gpio/dut.c | 8 | ||||
-rw-r--r-- | cts/gpio/th.c | 8 |
10 files changed, 149 insertions, 1 deletions
diff --git a/board/nucleo-f072rb/gpio.inc b/board/nucleo-f072rb/gpio.inc index 26f532f39f..91f8252e7f 100644 --- a/board/nucleo-f072rb/gpio.inc +++ b/board/nucleo-f072rb/gpio.inc @@ -18,3 +18,9 @@ UNIMPLEMENTED(ENTERING_RW) UNIMPLEMENTED(WP_L) ALTERNATE(PIN_MASK(A, 0x000C), 1, MODULE_UART, 0) /* USART2: PA2/PA3 */ + +#ifdef CTS_MODULE +/* CTS Signals */ +GPIO(HANDSHAKE_INPUT, PIN(A, 4), GPIO_INPUT | GPIO_PULL_UP) +GPIO(HANDSHAKE_OUTPUT, PIN(B, 0), GPIO_ODR_LOW) +#endif diff --git a/board/stm32l476g-eval/gpio.inc b/board/stm32l476g-eval/gpio.inc index f0599365aa..210c618e4c 100644 --- a/board/stm32l476g-eval/gpio.inc +++ b/board/stm32l476g-eval/gpio.inc @@ -17,4 +17,10 @@ UNIMPLEMENTED(ENTERING_RW) UNIMPLEMENTED(WP_L) ALTERNATE(PIN_MASK(B, 0xC0), GPIO_ALT_F7, MODULE_UART, 0) /* USART1: PB6/7 */ -ALTERNATE(PIN_MASK(G, 0x0180), GPIO_ALT_F8, MODULE_UART, 0) /* LPUART: PG7/8 */
\ No newline at end of file +ALTERNATE(PIN_MASK(G, 0x0180), GPIO_ALT_F8, MODULE_UART, 0) /* LPUART: PG7/8 */ + +#ifdef CTS_MODULE +/* CTS Signals */ +GPIO(HANDSHAKE_OUTPUT, PIN(D, 2), GPIO_ODR_LOW) +GPIO(HANDSHAKE_INPUT, PIN(C, 12), GPIO_INPUT | GPIO_PULL_UP) +#endif diff --git a/cts/build.mk b/cts/build.mk index af01cfb102..6766a9fb4c 100644 --- a/cts/build.mk +++ b/cts/build.mk @@ -5,6 +5,8 @@ ifeq ($(BOARD),stm32l476g-eval) cts-y+=$(CTS_MODULE)/th.o + cts-y+=common/th_common.o else cts-y+=$(CTS_MODULE)/dut.o + cts-y+=common/dut_common.o endif
\ No newline at end of file diff --git a/cts/common/cts_common.h b/cts/common/cts_common.h new file mode 100644 index 0000000000..eed93dccea --- /dev/null +++ b/cts/common/cts_common.h @@ -0,0 +1,26 @@ +/* Copyright 2016 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. + */ + +#ifndef __CTS_COMMON_H +#define __CTS_COMMON_H + +#include "console.h" + +/* Console output macros */ +#define CPUTS(outstr) cputs(CC_SYSTEM, outstr) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) + +/* In a single test, only one board can return unknown, the other must + * return a useful result (i.e. success, failure, etc) + */ +enum cts_error_code { + SUCCESS, + FAILURE, + BAD_SYNC, + UNKNOWN +}; + +#endif diff --git a/cts/common/dut_common.c b/cts/common/dut_common.c new file mode 100644 index 0000000000..f8c18fd81c --- /dev/null +++ b/cts/common/dut_common.c @@ -0,0 +1,31 @@ +/* Copyright 2016 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. + */ + +#include "gpio.h" +#include "timer.h" +#include "watchdog.h" +#include "cts_common.h" + +/* Returns unknown because TH could potentially still get stuck + * even if the DUT completes the sync + */ +enum cts_error_code sync(void) +{ + int input_level; + + gpio_set_level(GPIO_HANDSHAKE_OUTPUT, 0); + do { + watchdog_reload(); + input_level = gpio_get_level(GPIO_HANDSHAKE_INPUT); + } while (!input_level); + gpio_set_level(GPIO_HANDSHAKE_OUTPUT, 1); + do { + watchdog_reload(); + input_level = gpio_get_level(GPIO_HANDSHAKE_INPUT); + } while (input_level); + gpio_set_level(GPIO_HANDSHAKE_OUTPUT, 0); + + return UNKNOWN; +} diff --git a/cts/common/dut_common.h b/cts/common/dut_common.h new file mode 100644 index 0000000000..bd844499be --- /dev/null +++ b/cts/common/dut_common.h @@ -0,0 +1,13 @@ +/* Copyright 2016 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. + */ + +#ifndef __DUT_COMMON_H +#define __DUT_COMMON_H + +#include "cts_common.h" + +enum cts_error_code sync(void); + +#endif diff --git a/cts/common/th_common.c b/cts/common/th_common.c new file mode 100644 index 0000000000..1c75ef9dee --- /dev/null +++ b/cts/common/th_common.c @@ -0,0 +1,35 @@ +/* Copyright 2016 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. + */ + +#include "gpio.h" +#include "timer.h" +#include "watchdog.h" +#include "cts_common.h" + +/* Return SUCCESS if and only if we reach end of function + * Returning success here means sync was successful + */ +enum cts_error_code sync(void) +{ + int input_level; + + gpio_set_level(GPIO_HANDSHAKE_OUTPUT, 0); + do { + watchdog_reload(); + input_level = gpio_get_level(GPIO_HANDSHAKE_INPUT); + } while (input_level); + gpio_set_level(GPIO_HANDSHAKE_OUTPUT, 1); + do { + watchdog_reload(); + input_level = gpio_get_level(GPIO_HANDSHAKE_INPUT); + } while (!input_level); + gpio_set_level(GPIO_HANDSHAKE_OUTPUT, 0); + do { + watchdog_reload(); + input_level = gpio_get_level(GPIO_HANDSHAKE_INPUT); + } while (input_level); + + return SUCCESS; +} diff --git a/cts/common/th_common.h b/cts/common/th_common.h new file mode 100644 index 0000000000..0495e1048e --- /dev/null +++ b/cts/common/th_common.h @@ -0,0 +1,13 @@ +/* Copyright 2016 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. + */ + +#ifndef __TH_COMMON_H +#define __TH_COMMON_H + +#include "cts_common.h" + +enum cts_error_code sync(void); + +#endif diff --git a/cts/gpio/dut.c b/cts/gpio/dut.c index bdcd4938f7..7120a4da3e 100644 --- a/cts/gpio/dut.c +++ b/cts/gpio/dut.c @@ -3,11 +3,19 @@ * found in the LICENSE file. */ +#include "common.h" +#include "watchdog.h" +#include "uart.h" #include "timer.h" #include "watchdog.h" +#include "dut_common.h" +#include "cts_common.h" void cts_task(void) { + sync(); + CPRINTS("Successful Sync!"); + uart_flush_output(); while (1) { watchdog_reload(); sleep(1); diff --git a/cts/gpio/th.c b/cts/gpio/th.c index bdcd4938f7..7120a4da3e 100644 --- a/cts/gpio/th.c +++ b/cts/gpio/th.c @@ -3,11 +3,19 @@ * found in the LICENSE file. */ +#include "common.h" +#include "watchdog.h" +#include "uart.h" #include "timer.h" #include "watchdog.h" +#include "dut_common.h" +#include "cts_common.h" void cts_task(void) { + sync(); + CPRINTS("Successful Sync!"); + uart_flush_output(); while (1) { watchdog_reload(); sleep(1); |