diff options
author | Keith Packard <keithp@keithp.com> | 2009-04-12 23:17:16 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-04-12 23:17:16 -0700 |
commit | e14f07bfdb8824fc7ed6df1129c66ee39ffd6d54 (patch) | |
tree | bd0baa50ee2d25fe88dbbe8710a2ef9ee177d48d /ao_test.c | |
parent | 823f4f92de0c1f8dd7a644a8e56ffe9822bee6e2 (diff) |
Add A/D sampler
Sample A/D at the timer tick, placing data in a ring
of samples.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao_test.c')
-rw-r--r-- | ao_test.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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); |