Exemplo n.º 1
0
static void initISR(timer16_Sequence_t timer)
{  
    if( timer == _timer1){
        if( SRV_TAUxEN == 0 ){
#ifdef WORKAROUND_READ_MODIFY_WRITE
            SBI2( SRV_SFR2_PERx, SRV_SFR2_BIT_TAUxEN );        /* supplies input clock */
#else
            SRV_TAUxEN = 1U;          /* supplies input clock */
#endif
            SRV_TPSx   = TIMER_CLOCK;
        }

#ifdef WORKAROUND_READ_MODIFY_WRITE
        /* Set INTTM04 low priority */
        SBI( SRV_SFR_PR1xx, SRV_SFR_BIT_TMPR1xx );
        SBI( SRV_SFR_PR0xx, SRV_SFR_BIT_TMPR0xx );
        /* Mask channel 04 interrupt */
        CBI( SRV_SFR_MKxx, SRV_SFR_BIT_TMMKxx );    /* enable INTTM04 interrupt */
        CBI( SRV_SFR_IFxx, SRV_SFR_BIT_TMIFxx );    /* clear INTTM04 interrupt flag */
#else
        /* Set INTTM04 low priority */
        SRV_TMPR1xx = 1U;
        SRV_TMPR0xx = 1U;
        /* Mask channel 04 interrupt */
        SRV_TMMKxx  = 0U;    /* enable INTTM04 interrupt */
        SRV_TMIFxx  = 0U;    /* clear INTTM04 interrupt flag */
#endif
        /* Channel 0 used as interval timer */
        SRV_TMRxx   = 0x8000U;
        SRV_TDRxx   = (unsigned int)usToTicks(REFRESH_INTERVAL);
        SRV_TSx    |= SRV_CHx;     /* operation is enabled (start trigger is generated) */

        delay(1);
        
        Channel[timer] = -1;
        handle_interrupts(_timer1);   /* TDR0x setting */

    }
}
Exemplo n.º 2
0
 void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
Exemplo n.º 3
0
 void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
Exemplo n.º 4
0
INTERRUPT void servo_interrupt(void)
{
    handle_interrupts(_timer1);
}
Exemplo n.º 5
0
void __attribute__((interrupt(),nomips16)) T5_IntHandler (void){
 	handle_interrupts(TIMER5); 
	IFS0CLR = 0x100000; // Clear timer interrupt status flag
}
Exemplo n.º 6
0
// Draws one frame then returns
void run_one_frame() {
    frame_drawn = 0;

    while (!frame_drawn) {
        if (halted || stopped) {
            long current_cycles = cgb_speed ? 2 : 4;
            update_timers(current_cycles);
            sound_add_cycles(current_cycles);
            inc_serial_cycles(current_cycles);

            // If Key pressed in "stop" mode, then gameboy is "unstopped"
            if (stopped) {
                if(key_pressed()) {
                    stopped = 0;
                }
            }
            if (halted) {
                update_graphics(current_cycles);
            }
        }
        else if (!(halted || stopped)) {
            current_cycles = 0;
            current_cycles += exec_opcode(skip_bug);

        }

        cycles += current_cycles;
      
		#ifdef EFIAPI
        if (cycles > 3000) {
		#else
		if (cycles > 15000) {
		#endif
            quit |= update_keys();
            cycles = 0;
        }
        skip_bug = handle_interrupts();

        if (debug && step_count > 0 && --step_count == 0) {
            int flags = get_command();
            step_count = (flags & STEPS_SET) ? get_steps() : STEPS_OFF;
        }
    }

}

void setup_debug() {
    if (debug) {
        int flags = get_command();
        step_count = (flags & STEPS_SET) ?  get_steps() : STEPS_OFF;

        breakpoint =  (flags & BREAKPOINT_SET) ?
                      get_breakpoint() : BREAKPOINT_OFF;
    }


}

void run() {
    log_message(LOG_INFO, "About to setup debug\n");
    setup_debug();
    log_message(LOG_INFO, "About to run\n");
    while(!quit) {
        run_one_frame();
    }
}
Exemplo n.º 7
0
void __attribute__((interrupt(),nomips16)) T5_IntHandler (void)
#endif
{
 	handle_interrupts(TIMER5, &TMR5, &PR5); 
	IFS0bits.T5IF = 0; // Clear timer interrupt status flag
}