示例#1
0
static void
ow_timer_init(void)
{
    timer1_mode_normal();
    timer1_clock_off();
    timer1_count_set(0);
    timer1_compare_a_set(0xffff);
    timer1_interrupt_a_enable();
}
示例#2
0
static void
ow_delay_us(uint16_t usec)
{
    timer1_count_set(0);
    /* d8 with 16 MHz -> 0.5 usec resolution. */
    /* Thus max. wait 65535*0.5usec = 32.768 msec */
    timer1_compare_a_set(2*usec);
    timer1_clock_d8();
}
示例#3
0
static void
ow_delay_ms(uint16_t msec)
{
    /* For now, assume the timer is already stopped. */
    timer1_count_set(0);
    /* d1024 with 16 MHz -> 64 usec resolution. */
    /* Thus max. wait 65535*64usec = 4.194 sec */
    timer1_compare_a_set(((uint32_t)msec*1000 + 63)/64);
    timer1_clock_d1024();
}
示例#4
0
/*
 * triggered when the clock signal goes high
 */
pin2_interrupt()
{
	if (pin_is_high(PIN_DATA))
		value |= 1 << (7 - clk);

	clk++;
	timer1_clock_reset();
	timer1_count_set(0);
	second = 0;
	if (clk == 8) {
		if (cnt < 255) {
			data[cnt] = value;
			cnt++;
			events |= EV_DATA;
		}
		clk = 0;
		value = 0;
	}
}