static void timer_test_constants(void) { kprintf("TIMER_HW_HPTICKS_PER_SEC=%lu\n", (unsigned long)TIMER_HW_HPTICKS_PER_SEC); #ifdef TIMER_PRESCALER kprintf("TIMER_PRESCALER = %lu\n", (unsigned long)TIMER_PRESCALER); #endif #ifdef TIMER1_OVF_COUNT kprintf("TIMER1_OVF_COUNT = %lu\n", (unsigned long)TIMER1_OVF_COUNT); #endif kprintf("TIMER_TICKS_PER_SEC= %lu\n", (unsigned long)TIMER_TICKS_PER_SEC); kprintf("\n"); kprintf("ms_to_ticks(100) = %lu\n", (unsigned long)ms_to_ticks(100)); kprintf("ms_to_ticks(10000) = %lu\n", (unsigned long)ms_to_ticks(10000)); kprintf("us_to_ticks(100) = %lu\n", (unsigned long)us_to_ticks(100)); kprintf("us_to_ticks(10000) = %lu\n", (unsigned long)us_to_ticks(10000)); kprintf("\n"); kprintf("ticks_to_ms(100) = %lu\n", (unsigned long)ticks_to_ms(100)); kprintf("ticks_to_ms(10000) = %lu\n", (unsigned long)ticks_to_ms(10000)); kprintf("ticks_to_us(100) = %lu\n", (unsigned long)ticks_to_us(100)); kprintf("ticks_to_us(10000) = %lu\n", (unsigned long)ticks_to_us(10000)); kprintf("\n"); kprintf("hptime_to_us(100) = %lu\n", (unsigned long)hptime_to_us(100)); #if (SIZEOF_HPTIME_T > 1) kprintf("hptime_to_us(10000)= %lu\n", (unsigned long)hptime_to_us(10000)); #endif kprintf("us_to_hptime(100) = %lu\n", (unsigned long)us_to_hptime(100)); kprintf("us_to_hptime(10000)= %lu\n", (unsigned long)us_to_hptime(10000)); }
void NORETURN context_switch(void) { IRQ_ENABLE; timer_init(); proc_init(); #if CONFIG_USE_HP_TIMER ser_init(&out, CONFIG_CTX_DEBUG_PORT); ser_setbaudrate(&out, CONFIG_CTX_DEBUG_BAUDRATE); #endif #if CONFIG_USE_LED LED_INIT(); #endif proc_forbid(); hp_proc = proc_new(hp_process, NULL, PROC_STACK_SIZE, hp_stack); lp_proc = proc_new(lp_process, NULL, PROC_STACK_SIZE, lp_stack); main_proc = proc_current(); proc_setPri(hp_proc, 2); proc_setPri(lp_proc, 1); proc_permit(); while (1) { timer_delay(100); sig_send(lp_proc, SIG_USER0); sig_wait(SIG_USER0); #if CONFIG_USE_HP_TIMER kfile_printf(&out.fd, "Switch: %lu.%lu usec\n\r", hptime_to_us((end - start)), hptime_to_us((end - start) * 1000) % 1000); #endif } }