示例#1
0
void nRF_IRQ_ISR(void)
{
	BaseType_t xResult, xHigherPriorityTaskWoken;
	uint8_t RegValue;

	RegValue = nRF_SPI_IO_ReadReg(nRF_STATUS);
	nRF_SPI_IO_WriteReg(nRF_WRITE_REG+nRF_STATUS, 0xFF);
	
	xHigherPriorityTaskWoken = pdFALSE;
	
	if (RegValue & nRF_TX_OK)
	{
		xResult = xEventGroupSetBitsFromISR(xEventGruop, nRF_State_TX_OK, &xHigherPriorityTaskWoken);
	}
	else if(RegValue & nRF_MAX_TX)
	{
		xResult = xEventGroupSetBitsFromISR(xEventGruop, nRF_State_TX_MAX, &xHigherPriorityTaskWoken);
	}
	if (RegValue & nRF_RX_OK)
	{
		nRF_SPI_IO_ReadData(nRF_RD_RX_PLOAD, (uint8_t *)&nRF_Buf, nRF_RX_PLOAD_WIDTH);
		nRF_CSN_LOW();
		nRF_SPI_IO_WriteReg(nRF_FLUSH_RX, 0xFF);
		nRF_CSN_HIGH();
		xResult = xEventGroupSetBitsFromISR(xEventGruop, nRF_State_RX_OK, &xHigherPriorityTaskWoken);
	}
	
	if (xResult != pdFAIL)
	{
		portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
	}
}
示例#2
0
static void prvCDCDataReceivedCallback( uint32_t ulUnused, uint8_t ucStatus, uint32_t ulBytesReceived, uint32_t ulBytesRemaining )
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
static uint32_t ulNextRxPosition = 0;

	( void ) ulUnused;
	( void ) ucStatus;
	( void ) ulBytesRemaining;

	/* If bytes were received then store the number of bytes placed into the Rx
	buffer. */
	if( ucStatus == USBD_STATUS_SUCCESS )
	{
		ulBytesAvailable += ulBytesReceived;

		/* Restart the Rx position from a buffer position past the newly
		received data. */
		ulNextRxPosition += ulBytesReceived;

		if( ulNextRxPosition >= cmdMAX_INPUT_SIZE )
		{
			ulNextRxPosition = 0;
		}
		CDCDSerialDriver_Read( pcRxBuffer + ulNextRxPosition, cmdMAX_INPUT_SIZE - ulNextRxPosition, ( TransferCallback ) prvCDCDataReceivedCallback, 0 );

		/* Ensure the task knows new data is available. */
		xEventGroupSetBitsFromISR( xCDCEventBits, cmdRX_COMPLETE_BIT, &xHigherPriorityTaskWoken );
		portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
	}
}
示例#3
0
void HMC_ISR(void)
{
	BaseType_t xResult, xHigherPriorityTaskWoken;

	xResult = xEventGroupSetBitsFromISR(xEventGroup, HMC_DATA_READY, &xHigherPriorityTaskWoken);

}
示例#4
0
void IRAM_ATTR gpio_isr_handler_up(void* arg)
{
    uint32_t gpio_num = (uint32_t) arg;
    (void)gpio_num;

    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    xEventGroupSetBitsFromISR(g_pot_event_group, POT_PORT1_BIT, &xHigherPriorityTaskWoken);

    portYIELD_FROM_ISR();
}
示例#5
0
void MPU9050_ISR(void)
{
	BaseType_t xResult, xHigherPriorityTaskWoken;

	xResult = xEventGroupSetBitsFromISR(xEventGroup, MPU_DATA_READY, &xHigherPriorityTaskWoken);
	
	if (xResult != pdFAIL)
	{
		portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
	}
}
示例#6
0
void vPeriodicEventGroupsProcessing( void )
{
    static BaseType_t xCallCount = 0, xISRTestError = pdFALSE;
    const BaseType_t xSetBitCount = 100, xGetBitsCount = 200, xClearBitsCount = 300;
    const EventBits_t uxBitsToSet = 0x12U;
    EventBits_t uxReturned;
    BaseType_t xMessagePosted;

    /* Called periodically from the tick hook to exercise the "FromISR"
    functions. */

    xCallCount++;

    if( xCallCount == xSetBitCount ) {
        /* All the event bits should start clear. */
        uxReturned = xEventGroupGetBitsFromISR( xISREventGroup );
        if( uxReturned != 0x00 ) {
            xISRTestError = pdTRUE;
        } else {
            /* Set the bits.  This is called from the tick hook so it is not
            necessary to use the last parameter to ensure a context switch
            occurs immediately. */
            xMessagePosted = xEventGroupSetBitsFromISR( xISREventGroup, uxBitsToSet, NULL );
            if( xMessagePosted != pdPASS ) {
                xISRTestError = pdTRUE;
            }
        }
    } else if( xCallCount == xGetBitsCount ) {
        /* Check the bits were set as expected. */
        uxReturned = xEventGroupGetBitsFromISR( xISREventGroup );
        if( uxReturned != uxBitsToSet ) {
            xISRTestError = pdTRUE;
        }
    } else if( xCallCount == xClearBitsCount ) {
        /* Clear the bits again. */
        uxReturned = ( EventBits_t ) xEventGroupClearBitsFromISR( xISREventGroup, uxBitsToSet );

        /* Check the message was posted. */
        if( uxReturned != pdPASS ) {
            xISRTestError = pdTRUE;
        }

        /* Go back to the start. */
        xCallCount = 0;

        /* If no errors have been detected then increment the count of test
        cycles. */
        if( xISRTestError == pdFALSE ) {
            ulISRCycles++;
        }
    } else {
        /* Nothing else to do. */
    }
}
示例#7
0
static void prvCDCDataTransmittedCallback( uint32_t ulUnused, uint8_t ucStatus, uint32_t ulBytesSent, uint32_t ulBytesRemaining )
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;

	( void ) ulUnused;
	( void ) ucStatus;
	( void ) ulBytesRemaining;
	( void ) ulBytesSent;

	xEventGroupSetBitsFromISR( xCDCEventBits, cmdTX_COMPLETE_BIT, &xHigherPriorityTaskWoken );
	portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
示例#8
0
/*****************************************************************************
 Prototype    : DMA1_Channel3_IRQHandler
 Description  : uart3 DMA-Rx handler
 Input        : void  
 Output       : None
 Return Value : 
 Calls        : 
 Called By    : 
 
  History        :
  1.Date         : 2015/9/7
    Author       : qiuweibo
    Modification : Created function

*****************************************************************************/
void DMA1_Channel3_IRQHandler(void)
{
    BaseType_t xHigherPriorityTaskWoken, xResult;

    // xHigherPriorityTaskWoken must be initialised to pdFALSE.
    xHigherPriorityTaskWoken = pdFALSE;

    DMA_ClearITPendingBit(DMA1_IT_TC3); 
    DMA_Cmd(DMA1_Channel3, DISABLE);            //close DMA incase receive data while handling

    if( pdTRUE != xSemaphoreTakeFromISR( xSerialRxHandleLock, &xHigherPriorityTaskWoken))
    {
        return;
    }

    if (uart3_rx_dma_buf.IdleBufferIndex) //buf1 busy, buf2 idle
    {
        //buffer1 finished recevied mission (full), switch to buffer2
        uart3_rx_dma_buf.nBuff1Offset = uart3_rx_dma_buf.nBuff1MaxLength;
        
        DMA1_Channel3->CMAR = (uint32_t)uart3_rx_dma_buf.pPingPongBuff2;
        DMA1_Channel3->CNDTR = uart3_rx_dma_buf.nBuff2MaxLength;
        uart3_rx_dma_buf.IdleBufferIndex = 0;
    }
    else //buf2 busy, buf1 idle
    {
        //buffer2 finished recevied mission (full), switch to buffer1
        uart3_rx_dma_buf.nBuff2Offset = uart3_rx_dma_buf.nBuff2MaxLength;
        
        DMA1_Channel3->CMAR = (uint32_t)uart3_rx_dma_buf.pPingPongBuff1;
        DMA1_Channel3->CNDTR = uart3_rx_dma_buf.nBuff1MaxLength;
        uart3_rx_dma_buf.IdleBufferIndex = 1;
    }
    xSemaphoreGiveFromISR( xSerialRxHandleLock ,&xHigherPriorityTaskWoken);
    DMA_Cmd(DMA1_Channel3, ENABLE);             //open DMA after handled

    //boardcast message to handle
    xResult = xEventGroupSetBitsFromISR(
                    xUart3RxEventGroup,             // The event group being updated.
                    UART_DMA_RX_COMPLETE_EVENT_BIT, // The bits being set.
                    &xHigherPriorityTaskWoken );

    // Was the message posted successfully?
    if( xResult == pdPASS )
    {
        // If xHigherPriorityTaskWoken is now set to pdTRUE then a context
        // switch should be requested.  The macro used is port specific and 
        // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - 
        // refer to the documentation page for the port being used.
        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
    }
}
示例#9
0
// Callbacks
static void IMU_interrupt(void) {
    if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) {
        static BaseType_t xHigherPriorityTaskWoken = pdFALSE;

        // set the int state bit to wake the IMU Task
        xEventGroupSetBitsFromISR(imuTask.eventGroup,
                                  IMU_INT_BIT,
                                  &xHigherPriorityTaskWoken);

        if (xHigherPriorityTaskWoken) {
            portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
        }
    }
}
示例#10
0
文件: i2c.c 项目: cocobot/mcual
static void mcual_i2c_stop(mcual_i2c_id_t id, int success)
{
  I2C_TypeDef * reg = mcual_i2c_get_register(id);

  reg->CR2 &= ~(I2C_CR2_ITEVTEN | I2C_CR2_ITERREN);
  I2C1->SR1 = 0;
  I2C1->SR2 = 0;

  BaseType_t xHigherPriorityTaskWoken = pdFALSE;
  BaseType_t xResult = pdFALSE;
  if(success)
  {
    xResult =  xEventGroupSetBitsFromISR(transfer_done[id], 1 << MCUAL_I2C_SUCCESS, &xHigherPriorityTaskWoken);
  }
  else
  {
    xResult = xEventGroupSetBitsFromISR(transfer_done[id], 1 << MCUAL_I2C_FAIL, &xHigherPriorityTaskWoken);
  }

  if(xResult != pdFAIL)
  {
    portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
  }
}
/*FUNCTION**********************************************************************
 *
 * Function Name : OSA_EventSet
 * Description   : Set one or more event flags of an event object.
 * Return kStatus_OSA_Success if set successfully, kStatus_OSA_Error if failed.
 *
 *END**************************************************************************/
osa_status_t OSA_EventSet(event_t *pEvent, event_flags_t flagsToSet)
{
    assert(pEvent);
    portBASE_TYPE taskToWake = pdFALSE;

    if (__get_IPSR())
    {
        xEventGroupSetBitsFromISR(pEvent->eventHandler, flagsToSet, &taskToWake);
        if (pdTRUE == taskToWake)
        {
            vPortYieldFromISR();
        }
    }
    else
    {
        xEventGroupSetBits(pEvent->eventHandler, flagsToSet);
    }
    return kStatus_OSA_Success;
}
示例#12
0
/// Set the specified Signal Flags of an active thread.
/// \param[in]     thread_id     thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
/// \param[in]     signals       specifies the signal flags of the thread that should be set.
/// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
/// \note MUST REMAIN UNCHANGED: \b osSignalSet shall be consistent in every CMSIS-RTOS.
int32_t osSignalSet (osThreadId thread_id, int32_t signals)
{
    EventGroupHandle_t event_handle;
    portBASE_TYPE taskWoken = pdFALSE;
    portBASE_TYPE xResult;
    EventBits_t uxBits_ret=0x80000000;
#ifdef CHECK_VALUE_OF_EVENT_GROUP    
    EventBits_t uxBits;
#endif    

    if (signals & (0xFFFFFFFF << osFeature_Signals)) {
        return 0x80000000;
    }

    event_handle = find_signal_by_thread(thread_id);
    if (event_handle) {
        if (inHandlerMode()) {
            uxBits_ret = xEventGroupGetBitsFromISR(event_handle);
            xResult = xEventGroupSetBitsFromISR(
                            event_handle,    /* The event group being updated. */
                            signals,         /* The bits being set. */
                            &taskWoken );
            if( xResult != pdFAIL )
            {
                portYIELD_FROM_ISR(taskWoken);
            }
        }
        else {
            uxBits_ret = xEventGroupGetBits(event_handle);
#ifdef CHECK_VALUE_OF_EVENT_GROUP                
            uxBits = 
#endif              
                      xEventGroupSetBits(
                           event_handle,    /* The event group being updated. */
                           signals );/* The bits being set. */
        }
    }

    return uxBits_ret;
}
示例#13
0
/*FUNCTION**********************************************************************
 *
 * Function Name : OSA_EventSet
 * Description   : Set one or more event flags of an event object.
 * Return        : osaStatus_Success if set successfully, osaStatus_Error if failed.
 *
 *END**************************************************************************/
osaStatus_t OSA_EventSet(osaEventId_t eventId, osaEventFlags_t flagsToSet)
{
#if osNumberOfEvents    
  osEventStruct_t* pEventStruct; 
  portBASE_TYPE taskToWake = pdFALSE;
  if(osObjectIsAllocated(&osEventInfo, eventId) == FALSE)
  {
    return osaStatus_Error;
  }
  pEventStruct = (osEventStruct_t*)eventId;  
  if(pEventStruct->event.eventHandler == NULL)
  {
    return osaStatus_Error;
  }
  if (__get_IPSR())
  {
    if (pdPASS != xEventGroupSetBitsFromISR(pEventStruct->event.eventHandler, (event_flags_t)flagsToSet, &taskToWake))
    {
      panic(0,(uint32_t)OSA_EventSet,0,0);
      return osaStatus_Error;
    }
    if (pdTRUE == taskToWake)
    {
      portYIELD_FROM_ISR(taskToWake);
    }
  }
  else
  {
    xEventGroupSetBits(pEventStruct->event.eventHandler, (event_flags_t)flagsToSet);
  }
  return osaStatus_Success;
#else
  (void)eventId;
  (void)flagsToSet;  
  return osaStatus_Error;
#endif  
}
示例#14
0
void USART3_IRQHandler(void)
{
    volatile u32 tem_reg;
    volatile u16 u16BufferUsedLen = 0;
    BaseType_t xHigherPriorityTaskWoken, xResult;

    // xHigherPriorityTaskWoken must be initialised to pdFALSE.
    xHigherPriorityTaskWoken = pdFALSE;
    
    // error happen
    if(USART_GetITStatus(USART3, USART_IT_PE) != RESET)
    {
        USART_ClearITPendingBit(USART3, USART_IT_PE);
        xSerialRxParityFlag = DMA_UART_PACKET_PARITY_ERR;
    }
    
    // uart idle interrupt
    if(USART_GetITStatus(USART3, USART_IT_IDLE) != RESET)
    {
        USART_ClearITPendingBit(USART3, USART_IT_IDLE);
        DMA_ClearFlag(DMA1_FLAG_GL3);//clear all interrupt flags     
        DMA_Cmd(DMA1_Channel3, DISABLE); //close DMA incase receive data while handling
        
        xResult = xSemaphoreTakeFromISR( xSerialRxHandleLock, &xHigherPriorityTaskWoken);
        if( pdTRUE == xResult)
        {
            if (uart3_rx_dma_buf.IdleBufferIndex) //buf1 busy, buf2 idle
            {
                u16BufferUsedLen = uart3_rx_dma_buf.nBuff1MaxLength - DMA_GetCurrDataCounter(DMA1_Channel3); 
                if (u16BufferUsedLen > 0)
                {
                    uart3_rx_dma_buf.nBuff1Offset = u16BufferUsedLen;
                    DMA1_Channel3->CMAR = (uint32_t)uart3_rx_dma_buf.pPingPongBuff2;
                    DMA1_Channel3->CNDTR = uart3_rx_dma_buf.nBuff2MaxLength;
                    uart3_rx_dma_buf.IdleBufferIndex = 0;
                }
            }
            else
            {
                u16BufferUsedLen = uart3_rx_dma_buf.nBuff2MaxLength - DMA_GetCurrDataCounter(DMA1_Channel3); 
                if (u16BufferUsedLen > 0)
                {
                    uart3_rx_dma_buf.nBuff2Offset = u16BufferUsedLen;
                    DMA1_Channel3->CMAR = (uint32_t)uart3_rx_dma_buf.pPingPongBuff1;
                    DMA1_Channel3->CNDTR = uart3_rx_dma_buf.nBuff1MaxLength;
                    uart3_rx_dma_buf.IdleBufferIndex = 1;
                }
            }
            xResult = xSemaphoreGiveFromISR( xSerialRxHandleLock ,&xHigherPriorityTaskWoken);

            if (u16BufferUsedLen > 0)
            {
                //boardcast message to handle
                xResult = xEventGroupSetBitsFromISR(
                                xUart3RxEventGroup,	// The event group being updated.
                                UART_DMA_RX_INCOMPLETE_EVENT_BIT,// The bits being set.
                                &xHigherPriorityTaskWoken );
            } //End if u16BufferUsedLen > 0
        }// End if pdTRUE == xSemaphoreTakeFromISR
        DMA_Cmd(DMA1_Channel3, ENABLE);                 //open DMA after handled
        
        //clear Idle flag by read SR and DR
        tem_reg = USART3->SR;
        tem_reg = USART3->DR;
        tem_reg = tem_reg; // slove warning 
    }// End if USART_IT_IDLE
    
    if(USART_GetITStatus(USART3, USART_IT_FE | USART_IT_NE) != RESET)
    {
        USART_ClearITPendingBit(USART3, USART_IT_FE | USART_IT_NE);
    }

    if( xResult == pdPASS )
    {
        // If xHigherPriorityTaskWoken is now set to pdTRUE then a context
        // switch should be requested.  The macro used is port specific and 
        // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - 
        // refer to the documentation page for the port being used.
        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
    }
}