2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 static uint8_t sensor_value;
22 static uint8_t vidtime_monitor;
27 ao_exti_enable(AO_SENSOR_PORT, AO_SENSOR_PIN);
29 while (!vidtime_monitor)
30 ao_sleep(&vidtime_monitor);
31 ao_sleep(&sensor_value);
32 printf("%d\n", sensor_value);
38 sensor_interrupt(void)
40 uint8_t new = ao_gpio_get(AO_SENSOR_PORT, AO_SENSOR_PIN, foo);
44 ao_exti_set_mode(AO_SENSOR_PORT, AO_SENSOR_PIN,
45 AO_EXTI_MODE_FALLING);
47 ao_exti_set_mode(AO_SENSOR_PORT, AO_SENSOR_PIN,
50 if (new != sensor_value) {
52 ao_wakeup(&sensor_value);
56 static struct ao_task vidtime_task;
61 ao_enable_port(AO_SENSOR_PORT);
62 ao_exti_setup(AO_SENSOR_PORT, AO_SENSOR_PIN,
65 AO_EXTI_MODE_PULL_NONE|
68 ao_add_task(&vidtime_task, vidtime, "vidtime");
75 if (ao_cmd_status == ao_cmd_success) {
76 vidtime_monitor = ao_cmd_lex_i != 0;
77 ao_wakeup(&vidtime_monitor);
81 const struct ao_cmds ao_vidtime_cmds[] = {
82 { ao_set_vidtime, "V <0 off, 1 on>\0Enable/disable timing monitor" },
102 ao_cmd_register(&ao_vidtime_cmds[0]);
104 ao_start_scheduler();