#include "sim_time.h"
#include "ac_input.h"
+#define USECS_PER_SECOND (1000 * 1000)
+#define HZ (50)
+
static avr_cycle_count_t
switch_auto(
struct avr_t * avr,
ac_input_t * b = (ac_input_t *) param;
b->value = !b->value;
avr_raise_irq(b->irq + IRQ_AC_OUT, b->value);
- return when + avr_usec_to_cycles(avr, 100000 / 50);
+ return when + avr_usec_to_cycles(avr, USECS_PER_SECOND / HZ);
}
static const char * name = ">ac_input";
b->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_AC_COUNT, &name);
b->avr = avr;
b->value = 0;
- avr_cycle_timer_register_usec(avr, 100000 / 50, switch_auto, b);
+ avr_cycle_timer_register_usec(avr, USECS_PER_SECOND / HZ, switch_auto, b);
printf("ac_input_init period %duS or %d cycles\n",
- 100000 / 50, (int)avr_usec_to_cycles(avr, 100000 / 50));
+ USECS_PER_SECOND / HZ,
+ (int)avr_usec_to_cycles(avr, USECS_PER_SECOND / HZ));
}