forked from haraldwolff/avr-fw-modules
27 lines
583 B
C
27 lines
583 B
C
|
#include <sys/time.h>
|
||
|
#include <sys/runtime.h>
|
||
|
#include <sys/systick.h>
|
||
|
|
||
|
|
||
|
void unixtime_set(uint32_t _unixtime){
|
||
|
time_t oldtime = unixtime();
|
||
|
|
||
|
if (rt_ram.unix_time_changing && !rt_ram.unix_time_changing(UTCH_CHECK, oldtime,_unixtime)){
|
||
|
|
||
|
if (rt_ram.unix_time_changing)
|
||
|
rt_ram.unix_time_changing(UTCH_CHANGING,oldtime,_unixtime);
|
||
|
|
||
|
rt_ram.unix_timeoffset = _unixtime - systick_secs();
|
||
|
|
||
|
if (rt_ram.unix_time_changing)
|
||
|
rt_ram.unix_time_changing(UTCH_CHANGED,oldtime,_unixtime);
|
||
|
|
||
|
};
|
||
|
};
|
||
|
|
||
|
uint32_t unixtime(void){
|
||
|
return (rt_ram.unix_timeoffset + systick_secs());
|
||
|
};
|
||
|
|
||
|
|