示例#1
0
 void action(boolean flag) {
   pending_actions = flag;
   
   // If negative action, abort buzzer immedielty. 
   if (!flag) {
     enterIdleState();  
   }
 }
示例#2
0
  void setup() {
    // Fast PWM mode, OC2B output active high.
    TCCR0A = L(COM0A1) | L(COM0A0) | H(COM0B1) | H(COM0B0) | H(WGM01) | H(WGM00); 
    // Prescaler x256 (62.5Khz @ 16Mhz).
    TCCR0B = L(FOC0A) | L(FOC0B) | H(WGM02) | H(CS02) | L(CS01) | L(CS00);
    // Clear counter.
    TCNT0 = 0;
    // Compare A, sets output frequency.
    OCR0A = kDivider;
    // Compare B, sets output duty cycle.
    OCR0B = kDivider / 2;
    // Diabled interrupts.
    TIMSK0 = L(OCIE0B) | L(OCIE0A) | L(TOIE0);
    TIFR0 =  L(OCF0B) | L(OCF0A) | L(TOV0); 

    enterIdleState();
  }
示例#3
0
 // Called from loop() when in ACTIVE state.
 static inline void loopInActiveState() {
   // If within current slot time then do nothing.
   const uint16 slot_time_millis = slotTimeMillis(active_sequence_number, active_slot_index);
   if (timer.timeMillis() < slot_time_millis) {
     return;
   }
   
   // Advance to next slot.
   timer.restart();
   active_slot_index++;
   const uint16 next_slot_time_millis = slotTimeMillis(active_sequence_number, active_slot_index);
       
   // If this is a normal slot, start playing it.
   if (next_slot_time_millis) {
     // Odd slots are off, even are on.
     if (active_slot_index & 0x1) {
       buzzerOff();    
     } 
     else {
       buzzerOn();
     }  
     return;
   }
      
   // Here when we reached a terminator slot at the end of the sequence. 
   
   // If there are pending action, start a new sequence.
   if (pending_actions) {
     // Stay in active state and start another cycle.
     pending_actions = false;
     // We play sequence 1 once and then switch to sequence 2.
     active_sequence_number = 2;
     active_slot_index = 0;
     // First slot is always on (even index).
     buzzerOn();
     return;
   } 
     
   // Here when at end of sequence and no pending action. Switch
   // to off state.
   enterIdleState();
 }
示例#4
0
void DebuggerDriver::processOutput(const QByteArray& data)
{
    // write to log file (do not log delayed output - it would appear twice)
    if (m_logFile.isOpen()) {
	m_logFile.write(data);
	m_logFile.flush();
    }
    
    /*
     * gdb sometimes produces stray output while it's idle. This happens if
     * it receives a signal, most prominently a SIGCONT after a SIGTSTP:
     * The user haltet kdbg with Ctrl-Z, then continues it with "fg", which
     * also continues gdb, which repeats the prompt!
     */
    if (m_activeCmd == 0 && m_state != DSinterrupted) {
	// ignore the output
	TRACE("ignoring stray output: " + QString(data));
	return;
    }
    ASSERT(m_state == DSrunning || m_state == DSrunningLow || m_state == DSinterrupted);
    ASSERT(m_activeCmd != 0 || m_state == DSinterrupted);

    // collect output until next prompt string is found
    
    // accumulate it
    m_output += data;

    // check for a prompt
    int promptStart = findPrompt(m_output);
    if (promptStart >= 0)
    {
	// found prompt!

	// terminate output before the prompt
	m_output.resize(promptStart);

	/*
	 * We've got output for the active command. But if it was
	 * interrupted, ignore it.
	 */
	if (m_state != DSinterrupted) {
	    /*
	     * m_state shouldn't be DSidle while we are parsing the output
	     * so that all commands produced by parse() go into the queue
	     * instead of being written to gdb immediately.
	     */
	    ASSERT(m_state != DSidle);
	    CmdQueueItem* cmd = m_activeCmd;
	    m_activeCmd = 0;
	    commandFinished(cmd);
	    delete cmd;
	}

	// empty buffer
	m_output.clear();
	// also clear delayed output if interrupted
	if (m_state == DSinterrupted) {
	    m_delayedOutput = std::queue<QByteArray>();
	}

	/*
	 * We parsed some output successfully. Unless there's more delayed
	 * output, the debugger must be idle now, so send down the next
	 * command.
	 */
	if (m_delayedOutput.empty()) {
	    if (m_hipriCmdQueue.empty() && m_lopriCmdQueue.empty()) {
		// no pending commands
		m_state = DSidle;
		emit enterIdleState();
	    } else {
		writeCommand();
	    }
	}
    }
}