Files
OpenCellular/cts/timer/dut.c
Daisuke Nojiri b517067a41 cts: Add timer test
The timer test checks the accuracy of the internal timer. After sync,
DUT and TH start counting down one second. After one second, DUT raises
GPIO level.  TH determines whether the test passes or not based on how
much more or less time elapsed than one second, assuming its clock is
calibrated.

This test takes advantage of TH running on a bare chip. If the host
were measuring (instead of TH), the timing would be affected by many
software and hardware layers (e.g. UART drivers on DUT and host,
python interpreter, etc.).

BUG=chromium:624520
BRANCH=none
TEST=cts.py --module timer && cts.py --module gpio && make buildall

Change-Id: I535e7772b4d93f1f5d248506f7ea167429a50174
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361384
2016-07-29 15:02:44 -07:00

45 lines
782 B
C

/* 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 "common.h"
#include "dut_common.h"
#include "gpio.h"
#include "timer.h"
#include "watchdog.h"
static enum cts_rc timer_calibration_test(void)
{
gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_HIGH);
sync();
usleep(SECOND);
gpio_set_level(GPIO_OUTPUT_TEST, 0);
return CTS_RC_SUCCESS;
}
#include "cts_testlist.h"
void cts_task(void)
{
enum cts_rc rc;
int i;
for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
sync();
rc = tests[i].run();
CPRINTF("\n%s %d\n", tests[i].name, rc);
cflush();
}
CPRINTS("Timer test suite finished");
cflush();
while (1) {
watchdog_reload();
sleep(1);
}
}