-
Notifications
You must be signed in to change notification settings - Fork 8
/
dsp.cpp
41 lines (35 loc) · 844 Bytes
/
dsp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "dsp.h"
#include "timers.h"
#include "Arduino.h"
void setupIO() {
// prepare left
waveformGenerationMode(3, phaseCorrect);
timerPrescale(3, 1);
// analogWrite(3, 0);
// prepare right
waveformGenerationMode(5, phaseCorrect);
timerPrescale(5, 1);
// analogWrite(5, 0);
// analogWrite(6, 0);
// faster input
analogReference(INTERNAL);
analogPrescale(analogPrescale32);
}
void output(int channel, short value) {
if(channel == left) {
pwm3 = value >> 2;
pwm11 = (value & B11) << 6;
} else if(channel == right) {
pwm5 = value >> 2;
pwm6 = (value & B11) << 6;
}
/*
if(channel == left) {
analogWrite(3,value >> 2);
analogWrite(11, (value & B11) << 6);
} else if(channel == right) {
analogWrite(5 , value >> 2);
analogWrite(6 , (value & B11) << 6);
}
*/
}