#include "mcom_runtime/gic.h" #include "mcom_runtime/utimers.h" #include "mcom_runtime/mcom02.h" #include "mcom_runtime/rtc.h" #include "mcom_runtime/uart.h" #include "mcom_runtime/debug_printf.h" int Flag_Corr = 1; int wait_flag = 0; unsigned get_l3_freq(void) { return (((SET_SPLL&0xff) + 1)*XTI_FREQ >> (DIV_SYS0_CTR&0x1)) >> (DIV_SYS1_CTR&0x1); } void timer_interrupt_handler(int id) { disableUTimer(0); wait_flag = 1; } int main(void) { Flag_Corr = 1; wait_flag = 0; risc_initialize_gic(); risc_enable_interrupt(TIMER_INTR0, GIC_PL390_TARGET_CPU0, 0xF1); risc_register_interrupt(&timer_interrupt_handler, TIMER_INTR0, 0); uart_config(0, 115200); set_out_mode(OUT_FROM_UART); debug_printf("\n\r********Test started!*********\n\r"); RRTC_TIME_REG time; get_rtc_time(&time); debug_printf("Current time:\n\r"); debug_printf("sec=%d tsec=%d min=%d tmin=%d hour=%d thour=%d\n\r", time.sec, time.tsec, time.min, time.tmin, time.hour, time.thour); debug_printf("Waiting for 12 seconds"); unsigned int val = get_l3_freq(); initUTimer(0, 12*get_l3_freq(), 1); unsigned int first_time = 0; first_time = time.sec + (time.tsec*10) + (time.min*60) + (time.tmin*600) + (time.hour*3600); while(wait_flag != 1); get_rtc_time(&time); debug_printf("sec=%d tsec=%d min=%d tmin=%d hour=%d thour=%d\n\r", time.sec, time.tsec, time.min, time.tmin, time.hour, time.thour); unsigned int second_time = 0; second_time = time.sec + (time.tsec*10) + (time.min*60) + (time.tmin*600) + (time.hour*3600); unsigned int wait_time = second_time-first_time; if(wait_time == 72) Flag_Corr = 0; return 0; }