From e14f07bfdb8824fc7ed6df1129c66ee39ffd6d54 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 12 Apr 2009 23:17:16 -0700 Subject: Add A/D sampler Sample A/D at the timer tick, placing data in a ring of samples. Signed-off-by: Keith Packard --- ao_test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ao_test.c') diff --git a/ao_test.c b/ao_test.c index 35a019fa..05245359 100644 --- a/ao_test.c +++ b/ao_test.c @@ -43,9 +43,15 @@ blink_0(void) void blink_1(void) { + static struct ao_adc adc; + for (;;) { - P1 ^= 2; - ao_delay(20); + ao_sleep(&ao_adc_ring); + ao_adc_get(&adc); + if (adc.accel < 15900) + P1_1 = 1; + else + P1_1 = 0; } } @@ -68,6 +74,9 @@ main(void) /* Set p1_1 and p1_0 to output */ P1DIR = 0x03; + ao_adc_init(); + ao_timer_init(); + ao_add_task(&blink_0_task, blink_0); ao_add_task(&blink_1_task, blink_1); ao_add_task(&wakeup_task, wakeup); -- cgit v1.2.3