Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
60 jimmy 1
#ifndef timebase_h_
2
#define timebase_h_
3
 
4
 
5
/*-----------------------------------------------------------------------------
6
 * Includes
7
 *---------------------------------------------------------------------------*/
8
#include <inttypes.h>
9
 
10
 
11
/*-----------------------------------------------------------------------------
12
 * Defines
13
 *---------------------------------------------------------------------------*/
247 eqlazer 14
/* Enable timer2 if you want to use as many PWM outputs as possible */
15
#define TIMER2
16
 
60 jimmy 17
#define TIMEBASE_PRESCALE (64)
381 eqlazer 18
#define TIMEBASE_HITS_PER_1MS (F_CPU/TIMEBASE_PRESCALE/1000)
219 arune 19
 
20
#if TIMEBASE_HITS_PER_1MS > 255
21
#undef TIMEBASE_PRESCALE
22
#define TIMEBASE_PRESCALE (256)
23
#undef TIMEBASE_HITS_PER_1MS
381 eqlazer 24
#define TIMEBASE_HITS_PER_1MS (F_CPU/TIMEBASE_PRESCALE/1000)    // behöver denna definieras om ifall prescalern definierats om?
219 arune 25
#endif
26
 
60 jimmy 27
#define TIMEBASE_RELOAD ((uint8_t)(0xff-TIMEBASE_HITS_PER_1MS+1))
28
 
29
 
30
/*-----------------------------------------------------------------------------
31
 * Public Function Prototypes
32
 *---------------------------------------------------------------------------*/
127 jimmy 33
void Timebase_Init(void);
34
uint32_t Timebase_CurrentTime(void);
35
uint32_t Timebase_PassedTimeMillis(uint32_t t0);
60 jimmy 36
 
37
 
38
#endif