Project

General

Profile

Statistics
| Branch: | Revision:

root / scout_avr / src / orb.cpp @ 0970d303

History | View | Annotate | Download (739 Bytes)

1 066b08bb Tom Mullins
extern "C" {
2
#include <avr/io.h>
3
#include <util/delay.h>
4
}
5
#include "orb.h"
6
7
void orb_init() {
8
9
  /* set pins to output mode */
10
        DDRB |= _BV(PB4) | _BV(PB5) | _BV(PB6);
11
  DDRE |= _BV(PE3) | _BV(PE4) | _BV(PE5);
12
13
  orb_set0(0, 0, 0);
14
  orb_set1(0, 0, 0);
15
          
16
        /* timer 2 */
17
  TCCR2A |= _BV(COM2A1) | _BV(WGM20);
18
        TCCR2B |= _BV(CS21);
19
20
        /* timer 1 */
21
        TCCR1A |= _BV(COM1A1) | _BV(COM1B1) | _BV(WGM10);
22
        TCCR1B |= _BV(CS11);
23
24
        /* timer 3 */
25
        TCCR3A |= _BV(COM3A1) | _BV(COM3B1) | _BV(COM3C1) | _BV(WGM30);
26
        TCCR3B |= _BV(CS31);
27
}
28
29
void orb_set0(unsigned char r, unsigned char g, unsigned char b) {
30
        OCR1B = r;
31
        OCR1A = g;
32
        OCR2A = b;
33
}
34
35
void orb_set1(unsigned char r, unsigned char g, unsigned char b) {
36
        OCR3B = r;
37
        OCR3A = g;
38
        OCR3C = b;
39
}