#include "kit_time.h"
#include "kit_debug.h"

#ifdef NO_OS
    uint32_t sys_tick = 0;
#elif defined UCOS2
    #include "ucos_ii.h"
#endif
    
    
void kit_time_beat(void)
{
#ifdef NO_OS
    sys_tick++;
#elif defined UCOS2
    OSTimeTick();
#endif
}    
    
uint32_t kit_time_get_tick(void)
{
#ifdef NO_OS
 return sys_tick;
#else
 return OSTimeGet();
#endif    
}

void kit_time_dly_ms(uint32_t dly)
{
#ifdef NO_OS
    uint32_t tick = kit_time_get_tick();
    while((kit_time_get_tick() - tick) < dly);
#elif defined UCOS2
    OSTimeDly(dly);
#endif            
}
