summaryrefslogtreecommitdiff
path: root/cts/common/dut_common.c
blob: f8c18fd81c5ae6cb0fb54cf9b0859a3145031b4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}