- add LED control with PWM
[moodlight.git] / ircontrol.c
CommitLineData
17aea8ef 1/* $Id: ircontrol.c,v 1.1 2010/06/26 19:08:18 simimeie Exp $
2 * Functions for the infrared receiver
3 *
4 * The infrared receiver is connected to PB0 / PCINT0.
5 */
6
7#include <avr/io.h>
8#include <avr/interrupt.h>
9#include "ircontrol.h"
10#include "console.h"
11
12ISR(PCINT0_vect) {
13 uint8_t v = PINB & _BV(PB0);
14 if (v) {
15 console_printpgm_P(PSTR("!1!"));
16 } else {
17 console_printpgm_P(PSTR("!0!"));
18 }
19}
20
21void ircontrol_init(void)
22{
23 /* Activate pullup */
24 PORTB |= _BV(PB0);
25 /* enable PCINT0 */
26 PCICR |= _BV(PCIE0);
27 /* Enable pin change interrupt 0 (=PB0) in pcint0 */
28 PCMSK0 |= _BV(PCINT0);
29}
This page took 0.069502 seconds and 4 git commands to generate.