root / scout_avr / src / orb.cpp @ 73d308b3
History | View | Annotate | Download (855 Bytes)
1 |
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 |
orb_set1(0, 255, 255); |
16 |
|
17 |
/* timer 2 */
|
18 |
TCCR2A |= _BV(COM2A1) | _BV(COM2A0) | _BV(WGM20); |
19 |
TCCR2B |= _BV(CS21); |
20 |
|
21 |
/* timer 1 */
|
22 |
TCCR1A |= _BV(COM1A1) | _BV(COM1A0) | _BV(COM1B1) | _BV(COM1B0) |_BV(WGM10); |
23 |
TCCR1B |= _BV(CS11); |
24 |
|
25 |
/* timer 3 */
|
26 |
TCCR3A |= _BV(COM3A1) | _BV(COM3A0) | _BV(COM3B1) | _BV(COM3B0) | _BV(COM3C1) |
27 |
| _BV(COM3C0) | _BV(WGM30); |
28 |
TCCR3B |= _BV(CS31); |
29 |
} |
30 |
|
31 |
void orb_set0(unsigned char r, unsigned char g, unsigned char b) { |
32 |
OCR1B = r; |
33 |
OCR2A = g; |
34 |
OCR1A = b; |
35 |
} |
36 |
|
37 |
void orb_set1(unsigned char r, unsigned char g, unsigned char b) { |
38 |
OCR3B = r; |
39 |
OCR3C = g; |
40 |
OCR3A = b; |
41 |
} |