Rev 1199 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1199 | Rev 1437 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2011-2012 by Claas Anders "CaScAdE" Rathje * |
3 | * admiralcascade@gmail.com * |
3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ * |
5 | * * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License. * |
8 | * the Free Software Foundation; either version 2 of the License. * |
9 | * * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
13 | * GNU General Public License for more details. * |
14 | * * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ****************************************************************************/ |
19 | ****************************************************************************/ |
20 | 20 | ||
21 | #include "timer1.h" |
21 | #include "timer1.h" |
22 | 22 | ||
23 | // 16 bit timer |
23 | // 16 bit timer |
24 | // critical for pwm and stuff |
24 | // critical for pwm and stuff |
25 | // periodic uncritical stuff should go to the non-blocking timer0 |
25 | // periodic uncritical stuff should go to the non-blocking timer0 |
26 | 26 | ||
27 | void timer1_init() { |
27 | void timer1_init() { |
28 | // CTC Mode |
28 | // CTC Mode |
29 | TCCR1B = (1 << WGM12); |
29 | TCCR1B = (1 << WGM12); |
30 | 30 | ||
31 | // Prescale 8 |
31 | // Prescale 8 |
32 | TCCR1B &= ~(1 << CS10); |
32 | TCCR1B &= ~(1 << CS10); |
33 | TCCR1B |= (1 << CS11); |
33 | TCCR1B |= (1 << CS11); |
34 | TCCR1B &= ~(1 << CS12); |
34 | TCCR1B &= ~(1 << CS12); |
35 | 35 | ||
36 | // Compare every 100us at 20MHz |
36 | // Compare every 100us at 20MHz |
37 | OCR1A = 250; |
37 | OCR1A = 250; |
38 | 38 | ||
39 | // Compare Interrupt enable |
39 | // Compare Interrupt enable |
40 | TIMSK1 |= (1 << OCIE1A); |
40 | TIMSK1 |= (1 << OCIE1A); |
41 | } |
41 | } |
42 | 42 | ||
43 | // every 100us |
43 | // every 100us |
44 | 44 | ||
45 | ISR(TIMER1_COMPA_vect, ISR_BLOCK) { |
45 | ISR(TIMER1_COMPA_vect, ISR_BLOCK) { |
46 | 46 | ||
47 | // every 100us |
47 | // every 100us |
48 | led_timer_callback(); |
48 | led_timer_callback(); |
49 | } |
49 | } |
50 | 50 |