예제 #1
0
static void finISR(timer16_Sequence_t timer) {
  // Disable use of the given timer
  #ifdef WIRING
    if (timer == _timer1) {
      #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
        TIMSK1
      #else
        TIMSK
      #endif
          &= ~_BV(OCIE1A);    // disable timer 1 output compare interrupt
      timerDetach(TIMER1OUTCOMPAREA_INT);
    }
    else if (timer == _timer3) {
      #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
        TIMSK3
      #else
        ETIMSK
      #endif
          &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
      timerDetach(TIMER3OUTCOMPAREA_INT);
    }
  #else //!WIRING
    // For arduino - in future: call here to a currently undefined function to reset the timer
  #endif
}
예제 #2
0
파일: uartsw128.c 프로젝트: ericsims/AVRLib
//! turns off software UART
void uartswOff(void)
{
	// disable interrupts
	cbi(TIMSK, OCIE2);
	cbi(TIMSK, OCIE0);
	cbi(EIMSK, INT2);
	// detach the service routines
	timerDetach(TIMER2OUTCOMPARE_INT);
	timerDetach(TIMER0OUTCOMPARE_INT);
}
예제 #3
0
// turns off software UART
void uartswOff(void)
{
	// disable interrupts
	cbi(TIMSK0, OCIE0A);
	cbi(TIMSK0, OCIE0B);
	cbi(EIMSK, INT1);
	// detach the service routines
	timerDetach(TIMER0OUTCOMPAREA_INT);
	timerDetach(TIMER0OUTCOMPAREB_INT);
}
//! turns off software UART
void uartswOff(void)
{
	// disable interrupts
	cbi(TIMSK0, OCIE2A);
	cbi(TIMSK0, OCIE0A);
	cbi(PCMSK0, PCINT2);
	// detach the service routines
	timerDetach(TIMER2OUTCOMPARE_INT);
	timerDetach(OCIE0A);
}
예제 #5
0
파일: Servo.cpp 프로젝트: jguille2/SA5
///////////////////////////////////////////////////////////////////JGP
static void finISR(timer16_Sequence_t timer)
{
    //disable use of the given timer
#if defined WIRING   // Wiring
  if(timer == _timer1) {
    #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
    TIMSK1 &=  ~_BV(OCIE1A) ;  // disable timer 1 output compare interrupt
    #else
    TIMSK &=  ~_BV(OCIE1A) ;  // disable timer 1 output compare interrupt
    #endif
    timerDetach(TIMER1OUTCOMPAREA_INT);
  }
  else if(timer == _timer3) {
    #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
    TIMSK3 &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
    #else
    ETIMSK &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
    #endif
    timerDetach(TIMER3OUTCOMPAREA_INT);
  }
#else
    //For arduino - in future: call here to a currently undefined function to reset the timer
	//
	//////////////////////////////////////////////////////////////////////JGP
	//Code from wiring.c. Function init. Reseting timer1
/*
	#if defined(TCCR1B) && defined(CS11) && defined(CS10)
		TCCR1B = 0;

		// set timer 1 prescale factor to 64
		sbi(TCCR1B, CS11);
		#if F_CPU >= 8000000L
			sbi(TCCR1B, CS10);
		#endif
	#elif defined(TCCR1) && defined(CS11) && defined(CS10)
		sbi(TCCR1, CS11);
		#if F_CPU >= 8000000L
			sbi(TCCR1, CS10);
		#endif
	#endif
	// put timer 1 in 8-bit phase correct pwm mode
	#if defined(TCCR1A) && defined(WGM10)
		sbi(TCCR1A, WGM10);
	#endif
*/
//Provisional code - tested in Arduino Uno
TCCR1B = 0;
TCCR1B=_BV(CS11);
TCCR1B=_BV(CS10);
TCCR1A=_BV(WGM10);
TIMSK1=0;
	///////////////////////////////////////////////////////////////////////JGP

#endif
}
예제 #6
0
//! turns off software UART
void uartswOff(void)
{
	// disable interrupts
	cbi(TIMSK, OCIE1A);
	cbi(TIMSK, OCIE1B);
	cbi(TIMSK, TICIE1);
	// detach the service routines
	timerDetach(TIMER1OUTCOMPAREA_INT);
	timerDetach(TIMER1OUTCOMPAREB_INT);
	timerDetach(TIMER1INPUTCAPTURE_INT);
}
예제 #7
0
//! turns off software PWM system
void servoOff(void)
{
	// disable the timer1 output compare A interrupt
	cbi(TIMSK, OCIE1A);
	// detach the service routine
	timerDetach(TIMER1OUTCOMPAREA_INT);
}
예제 #8
0
void Servo253::end()
{
  //digitalWrite(48, LOW);
  // disable the timer2 output compare interrupt
  TIMSK &= ~_BV(OCIE2);
  timerDetach(TIMER2OUTCOMPARE_INT);
}
예제 #9
0
void pulseT1Off(void)
{
	// turns pulse outputs off immediately
	
	// set pulse counters to zero (finished)
	PulseT1ACount = 0;
	PulseT1BCount = 0;
	// disconnect OutputCompare action from OC1A pin
	cbi(TCCR1A,COM1A1);
	cbi(TCCR1A,COM1A0);
	// disconnect OutputCompare action from OC1B pin
	cbi(TCCR1A,COM1B1);
	cbi(TCCR1A,COM1B0);
	// detach the pulse service routines
	timerDetach(TIMER1OUTCOMPAREA_INT);
	timerDetach(TIMER1OUTCOMPAREB_INT);
}
예제 #10
0
파일: signal.c 프로젝트: tijuo/Silverbox-OS
int sysRaise( TCB *tcb, int signal, int arg )
{
  dword stack[12];

  if( tcb->sig_handler == NULL )
    return 1;

  if( tcb == currentThread )
    return -2;

  if( tcb->threadState == WAIT_FOR_SEND || tcb->threadState == WAIT_FOR_RECV )
  {
    if( timerDetach( tcb ) == NULL )
      return ESYS_FAIL;
  }

  if( tcb->threadState == WAIT_FOR_SEND )
  {
    tcb->waitThread = NULL;
    tcb->threadState = PAUSED;
    tcb->execState.user.eax = (dword)(signal == SIGTMOUT ? -3 : -2);
    kprintf("receive interrupted\n");
  }
  else if( tcb->threadState == WAIT_FOR_RECV )
  {
    tcb->execState.user.eax = (dword)(signal == SIGTMOUT ? -3 : -2);

    kprintf("send interrupted\n");
    tcb->threadState = PAUSED;

    detachQueue( &tcb->waitThread->threadQueue, tcb );
    tcb->waitThread = NULL;
  }

  stack[0] = (dword)signal;
  stack[1] = (dword)arg;
  memcpy( &stack[2], &tcb->execState.user.edi, 8 * sizeof(dword) );
  stack[5] = tcb->execState.user.userEsp - sizeof stack;
  stack[10] = tcb->execState.user.eflags;
  stack[11] = tcb->execState.user.eip;

  if( pokeVirt( (addr_t)(tcb->execState.user.userEsp - sizeof stack), sizeof stack,
           (addr_t)stack, (addr_t)(tcb->cr3.base << 12) ) != 0 )
  {
    tcb->execState.user.eax = (dword)-1;
    return ESYS_FAIL;
  }

  tcb->execState.user.eip = (dword)tcb->sig_handler;
  tcb->execState.user.userEsp -= sizeof stack;

  if( tcb->threadState != RUNNING && tcb->threadState != READY )
    startThread( tcb );

  return ESYS_OK;
}
예제 #11
0
파일: thread.c 프로젝트: tijuo/Silverbox-OS
int releaseThread( TCB *thread )
{
  #if DEBUG
    TCB *retThread;
  #endif

  assert(thread->threadState != DEAD);

  if( thread->threadState == DEAD )
    return -1;

  /* If the thread is a sender waiting for a recipient, remove the
     sender from the recipient's wait queue. If the thread is a
     receiver, clear its wait queue after
     waking all of the waiting threads. */

  switch( thread->threadState )
  {
    /* Assumes that a ready/running thread can't be on the timer queue. */

    case READY:
      #if DEBUG
        retThread =
      #endif /* DEBUG */

      detachQueue( &runQueues[thread->priority], thread );

      assert( retThread == thread );
      break;
    case WAIT_FOR_RECV:
    case WAIT_FOR_SEND:
    case SLEEPING:
      #if DEBUG
       retThread =
      #endif /* DEBUG */

      timerDetach( thread );

      assert( retThread == thread );
      break;
  }

  /* XXX: Are these implemented properly? */

  if( thread->threadState == WAIT_FOR_SEND )
  {
    TCB *waitingThread;

    while( (waitingThread=popQueue( &thread->threadQueue )) != NULL )
    {
      waitingThread->threadState = READY;
      attachRunQueue(waitingThread);
    }
  }
  else if( thread->threadState == WAIT_FOR_RECV )
  {
    assert( thread->waitThread != NULL ); // XXX: Why?

    detachQueue( &thread->waitThread->threadQueue, thread );
  }

  memset(thread, 0, sizeof *thread);
  thread->threadState = DEAD;

  enqueue(&freeThreadQueue, thread);
  return 0;
}