/*
Diplomova prace : Palubni pocitac

timer - systemovy casovac

Atmega128A 10 MHz XTAL

Autor: Ondrej Lutera

2011/2012

*/
#ifndef TIMER_H_INCLUDED
#define TIMER_H_INCLUDED

#include <avr/io.h>
#include <avr/interrupt.h>
#include "car_meas.h"
#include "i2clib/pcf8563.h"
#include "define.h"

#define INT_ISR()   ISR(INT7_vect)
#define INT_EICR    EICRB
#define INT_EICR_INIT   1<<ISC71
#define INT_EIMSK   EIMSK
#define INT_EIMSK_INIT  (1<<INT7)

#define INT_PULL    PORTE
#define INT         PE7
#define INT_PIN     PINE
#define INT_DDR     DDRE

/* 1/32s ISR timer -> max 31.25*256 ms */

void InitTimer(uint8_t clk);        // init timeru
void DisTimer(void);                    // zakazani timeru pri power-down apod

uint8_t RetTimer(void);             // vraci akt. hodnotu timeru

uint8_t CompTimer(uint8_t TimeState,uint8_t delay);     // porovnava hodnotu s pozadovanym zpozdenim a s aktualnim stavem timeru..dokaze porovnat az 8s zpozdeni


#endif // TIMER_H_INCLUDED
