Ejemplo n.º 1
0
/*
 * Manual context switch.  This is similar to the tick context switch,
 * but does not increment the tick count.  It must be identical to the
 * tick context switch in how it stores the stack of a task.
 */
void vPortYield( void )
{
    /* This can get called with interrupts either enabled or disabled.  We
    will save the INTCON register with the interrupt enable bits unmodified. */
    portSAVE_CONTEXT( portINTERRUPTS_UNCHANGED );

    /* Switch to the highest priority task that is ready to run. */
    vTaskSwitchContext();

    /* Start executing the task we have just switched to. */
    portRESTORE_CONTEXT();
}
Ejemplo n.º 2
0
void vEINT0_ISR_Wrapper( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();

	/* The handler must be a separate function from the wrapper to
	ensure the correct stack frame is set up. */
	vEINT0_ISR_Handler();

	/* Restore the context of whichever task is going to run next. */
	portRESTORE_CONTEXT();
}
Ejemplo n.º 3
0
/**
 @brief Wrapper for the serial interrupt vector.
 
 FreeRTOS can save the context (all registers, stack positions, etc.) 
 so everything doesn't get screwed up because the ARM doesn't do that for you.
*/
void vUART_ISR_Wrapper( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();

	/* Call the handler.  This must be a separate function from the wrapper
	to ensure the correct stack frame is set up. */
	__asm volatile ("bl vUART_ISR_Handler");

	/* Restore the context of whichever task is going to run next. */
	portRESTORE_CONTEXT();
}
Ejemplo n.º 4
0
void vEMACISR_Wrapper( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();
	
	/* Call the handler task to do the actual work.  This must be a separate
	function to ensure the stack frame is correctly set up. */
	__asm volatile ("bl vEMACISR_Handler");
	
	/* Restore the context of whichever task is the next to run. */
	portRESTORE_CONTEXT();
}
Ejemplo n.º 5
0
void vI2C_ISR_Wrapper( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();

	/* Call the handler to perform the actual work.  This must be a
	separate function to ensure the correct stack frame is set up. */
	vI2C_ISR_Handler();

	/* Restore the context of whichever task is going to run next. */
	portRESTORE_CONTEXT();
}
Ejemplo n.º 6
0
void  vEMACISR_Wrapper( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();

	/* Call the handler to do the work.  This must be a separate
	function to ensure the stack frame is set up correctly. */
	vEMACISR_Handler();

	/* Restore the context of whichever task will execute next. */
	portRESTORE_CONTEXT();
}
void vEMAC_ISR_Wrapper( void )
{
	/* Save the context of the interrupted task. */
    portSAVE_CONTEXT();
    
    /* Call the handler.  This must be a separate function unless you can
    guarantee that no stack will be used. */
    __asm volatile ( "bl vEMAC_ISR_Handler" );
    
    /* Restore the context of whichever task is going to run next. */
    portRESTORE_CONTEXT();
}
Ejemplo n.º 8
0
	interrupt (TIMERA0_VECTOR) prvTickISR( void )
	{
		/* Save the context of the interrupted task. */
		portSAVE_CONTEXT();

		/* Increment the tick count then switch to the highest priority task
		that is ready to run. */
		vTaskIncrementTick();
		vTaskSwitchContext();

		/* Restore the context of the new task. */
		portRESTORE_CONTEXT();
	}
Ejemplo n.º 9
0
void vButtonISRWrapper( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();

	/* Call the handler to do the work.  This must be a separate function to
	the wrapper to ensure the correct stack frame is set up. */
	__asm volatile( "bl vButtonHandler" );

	/* Restore the context of whichever task is going to run once the interrupt
	completes. */
	portRESTORE_CONTEXT();
}
Ejemplo n.º 10
0
void vPortYieldFromTick( void )
{
	portSAVE_CONTEXT();

	if( xTaskIncrementTick() != pdFALSE )
	{
		vTaskSwitchContext();
	}

	portRESTORE_CONTEXT();

	__asm__ __volatile__ ( "ret" );
}
Ejemplo n.º 11
0
void i2c_isr()
{
	portSAVE_CONTEXT();
	//i2c_stateMachine();
	if (i2c_stateMachine())     //run the state machine code.
	{   //finished sending/receiving data.
		signed portBASE_TYPE prio_task; xSemaphoreGiveFromISR(i2c_done, &prio_task);
	} else { //not done yet.
		portYIELD_FROM_ISR(); //let other tasks happen, we're not done with the state machine yet.
	}
	VICVectAddr = 0;	//Acknowledge interrupt
	portRESTORE_CONTEXT();
}
Ejemplo n.º 12
0
ISR (TCC0_OVF_vect, ISR_NAKED) {
    /*
     * Context switch function used by the tick.  This must be identical to
     * vPortYield() from the call to vTaskSwitchContext() onwards.  The only
     * difference from vPortYield() is the tick count is incremented as the
     * call comes from the tick ISR.
     */
    portSAVE_CONTEXT();
    vTaskIncrementTick();
    vTaskSwitchContext();
    portRESTORE_CONTEXT();
    asm volatile ( "reti" );
}
Ejemplo n.º 13
0
static void
prvPortPreemptiveTick( void )
{
    asm volatile ( "move.w  #0x2700, %sr\n\t" );
#if _GCC_USES_FP == 1
    asm volatile ( "unlk %fp\n\t" );
#endif
    portSAVE_CONTEXT(  );
    MCF_PIT_PCSR0 |= MCF_PIT_PCSR_PIF;
    vTaskIncrementTick(  );
    vTaskSwitchContext(  );
    portRESTORE_CONTEXT(  );
}
Ejemplo n.º 14
0
void vUSB_ISR_Wrapper( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();

	/* Call the handler itself.  This must be a separate function as it uses
	the stack. */
	__asm volatile ("bl vUSB_ISR_Handler");

	/* Restore the context of the task that is going to 
	execute next. This might not be the same as the originally 
	interrupted task.*/
	portRESTORE_CONTEXT();
}
Ejemplo n.º 15
0
void spi_isr(void)
{
    portSAVE_CONTEXT();
    static signed portBASE_TYPE xHigherPriorityTaskWoken= pdFALSE;
    //FIO1PIN = FIO1PIN ^ (1<<19);   
    //Between Boilerplate..
    S0SPINT |= (1<<0);      //Clear SPI Interrupt Flag by writing a 1 to it.
    VICVectAddr = 0x0;      // Update VIC hardware
    xSemaphoreGiveFromISR( spi_IntSemaphore, &xHigherPriorityTaskWoken );
    if( xHigherPriorityTaskWoken ) {
	    portYIELD_FROM_ISR();
    }
    
    portRESTORE_CONTEXT();
}
Ejemplo n.º 16
0
	void prvTickISR( void )
	{
		/* Save the context of the interrupted task. */
		portSAVE_CONTEXT();

		/* Increment the tick count then switch to the highest priority task
		that is ready to run. */
		if( xTaskIncrementTick() != pdFALSE )
		{
			vTaskSwitchContext();
		}

		/* Restore the context of the new task. */
		portRESTORE_CONTEXT();
	}
Ejemplo n.º 17
0
void audioIsr_Wrapper( void )
{
    /* Save the context of the interrupted task. */
    portSAVE_CONTEXT();

#ifdef CFG_DEEP_SLEEP
    check_power_mode();
#endif

    /* Call the handler to do the work.  This must be a separate
       function to ensure the stack frame is set up correctly. */
    audio_isr();

    /* Restore the context of whichever task will execute next. */
    portRESTORE_CONTEXT();
}
Ejemplo n.º 18
0
/*
 * Called by portYIELD() or taskYIELD() to manually force a context switch.
 */
static void
prvPortYield( void )
{
    asm volatile ( "move.w  #0x2700, %sr\n\t" );
#if _GCC_USES_FP == 1
    asm volatile ( "unlk %fp\n\t" );
#endif
     /* Perform the context switch.  First save the context of the current task. */
    portSAVE_CONTEXT(  );

    /* Find the highest priority task that is ready to run. */
    vTaskSwitchContext(  );

    /* Restore the context of the new task. */
    portRESTORE_CONTEXT(  );
}
Ejemplo n.º 19
0
/*
 * Called by portYIELD() or taskYIELD() to manually force a context switch.
 *
 * When a context switch is performed from the task level the saved task 
 * context is made to look as if it occurred from within the tick ISR.  This
 * way the same restore context function can be used when restoring the context
 * saved from the ISR or that saved from a call to vPortYieldProcessor.
 */
void vPortYieldProcessor( void )
{
	/* Within an IRQ ISR the link register has an offset from the true return 
	address, but an SWI ISR does not.  Add the offset manually so the same 
	ISR return code can be used in both cases. */
	__asm volatile ( "ADD		LR, LR, #4" );

	/* Perform the context switch.  First save the context of the current task. */
	portSAVE_CONTEXT();

	/* Find the highest priority task that is ready to run. */
	__asm volatile( "bl			vTaskSwitchContext" );

	/* Restore the context of the new task. */
	portRESTORE_CONTEXT();	
}
/******************************************************************************
 External interrupt 0 handler
******************************************************************************/
void irq0Handler(void)
{
	//LOG(__FUNCTION__);
#if defined(FREE_RTOS)
  portSAVE_CONTEXT();
#endif

  if (NULL != IrqCallbackList[HAL_FIRST_VALID_IRQ])
    IrqCallbackList[HAL_FIRST_VALID_IRQ]();

#if defined(FREE_RTOS)
  /* End the interrupt in the AIC. */
  AT91C_BASE_AIC->AIC_EOICR = 0;

  portRESTORE_CONTEXT();
#endif
}
Ejemplo n.º 21
0
	void vPreemptiveTick( void )
	{
		/* Save the context of the interrupted task. */
		portSAVE_CONTEXT();	

		/* Increment the RTOS tick count, then look for the highest priority 
		task that is ready to run. */
		__asm volatile( "bl vTaskIncrementTick" );
		__asm volatile( "bl vTaskSwitchContext" );

		/* Ready for the next interrupt. */
		T0IR = 2;
		VICVectAddr = portCLEAR_VIC_INTERRUPT;
		
		/* Restore the context of the new task. */
		portRESTORE_CONTEXT();
	}
Ejemplo n.º 22
0
	void vPreemptiveTick( void )
	{
		/* Save the context of the current task. */
		portSAVE_CONTEXT();

		/* Increment the tick count - this may wake a task. */
		if( xTaskIncrementTick() != pdFALSE )
		{
			/* Find the highest priority task that is ready to run. */
			vTaskSwitchContext();
		}

		/* End the interrupt in the AIC. */
		AT91C_BASE_AIC->AIC_EOICR = AT91C_BASE_PITC->PITC_PIVR;

		portRESTORE_CONTEXT();
	}
Ejemplo n.º 23
0
void vFreeRTOS_IRQInterrupt ( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();

	ulCriticalNesting++;

	__asm volatile( "clrex" );

	/* Call the handler provided with the standalone BSP */
	__asm volatile( "bl IRQInterrupt" );

	ulCriticalNesting--;

	/* Restore the context of the new task. */
	portRESTORE_CONTEXT();
}
Ejemplo n.º 24
0
void vPortYield( void )
{
	/* We want the stack of the task being saved to look exactly as if the task
	was saved during a pre-emptive RTOS tick ISR.  Before calling an ISR the 
	msp430 places the status register onto the stack.  As this is a function 
	call and not an ISR we have to do this manually. */
	asm volatile ( "push	r2" );
	_DINT();

	/* Save the context of the current task. */
	portSAVE_CONTEXT();

	/* Switch to the highest priority task that is ready to run. */
	vTaskSwitchContext();

	/* Restore the context of the new task. */
	portRESTORE_CONTEXT();
}
Ejemplo n.º 25
0
void vPortPreemptiveTick( void )
{
    /* Save the context of the interrupted task. */
    portSAVE_CONTEXT();	

    /* Increment the RTOS tick count, then look for the highest priority 
     * task that is ready to run. 
     */
    vTaskIncrementTick();
    vTaskSwitchContext();

    /* Clear the interrupt in the watchdog and EIC. */
	WDG->SR = 0x0000;
    /* clear current interrupt pending flag for interupt source. */
    EIC->IPR |= 1 << EIC_CurrentIRQChannelValue();
    
    /* Restore the context of the new task. */
    portRESTORE_CONTEXT();
}
Ejemplo n.º 26
0
void vPortYieldFromTick( void )
{
	portSAVE_CONTEXT();

	if (--ticksRemainingInSec == 0)
	{
		system_tick();
		ticksRemainingInSec = portTickRateHz;
	}

	if( xTaskIncrementTick() != pdFALSE )
	{
		vTaskSwitchContext();
	}

	portRESTORE_CONTEXT();

	asm volatile ( "ret" );
}
Ejemplo n.º 27
0
void vTickISR( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT();	

	/* Increment the RTOS tick count, then look for the highest priority 
	task that is ready to run. */
	__asm volatile( "bl vTaskIncrementTick" );

	#if configUSE_PREEMPTION == 1
		__asm volatile( "bl vTaskSwitchContext" );
	#endif

	/* Ready for the next interrupt. */
	T0_IR = portTIMER_MATCH_ISR_BIT;
	VICVectAddr = portCLEAR_VIC_INTERRUPT;
	
	/* Restore the context of the new task. */
	portRESTORE_CONTEXT();
}
/**************************************************************************//**
\brief TWI interrupt handler.
******************************************************************************/
void twiHandler(void)
{
#if defined(FREE_RTOS)
  portSAVE_CONTEXT();
#endif

  if (I2C_PACKET_READ_DATA == halI2cDesc->service.state)
  { // It is necessary for problem-solving NACK Status Bit Lost.
    // Reading status register is not allowed.
    if (AT91C_BASE_TWI->TWI_IMR & AT91C_TWI_TXCOMP)
      halTransactionCompleteI2c();
    else
      halReadByteDoneI2c();
  }
  else
  {
    volatile uint32_t status;

    status = AT91C_BASE_TWI->TWI_SR;
    if ((status & AT91C_TWI_TXCOMP) && (AT91C_BASE_TWI->TWI_IMR & AT91C_TWI_TXCOMP))
    {
      halTransactionCompleteI2c();
    }
    else if ((status & AT91C_TWI_TXRDY) && (AT91C_BASE_TWI->TWI_IMR & AT91C_TWI_TXRDY))
    {
      halWriteByteDoneI2c();
    }
    else if ((status & AT91C_TWI_NACK) && (AT91C_BASE_TWI->TWI_IMR & AT91C_TWI_NACK))
    {
      halI2cBusError();
    }
  }

#if defined(FREE_RTOS)
  /* End the interrupt in the AIC. */
  AT91C_BASE_AIC->AIC_EOICR = 0;

  portRESTORE_CONTEXT();
#endif
}
Ejemplo n.º 29
0
/* Read the incoming interrupt and then jump to the appropriate ISR */
void vIRQHandler ( void ) {
    portSAVE_CONTEXT();

//	serial_puts("Entering IRQ...\n");

    /* If this is IRQ_38 then jump to vTickISR */
    if((*(REG32(MPU_INTC + INTCPS_SIR_IRQ))) == 37)
    {
        vTickISR();//__asm volatile ("bl vTickISR");
    }

    //Malik: I deleted serial code, so commented
    else if((*(REG32(MPU_INTC + INTCPS_SIR_IRQ)))==74)
    {
        vUART_ISR_Handler();//__asm volatile ("bl vUART_ISR_Handler");
    }

//	serial_puts("Exiting IRQ...\n");

    portRESTORE_CONTEXT();

}
/****************************************************************
  RF interrupt service routine.
****************************************************************/
void irqRfHandler(void)
{
  //configure_dbgu();
	//LOG(__FUNCTION__);
	  //LOG("\n");
#if defined(PLATFORM_deRFarm7) || defined(PLATFORM_CUSTOM_1) || defined(PLATFORM_CUSTOM_2)
  #if defined(FREE_RTOS)
    portSAVE_CONTEXT();
  #endif
#endif

  phyDispatcheRfInterrupt();

#if defined(PLATFORM_deRFarm7) || defined(PLATFORM_CUSTOM_1) || defined(PLATFORM_CUSTOM_2)
  #if defined(FREE_RTOS)
    /* End the interrupt in the AIC. */
    AT91C_BASE_AIC->AIC_EOICR = 0;

    portRESTORE_CONTEXT();
  #endif
#endif
}