-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathderTrigger.cpp
63 lines (54 loc) · 1.36 KB
/
derTrigger.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* derTrigger.cpp
*
* Created on: 09.02.2017
* Author: cybaer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "derTrigger.h"
#include "HardwareConfig.h"
#include "Sequencer.h"
MCP23017 Extender;
volatile bool poll = false;
ISR(TIMER2_OVF_vect, ISR_NOBLOCK)
{
//ca 4kHz
sequencer.onClock();
static int8_t subClock = 0;
subClock = (subClock + 1) & 3;
if (subClock == 0)
{ // 1kHz
poll = true;
}
}
void setup()
{
Serial.begin(9600);
Serial.println("*** START ***");
initHW();
// 16MHz / (8 * 510) = 3906,25 Hz
// prescaler(2)_|
Timer<2>::set_prescaler(2);//2
Timer<2>::set_mode(TIMER_PWM_PHASE_CORRECT);
Timer<2>::Start();
}
void loop()
{
if(poll)
{
poll = false;
sequencer.poll();
}
sequencer.update();
}