#ifndef _KIT_TIME_H_
#define _KIT_TIME_H_

#ifdef __cplusplus
extern "C" {
#endif 

#include <time.h>
#include "kit_macro.h"

#ifdef NO_OS
extern uint32_t sys_tick;
#endif 

uint32_t kit_time_get_tick(void);
uint32_t kit_time_get_interval(uint32_t last_tick, uint32_t new_tick);
uint32_t kit_time_get_interval_by_now(uint32_t last_tick);
uint32_t kit_time_get_interval_by_now_and_update(uint32_t *last_tick);

void kit_time_beat(void);
void kit_time_dly_100ns(void);
void kit_time_dly_us(uint32_t dly);
void kit_time_dly_ms(uint32_t dly);
void kit_time_dly_by_fix_period(uint32_t last_tick,uint16_t period);

struct tm * kit_time_get_date(uint16_t start_year, uint32_t stamp);
uint32_t    kit_time_get_stamp(uint16_t start_year, struct tm *time);

KitResult kit_wait_flag(volatile uint32_t *reg, uint32_t flag_bit, int32_t timeout);
#ifdef __cplusplus
}
#endif

#endif    
