Subversion Repositories Projects

Rev

Rev 1199 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1199 - 1
/****************************************************************************
1437 - 2
 *   Copyright (C) 2011-2012 by Claas Anders "CaScAdE" Rathje               *
1199 - 3
 *   admiralcascade@gmail.com                                               *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/                 *
5
 *                                                                          *
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   *
8
 *   the Free Software Foundation; either version 2 of the License.         *
9
 *                                                                          *
10
 *   This program is distributed in the hope that it will be useful,        *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
 *   GNU General Public License for more details.                           *
14
 *                                                                          *
15
 *   You should have received a copy of the GNU General Public License      *
16
 *   along with this program; if not, write to the                          *
17
 *   Free Software Foundation, Inc.,                                        *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
 ****************************************************************************/
20
 
21
#include "timer0.h"
22
 
23
// 8 bit timer
24
// unccritical stuff
25
// periodic critical stuff should go to the blocking timer1
26
 
27
volatile uint16_t uptime = 0;
28
 
29
void timer0_init() {
30
    TCCR0B |= ((1 << CS02) | (1 << CS00)); // Prescale 1024
31
 
32
    TIMSK0 |= (1 << TOIE0); // overflow enable
33
}
34
 
35
// every ~ 10ms = 10000us (9984us)
36
uint8_t timer0_scale_helper = 0;
37
 
38
ISR(TIMER0_OVF_vect, ISR_NOBLOCK) {
39
    TCNT0 = 61;
40
 
41
    player_timer_callback();
42
 
43
    static uint16_t ticks = 0;
44
    ticks++;
45
 
46
    // ~1s
47
    if (timer0_scale_helper++ >= 100) {
48
        timer0_scale_helper = 0;
49
        nc_handler_timer_callback();
50
        eeprom_timer_callback();
51
        uptime++;
52
        //LEDRED_TOGGLE
53
    }
54
 
55
}