#include "trace.h"

uint32_t g_time_start[3];
__attribute__((always_inline)) uint32_t Time_offset(uint32_t idx)
{
    #ifndef IDE_TEST
        uint32_t cur_cycle = TIME_NS();
        return (cur_cycle < g_time_start[idx]) ? (cur_cycle + 0x3b9aca00 - g_time_start[idx]) : (cur_cycle - g_time_start[idx]);
    #else
        return 0;
    #endif
}