/*
 * timer.h
 *
 * Created: 20.02.2019 20:56:07
 *  Author: jens
 */ 


#ifndef TIMER_H_
#define TIMER_H_

#include "fifo.h"

typedef enum _eTimerId
{
	TIMER_GENERAL	= 0,
	TIMER_TIMEOUT = 1,
	TIMER_ADC = 2
} TimerId;

typedef struct _sTimer_t
{
	int isRunning;
	uint16_t count;
} Timer_t;

typedef enum _eTimerClockSel
{
	TimerClockSel_none = 0,
	TimerClockSel_PS_1 = (1<<CS10),
	TimerClockSel_PS_8 = (1<<CS11),
	TimerClockSel_PS_64 = (1<<CS11) | (1<<CS10),
	TimerClockSel_PS_256 = (1<<CS12),
	TimerClockSel_PS_1024 = (1<<CS12) | (1<<CS10),
	TimerClockSel_ext_T1_neg = (1<<CS12) | (1<<CS11),
	TimerClockSel_ext_T1_pos = (1<<CS12) | (1<<CS11) | (1<<CS10),
	TimerClockSel_mask = (1<<CS12) | (1<<CS11) | (1<<CS10),
} TimerClockSel;

void timer_init(Fifo *pFifo, uint16_t TIMER_RELOAD, TimerClockSel clockSel);
void timer_start(TimerId timerId, uint16_t count);
#endif /* TIMER_H_ */