- add LED control with PWM
[moodlight.git] / ircontrol.c
diff --git a/ircontrol.c b/ircontrol.c
new file mode 100644 (file)
index 0000000..cf7e494
--- /dev/null
@@ -0,0 +1,29 @@
+/* $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);
+}
This page took 0.049203 seconds and 4 git commands to generate.