//You give it a vallut and the specific timer you want to star. // YOu have four timers just start with timer zero // The speed of counter or number ticks depends on qemu hertz speed // we don't know he start of it but it should be around 10 milliseconds // per proccess. // ex: start_timer_interrupts(0,10) which means start timer(0) // and interrupt every 10 clicks. int start_timer_interrupts(int timer_index,int milliseconds){ // conversion(timer_index, milliseconds); if(timer_index < 4 && timer_index >= 0){ int clicks=conversion(timer_index, milliseconds); set_background_load_value(timer_index, clicks); set_periodic_mode(timer_index); enable_timer_interrupt(timer_index); timer_start(timer_index); // return 0; } // return -1; //just testing code //int count=0; /*while(1){ os_printf("\n%d",get_current_timer_value(timer_index)); if(get_current_timer_value(timer_index)==0){ os_printf("\nInterrupt Control Val:%X \t Process Val:%X\t VIC Val:%X\t",get_timer_control_value(timer_index),get_proc_status(),mmio_read(VIC_INT_ENABLE)); // count++; } // if(get_current_timer_value(timer_index)==0){ // hw_interrupt_enable(4); /// } // if(get_current_timer_value(timer_index==9&count>0)) // hw_interrupt_enable(4); } */ return 0; }
void Timer_attachInterrupt(void (*f)(void)){ // 割り込みフラグクリア *TIMER_IRQ_CLR = 0; // 関数ポインタセット timerIRQ_func = f; // タイマー開始 Timer_start(); // 割り込み有効 enable_timer_interrupt(); enable_IRQ(); }
int main(void) { SysTick_Config(SystemCoreClock / 1000); delay(1000); led_control_init(); servo_control_init(); init_button_gpio(); init_timer(); enable_timer_interrupt(); while(1) {} }