Esempio n. 1
0
void encoder_init(void)
{
	/* initialize interrupts for external quadrature encoders */
	PCICR |= BV(PCIE0) | BV(PCIE1); /* enable int0 (pin change 0-7) and int1 (pin change 8-14) */
	EICRA |= BV(ISC00) | BV(ISC10); /* int on both rising and falling edge */
	
	PCMSK0 |= BV(PCINT4); /* enable pin change INT4 (PB4) Left  */
	PCMSK1 |= BV(PCINT12); /* enable pin change INT12 (PC4) Right */

	PB_PULL_UP (ENC_L_A_PORT, ENC_L_A); /* pull-up required according to datasheet */
	PB_PULL_UP (ENC_L_B_PORT, ENC_L_B);
	PB_PULL_UP (ENC_R_A_PORT, ENC_R_A);
	PB_PULL_UP (ENC_R_B_PORT, ENC_R_B);

	/* reset variables */
	pid_ticks_l = 0;
	pid_ticks_r = 0;
}
Esempio n. 2
0
void button_init(void)
{
	PB_PULL_UP (PORTD, PD7); /* enable pull-up resistor */
	button_update();
}