/*..........................................................................*/ static void interrupt ISR_tmr() { QF_ISR_ENTRY(); /* QF-specific ISR entry */ QF_tick(); /*<-- process the QF clock tick */ QF_ISR_EXIT(); /* QF-specific ISR exit */ }
void SysTick_Handler(void) { #ifdef Q_SPY uint32_t dummy = SysTick->CTRL; /* clear NVIC_ST_CTRL_COUNT flag */ QS_tickTime_ += QS_tickPeriod_; /* account for the clock rollover */ #endif QF_tick(); }
//------------------------------------------------------------------------------ /// Handler for PIT interrupt. Increments the timestamp counter. //------------------------------------------------------------------------------ void ISR_Pit(void) { unsigned int status; // Read the PIT status register status = PIT_GetStatus() & AT91C_PITC_PITS; if (status != 0) { // Read the PIVR to acknowledge interrupt and get number of ticks timestamp += (PIT_GetPIVR() >> 20); #ifdef QF_TICK #ifdef QK __disable_irq(); ++QK_intNest_; #endif QF_INT_UNLOCK(); QF_tick(); QF_INT_LOCK(); #ifdef QK --QK_intNest_; if ( QK_intNest_ ==0) QK_schedule_(); #endif #endif }
/* case 1: Interrupt Controller available, * "unconditional interrupt unlocking" critical section policy * (nesting of critical sections _not_ allowed) */ interrupt void ISR_timer() { /* entered with interrupts locked in hardware */ QF_INT_UNLOCK(ignore); /* unlock interrupts */ QF_tick(); /*<-- call the QF tick processing */ QF_INT_LOCK(ignore); /* lock interrupts again */ /* send the EOI instruction to the Interrupt Controller */ }
/*..........................................................................*/ static void interrupt tmrISR(void) { dispPreemptions(TMR_ISR_PRIO); /* for testing only, NOTE01 */ QK_ISR_ENTRY(); /* inform QK-nano about entering the ISR */ QF_tick(); /* process all armed time events */ BSP_busyDelay(); /* for testing, NOTE02 */ QK_ISR_EXIT(); /* inform QK-nano about exiting the ISR */ }
void timer_z_isr(void) { QK_ISR_ENTRY(); /* inform QK about ISR entry */ TZ0.TSR.BIT.IMFA = 0; /* clear compare match flag */ #ifdef Q_SPY l_tickTime += (uint32_t)((f1_CLK_SPEED/8 + BSP_TICKS_PER_SEC/2) / BSP_TICKS_PER_SEC); #endif QF_tick(); /* process all armed time events */ QK_ISR_EXIT(); /* inform QK about ISR exit */ }
/*..........................................................................*/ void SysTick_Handler(void) { QK_ISR_ENTRY(); /* infrom QK about entering an ISR */ #ifdef Q_SPY { uint32_t dummy = SysTick->CTRL; /* clear the COUNTFLAG in SysTick */ QS_tickTime_ += QS_tickPeriod_; /* account for the clock rollover */ } #endif QF_tick(); /* process all armed time events */ QK_ISR_EXIT(); /* infrom QK about exiting an ISR */ }
/*..........................................................................*/ #pragma INTERRUPT ta0_isr (vect = 12) /* system clock tick ISR */ void ta0_isr(void) { QF_INT_UNLOCK(dummy); /* see NOTE01 */ #ifdef Q_SPY if (ir_ta1ic != 0) { /* interrupt request set? */ ++l_nTimerA1Underflows; /* account for 16-bit underflow (0->0xFFFF) */ ir_ta1ic = 0; /* clear the overflow flag */ } #endif QF_tick(); /* process all armed time events */ QF_INT_LOCK(dummy); /* see NOTE01 */ }
__interrupt void timer0_ISR(void) { QK_ISR_ENTRY(); /* inform QK about entering the ISR */ /* No need to clear the interrupt source since the Timer0 compare * interrupt is automatically cleard in hardware when the ISR runs. */ #ifdef Q_SPY l_tickTime += (F_CPU / BSP_TICKS_PER_SEC / 1024); #endif QF_tick(); QK_ISR_EXIT(); /* inform QK about exiting the ISR */ }
/*..........................................................................*/ static void interrupt tmrISR() { enable(); /* unlock interrupts */ QF_tick(); /*<-- process the QF clock tick */ disable(); /* lock interrupts again */ outportb(0x20, 0x20); /* write EOI to the master PIC */ }
/*..........................................................................*/ static void interrupt tmrISR(void) { QF_tick(); /* process all armed time events */ outportb(0x20, 0x20); /* write EOI to the master PIC */ }
__interrupt void timerA_ISR(void) { __low_power_mode_off_on_exit(); QF_tick(); /* handle all armed time events in QF-nano */ }
__interrupt void timer2_ISR(void) { TMR2CN &= ~(1 << 7); /* Clear Timer2 interrupt flag */ QF_tick(); /* handle all armed time events in QF-nano */ }
__interrupt void timerA_ISR(void) { QK_ISR_ENTRY(); /* inform QK-nano about entering the ISR */ QF_tick(); /* handle all armed time events in QF-nano */ QK_ISR_EXIT(); /* inform QK-nano about exiting the ISR */ }
int main(int argc, char* argv[]) { char cmdBuf[SOCK_BUFF_SIZE]; printf("Quantum Test\nQEP %s\nQF %s, QF/Linux port %s\n", QEP_getVersion(), QF_getVersion(), QF_getPortVersion()); QF_init(); QF_psInit(subscrSto, Q_DIM(subscrSto)); QF_poolInit(poolArray, sizeof(poolArray), sizeof(GenEvt)); applicationStart(QSIZE); for (;;) { // Get the incoming string command from the dmsTerminal or the GUI receiveCmd(cmdBuf); // Attempt to parse the command string for IMPL or ACTIVE calls char tmpBuf[USER_ENTRY_SIZE]; char smName[USER_ENTRY_SIZE]; char attrName[USER_ENTRY_SIZE]; char valStr[USER_ENTRY_SIZE]; // scan for IMPL['SM'].set("attr", True/False), allowing blanks // IMPL['trans'].set('guard', False) int cnt = sscanf(strcpy(tmpBuf, cmdBuf), "IMPL[%*['\"]%[^'\"]%*['\"]].set(%*['\"]%[^'\"]%*['\"],%[^)])", smName, attrName, valStr); if (cnt > 0) { // found an IMPL attribute setter! setGuardAttribute(smName, attrName, valStr); continue; } char *word; word = strtok(cmdBuf, " "); // We assume the first word contains the signal that is to be published, // and the remaining words are data to be used to populate the event. GenEvt *event; int signal = strtoul(word, NULL, 10); if (signal == DURING) { QF_tick(); QF_publish( Q_NEW(QEvent, DURING) ); } else { event = Q_NEW(GenEvt, signal); // Loop through the remaining words and populate the event int i = 0; do { word = strtok('\0', " "); if (word) { Q_ASSERT(i<EVENT_SIZE); event->data[i] = strtoul(word, NULL, 16); } i = i + 1; } while (word); QF_publish((QEvent *)event); } QF_run(); } }
/* case 2: Interrupt Controller not used, * "saving and restoring interrupt status" critical section policy * (nesting of critical sections allowed) */ interrupt void ISR_timer() { QF_tick(); /*<-- call the QF tick processing */ }