--- /dev/null
+/* $Id: ircontrol.c,v 1.1 2010/06/26 19:08:18 simimeie Exp $
+ * Functions for the infrared receiver
+ *
+ * The infrared receiver is connected to PB0 / PCINT0.
+ */
+
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include "ircontrol.h"
+#include "console.h"
+
+ISR(PCINT0_vect) {
+ uint8_t v = PINB & _BV(PB0);
+ if (v) {
+ console_printpgm_P(PSTR("!1!"));
+ } else {
+ console_printpgm_P(PSTR("!0!"));
+ }
+}
+
+void ircontrol_init(void)
+{
+ /* Activate pullup */
+ PORTB |= _BV(PB0);
+ /* enable PCINT0 */
+ PCICR |= _BV(PCIE0);
+ /* Enable pin change interrupt 0 (=PB0) in pcint0 */
+ PCMSK0 |= _BV(PCINT0);
+}