59 lines
2.1 KiB
C
59 lines
2.1 KiB
C
#ifndef _GLOBAL_TIME
|
|
#define _GLOBAL_TIME
|
|
|
|
typedef struct {
|
|
unsigned long total_seconds; //Âñåãî ñåêóíä ñ ìîìåíòà âêëþ÷åíèß
|
|
unsigned long total_seconds10; //Âñåãî ñåêóíä ñ ìîìåíòà âêëþ÷åíèß ñ äåñÿòûìè
|
|
unsigned long total_seconds10full; //Âñåãî ñåêóíä ñ ìîìåíòà âêëþ÷åíèß ñ äåñÿòûìè
|
|
unsigned long microseconds;
|
|
unsigned int microseconds_temp;
|
|
|
|
unsigned int miliseconds; //???
|
|
unsigned long miliseconds_long; //???
|
|
unsigned int pwm_tics;
|
|
unsigned int seconds;
|
|
unsigned int minuts;
|
|
unsigned int hours;
|
|
unsigned int freq_pwm_hz;
|
|
unsigned int microseconds_add;
|
|
void (*calc)(); //Ñ÷èòàåò â ïðåðûâàíèè ØÈÌ'à
|
|
} GLOBAL_TIME;
|
|
|
|
typedef GLOBAL_TIME *GLOBAL_TIME_handle;
|
|
|
|
void global_time_calc(GLOBAL_TIME_handle);
|
|
void init_global_time_struct(unsigned int freq_pwm);
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
Default initalizer for the GLOBAL_TIME object.
|
|
-----------------------------------------------------------------------------*/
|
|
#define GLOBAL_TIME_DEFAULTS { 0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
0, \
|
|
global_time_calc \
|
|
}
|
|
/*------------------------------------------------------------------------------
|
|
Prototypes for the functions in global_time.c
|
|
------------------------------------------------------------------------------*/
|
|
|
|
|
|
extern GLOBAL_TIME global_time;
|
|
|
|
void init_timer_sec(unsigned int *start_time); //Èíèöèàëèçèðóåò ïåðåìåííóþ, âðåìß ñòàðòà â ñåêóíäàõ
|
|
void init_timer_milisec(unsigned int *start_time); //Èíèöèàëèçèðóåò ïåðåìåííóþ, âðåìß ñòàðòà â ìèëèñåêóíäàõ
|
|
int detect_pause_sec(unsigned int wait_pause, unsigned int *old_time); //ïàóçà â ñåêóíäàõ
|
|
int detect_pause_milisec(unsigned int wait_pause, unsigned int *old_time); //Ïàóçà â ìèëèñåêóíäàõ (íå áîëåå 60000ìëñåê)
|
|
unsigned int get_delta_milisec(unsigned int *old_time, unsigned int upd); // âåðíóëè ñêîëüêî âðåìåíè ïðîøëî îò âðåìåíè old_time ; upd=1 - îáíîâèòü old_time - òåêóùèì
|
|
|
|
#endif //_GLOBAL_TIME
|