1 |
/* mija 2009 |
1 |
/* mija 2009 |
2 |
|
2 |
|
3 |
SW pro ATmega8 mereni + regulace teploty |
3 |
SW pro ATmega8 mereni + regulace teploty |
4 |
Fosc = 8192000Hz externi krystal |
4 |
Fosc = 8192000Hz externi krystal |
5 |
|
5 |
|
6 |
|
6 |
|
7 |
ver.: 0.0 - start |
7 |
ver.: 0.0 - start |
8 |
*/ |
8 |
*/ |
9 |
|
9 |
|
10 |
#include <avr/io.h> |
10 |
#include <avr/io.h> |
11 |
#include "clock.h" |
11 |
#include "clock.h" |
12 |
|
12 |
|
13 |
void ClockInit(uint8_t hour,uint8_t min,uint8_t sec,Clockt_t *clock) |
13 |
void ClockInit(uint8_t hour,uint8_t min,uint8_t sec,Clockt_t *clock) |
14 |
{ |
14 |
{ |
15 |
clock->hour = hour; |
15 |
clock->hour = hour; |
16 |
clock->min = min; |
16 |
clock->min = min; |
17 |
clock->sec = sec; |
17 |
clock->sec = sec; |
18 |
} |
18 |
} |
19 |
|
19 |
|
20 |
void ProcesClock(uint8_t *tik,Clockt_t *clock) |
20 |
void ProcesClock(uint8_t *tik,Clockt_t *clock) |
21 |
{ |
21 |
{ |
22 |
if (!*tik) |
22 |
if (!*tik) |
23 |
{ |
23 |
{ |
24 |
*tik = TIKSOFSEC; //125 |
24 |
*tik = TIKSOFSEC; //125 |
25 |
if (++clock->sec == 60) |
25 |
if (++clock->sec == 60) |
26 |
{ |
26 |
{ |
27 |
clock->sec = 0; |
27 |
clock->sec = 0; |
28 |
if (++clock->min == 60) |
28 |
if (++clock->min == 60) |
29 |
{ |
29 |
{ |
30 |
clock->min = 0; |
30 |
clock->min = 0; |
31 |
clock->hour++; |
31 |
clock->hour++; |
32 |
} |
32 |
} |
33 |
} |
33 |
} |
34 |
} |
34 |
} |
35 |
} |
35 |
} |