static uint32_t pwm_isr(cyg_vector_t vector, cyg_addrword_t data) { static uint32_t pwmisr, icnt; CYG_INTERRUPT_STATE istate; CYG_ASSERT (CYGNUM_HAL_INTERRUPT_PWMC == vector, "Wrong interrupts"); pwms_idisable; // mask pwm interrupts HAL_READ_UINT32(AT91_PWM + AT91_PWM_ISR, pwmisr); // clears pwm-interrupt HAL_QUERY_INTERRUPTS(istate); // supervisor mode - interrupts are disabled HAL_ENABLE_INTERRUPTS(); // turn them on to allow higher priority irs icnt++; // to come through while (pwmisr) { if (icnt == 1) { if (pwmisr & 7) { // pwm0..2 run synchroneously, hence only pwm0 has been set for interrupts Set_LEDs(); Chk_Keys(); // Check if any key is pressed } if (pwmisr & 8) { // pwm3 interrupt pwm3d.ticks++; Read_AT91adc(); Do_Scan(); } // end pwm3 interrupt } // end if icnt else { icnt = (icnt + 0); // just for the debugger } HAL_READ_UINT32(AT91_PWM + AT91_PWM_ISR, pwmisr); // clears pwm-interrupt if (pwmisr & 0xf) icnt = (icnt + 0); // just for the debugger } // end while pwmisr icnt--; HAL_RESTORE_INTERRUPTS(istate); // turns interrupts off again cyg_interrupt_acknowledge(vector); // write eoi to AIC pwms_ienable; // unmask pwm interrupts and leave all the rest to ecos return CYG_ISR_HANDLED; } // end pwm_isr