4 Copyright Luki <humbell@ethz.ch>
5 Copyright 2011 Michel Pollet <buserror@gmail.com>
7 This file is part of simavr.
9 simavr is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 simavr is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with simavr. If not, see <http://www.gnu.org/licenses/>.
28 static avr_cycle_count_t
29 switch_auto(struct avr_t * avr,
30 avr_cycle_count_t when, void * param)
32 ac_input_t * b = (ac_input_t *) param;
34 avr_raise_irq(b->irq + IRQ_AC_OUT, b->value);
35 return when + avr_usec_to_cycles(avr, 100000 / 50);
38 void ac_input_init(avr_t *avr, ac_input_t *b)
40 const char * name = ">ac_input";
41 b->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_AC_COUNT, &name);
44 avr_cycle_timer_register_usec(avr, 100000 / 50, switch_auto, b);
45 printf("ac_input_init period %duS or %d cycles\n",
46 100000 / 50, (int)avr_usec_to_cycles(avr, 100000 / 50));