Files
OpenCellular/test/timer_dos.c
Randall Spangler a61d8db3d3 Change task messages to events
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7461
TEST=manual

make BOARD={bds,link,daisy}
make tests
flash link system and make sure it boots

Change-Id: I1241a1895c083e387e38ddab01ac346ca4474eb9
2012-04-06 09:06:53 -07:00

39 lines
817 B
C

/* Copyright (c) 2012 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.
*
* Tasks for timer test.
*/
#include "common.h"
#include "uart.h"
#include "task.h"
#include "timer.h"
/* Linear congruential pseudo random number generator*/
static uint32_t prng(uint32_t x)
{
return 22695477 * x + 1;
}
/* period between 500us and 128ms */
#define PERIOD_US(num) (((num % 256) + 1) * 500)
int TaskTimer(void *seed)
{
uint32_t num = (uint32_t)seed;
task_id_t id = task_get_current();
uart_printf("\n[Timer task %d]\n", id);
while (1) {
/* Wait for a "random" period */
task_wait_event(PERIOD_US(num));
uart_printf("%01d\n", id);
/* next pseudo random delay */
num = prng(num);
}
return EC_SUCCESS;
}