Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1198 → Rev 1199

/C-OSD/C-Epilepsy/timer0.c
0,0 → 1,55
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 2 of the License. *
* *
* 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, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
#include "timer0.h"
 
// 8 bit timer
// unccritical stuff
// periodic critical stuff should go to the blocking timer1
 
volatile uint16_t uptime = 0;
 
void timer0_init() {
TCCR0B |= ((1 << CS02) | (1 << CS00)); // Prescale 1024
 
TIMSK0 |= (1 << TOIE0); // overflow enable
}
 
// every ~ 10ms = 10000us (9984us)
uint8_t timer0_scale_helper = 0;
 
ISR(TIMER0_OVF_vect, ISR_NOBLOCK) {
TCNT0 = 61;
 
player_timer_callback();
 
static uint16_t ticks = 0;
ticks++;
 
// ~1s
if (timer0_scale_helper++ >= 100) {
timer0_scale_helper = 0;
nc_handler_timer_callback();
eeprom_timer_callback();
uptime++;
//LEDRED_TOGGLE
}
 
}