diff options
Diffstat (limited to 'cts/common')
-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 |
5 files changed, 118 insertions, 0 deletions
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 |