当前位置: 首页>>代码示例>>C++>>正文


C++ xQueueReceiveFromISR函数代码示例

本文整理汇总了C++中xQueueReceiveFromISR函数的典型用法代码示例。如果您正苦于以下问题:C++ xQueueReceiveFromISR函数的具体用法?C++ xQueueReceiveFromISR怎么用?C++ xQueueReceiveFromISR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xQueueReceiveFromISR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: vSerialISR

/* Serial port ISR.  This can cause a context switch so is not defined as a
standard ISR using the __irq keyword.  Instead a wrapper function is defined
within serialISR.s79 which in turn calls this function.  See the port
documentation on the FreeRTOS.org website for more information. */
__arm void vSerialISR( void )
{
unsigned short usStatus;
signed char cChar;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

	/* What caused the interrupt? */
	usStatus = UART_FlagStatus( UART0 );

	if( usStatus & UART_TxHalfEmpty )
	{
		/* The interrupt was caused by the THR becoming empty.  Are there any
		more characters to transmit? */
		if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
		{
			/* A character was retrieved from the queue so can be sent to the
			THR now. */
			UART0->TxBUFR = cChar;
		}
		else
		{
			/* Queue empty, nothing to send so turn off the Tx interrupt. */
			serINTERRUPT_OFF();
		}		
	}

	if( usStatus & 	UART_RxBufFull )
	{
		/* The interrupt was caused by a character being received.  Grab the
		character from the RHR and place it in the queue of received
		characters. */
		cChar = UART0->RxBUFR;
		xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
	}

	/* If a task was woken by either a character being received or a character
	being transmitted then we may need to switch to another task. */
	portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );

	/* End the interrupt in the EIC. */
	portCLEAR_EIC();
}
开发者ID:Eclo,项目名称:FreeRTOS,代码行数:46,代码来源:serial.c

示例2: vSerialISR

/* Serial port ISR.  This can cause a context switch so is not defined as a
standard ISR using the __irq keyword.  Instead a wrapper function is defined
within serialISR.s79 which in turn calls this function.  See the port
documentation on the FreeRTOS.org website for more information. */
__arm void vSerialISR( void )
{
unsigned long ulStatus;
signed char cChar;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

	/* What caused the interrupt? */
	ulStatus = serCOM0->US_CSR &= serCOM0->US_IMR;

	if( ulStatus & AT91C_US_TXRDY )
	{
		/* The interrupt was caused by the THR becoming empty.  Are there any
		more characters to transmit? */
		if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
		{
			/* A character was retrieved from the queue so can be sent to the
			THR now. */
			serCOM0->US_THR = cChar;
		}
		else
		{
			/* Queue empty, nothing to send so turn off the Tx interrupt. */
			vInterruptOff();
		}		
	}

	if( ulStatus & AT91C_US_RXRDY )
	{
		/* The interrupt was caused by a character being received.  Grab the
		character from the RHR and place it in the queue or received 
		characters. */
		cChar = serCOM0->US_RHR;
		xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
	}

	/* If a task was woken by either a character being received or a character 
	being transmitted then we may need to switch to another task. */
	portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );

	/* End the interrupt in the AIC. */
	AT91C_BASE_AIC->AIC_EOICR = 0;
}
开发者ID:aeste,项目名称:freertos,代码行数:46,代码来源:serial.c

示例3: vSoftwareInterruptHandler

void vSoftwareInterruptHandler( void )
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
static unsigned long ulReceivedNumber;

/* The strings are declared static const to ensure they are not allocated to the
interrupt service routine stack, and exist even when the interrupt service routine
is not executing. */
static const char *pcStrings[] =
{
    "String 0\n",
    "String 1\n",
    "String 2\n",
    "String 3\n"
};

    /* Loop until the queue is empty. */
    while( xQueueReceiveFromISR( xIntegerQueue, &ulReceivedNumber, &xHigherPriorityTaskWoken ) != errQUEUE_EMPTY )
    {
        /* Truncate the received value to the last two bits (values 0 to 3 inc.), then
        send the string    that corresponds to the truncated value to the other
        queue. */
        ulReceivedNumber &= 0x03;
        xQueueSendToBackFromISR( xStringQueue, &pcStrings[ ulReceivedNumber ], &xHigherPriorityTaskWoken );
    }

    /* Clear the software interrupt bit using the interrupt controllers
    Clear Pending register. */
    mainCLEAR_INTERRUPT();

    /* xHigherPriorityTaskWoken was initialised to pdFALSE.  It will have then
    been set to pdTRUE only if reading from or writing to a queue caused a task
    of equal or greater priority than the currently executing task to leave the
    Blocked state.  When this is the case a context switch should be performed.
    In all other cases a context switch is not necessary.

    NOTE: The syntax for forcing a context switch within an ISR varies between
    FreeRTOS ports.  The portEND_SWITCHING_ISR() macro is provided as part of
    the Cortex M3 port layer for this purpose.  taskYIELD() must never be called
    from an ISR! */
    portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
开发者ID:Lzyuan,项目名称:STE-LPC1768-,代码行数:42,代码来源:main.c

示例4: prvReceiveFromQueueInSetFromISR

static void prvReceiveFromQueueInSetFromISR( void )
{
    QueueSetMemberHandle_t xActivatedQueue;
    uint32_t ulReceived;

    /* See if any of the queues in the set contain data. */
    xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );

    if( xActivatedQueue != NULL ) {
        /* Reading from the queue for test purposes only. */
        if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS ) {
            /* Data should have been available as the handle was returned from
            xQueueSelectFromSetFromISR(). */
            xQueueSetTasksStatus = pdFAIL;
        }

        /* Ensure the value received was the value expected. */
        prvCheckReceivedValue( ulReceived );
    }
}
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:20,代码来源:QueueSet.c

示例5: UART0_TxISR

/*
 * UART Tx interrupt service routine.
 */
__interrupt void UART0_TxISR( void )
{
signed char			cChar;
signed portBASE_TYPE	xTaskWoken = pdFALSE;

	/* The previous character has been transmitted.  See if there are any
	further characters waiting transmission. */
	if( xQueueReceiveFromISR(xCharsForTx, &cChar, &xTaskWoken) == pdTRUE )
	{
		/* There was another character queued - transmit it now. */
		TDR0 = cChar;
	}
	else
	{
		/* There were no other characters to transmit. */
		sTHREEmpty = pdTRUE;

		/* Disable transmit interrupts */
		SSR0_TIE = 0;
	}
}
开发者ID:BuiChien,项目名称:FreeRTOS-TM4C123GXL,代码行数:24,代码来源:serial.c

示例6: CAN_rx

bool CAN_rx (can_t can, can_msg_t *pCanMsg, uint32_t timeout_ms)
{
    bool ok = false;

    if (CAN_VALID(can) && pCanMsg)
    {
        if (taskSCHEDULER_RUNNING == xTaskGetSchedulerState()) {
            ok = xQueueReceive(g_can_rx_qs[CAN_INDEX(can)], pCanMsg, OS_MS(timeout_ms));
        }
        else {
            uint64_t msg_timeout = sys_get_uptime_ms() + timeout_ms;
            while (! (ok = xQueueReceiveFromISR(g_can_rx_qs[CAN_INDEX(can)], pCanMsg, NULL))) {
                if (sys_get_uptime_ms() > msg_timeout) {
                    break;
                }
            }
        }
    }

    return ok;
}
开发者ID:Bento007,项目名称:SJSU-Superway-2014,代码行数:21,代码来源:can.c

示例7: usb_handle_transfer

/*
 * This code has been adapted from the ST Microelectronics CDC
 * Example, which is covered under the V2 Liberty License:
 * http://www.st.com/software_license_agreement_liberty_v2
 */
static void usb_handle_transfer(void)
{
        portBASE_TYPE hpta = false;
        xQueueHandle queue = serial_get_tx_queue(usb_state.serial);
        uint8_t *buff = usb_state.USB_Tx_Buffer;
        size_t len = 0;

        for (; len < VIRTUAL_COM_PORT_DATA_SIZE; ++len)
                if (!xQueueReceiveFromISR(queue, buff + len, &hpta))
                        break;

        /* Check if we actually have something to send */
	if (len) {
                UserToPMABufferCopy(usb_state.USB_Tx_Buffer,
                                    ENDP1_TXADDR, len);
                SetEPTxCount(ENDP1, len);
                SetEPTxValid(ENDP1);
        }

        portEND_SWITCHING_ISR(hpta);
}
开发者ID:zkdzegede,项目名称:RaceCapture-Pro_firmware,代码行数:26,代码来源:USB-CDC_device_stm32.c

示例8: dma_isr_handler

// DMA interrupt handler. It is called each time a DMA block is finished processing.
static void dma_isr_handler(void)
{
    portBASE_TYPE task_awoken = pdFALSE;

    if (i2s_dma_is_eof_interrupt()) {
        dma_descriptor_t *descr = i2s_dma_get_eof_descriptor();

        if (xQueueIsQueueFullFromISR(dma_queue)) {
            // List of empty blocks is full. Sender don't send data fast enough.
            int dummy;
            underrun_counter++;
            // Discard top of the queue
            xQueueReceiveFromISR(dma_queue, &dummy, &task_awoken);
        }
        // Push the processed buffer to the queue so sender can refill it.
        xQueueSendFromISR(dma_queue, (void*)(&descr->buf_ptr), &task_awoken);
    }
    i2s_dma_clear_interrupt();

    portEND_SWITCHING_ISR(task_awoken);
}
开发者ID:Paasmer,项目名称:esp-open-rtos,代码行数:22,代码来源:i2s_audio_example.c

示例9: vSerialISR

__arm void vSerialISR( void )
{
signed char cChar;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

	do
	{
		if( UART0->MIS & UART_IT_Transmit )
		{
			/* The interrupt was caused by the THR becoming empty.  Are there any
			more characters to transmit? */
			if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
			{
				/* A character was retrieved from the queue so can be sent to the
				THR now. */
				UART0->DR = cChar;
			}
			else
			{
				xQueueEmpty = pdTRUE;		
			}		

			UART_ClearITPendingBit( UART0, UART_IT_Transmit );
		}
	
		if( UART0->MIS & UART_IT_Receive )
		{
			/* The interrupt was caused by a character being received.  Grab the
			character from the RHR and place it in the queue of received
			characters. */
			cChar = UART0->DR;
			xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
			UART_ClearITPendingBit( UART0, UART_IT_Receive );
		}
	} while( UART0->MIS );

	/* If a task was woken by either a character being received or a character
	being transmitted then we may need to switch to another task. */
	portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
开发者ID:DuinOS,项目名称:FreeRTOS,代码行数:40,代码来源:serial.c

示例10: BPL_AllocMessageBufferFromISR

/* This is too slow to use */
unsigned char* BPL_AllocMessageBufferFromISR(void)
{  
  unsigned char * pBuffer = NULL;

  signed portBASE_TYPE HigherPriorityTaskWoken;
  
  // params are: queue handle, ptr to the msg buffer, ticks to wait
  if( pdTRUE != xQueueReceiveFromISR(QueueHandles[FREE_QINDEX], 
                                     &pBuffer, 
                                     &HigherPriorityTaskWoken ))
  {
    PrintString2("@ Alloc Buf frm Isr", CR);
    SetBufferPoolFailureBit();
  }
  
  if ( HigherPriorityTaskWoken == pdTRUE )
  {
    portYIELD();
  }
  
  return pBuffer;
}
开发者ID:ChrisSewell,项目名称:MetaWatch-Gen2,代码行数:23,代码来源:BufferPool.c

示例11: USART1_IRQHandler

void USART1_IRQHandler(void) {

	static signed portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

    if ( USART_GetITStatus(USART1, USART_IT_RXNE) ) {

		if ( xSemaphoreRx != NULL ) {
			if (xQueueReceiveFromISR( xSemaphoreRx, NULL, NULL)) {
				// The first rx buffer is available
				xSemaphoreGiveFromISR( xSemaphoreRx, &xHigherPriorityTaskWoken );
				rb_putc(&rx_buf1, USART1->DR);
			} else {
				// The first rx buffer is locked by the reader task
				// so we have to use the second buffer which is of course available
				rb_putc(&rx_buf2, USART1->DR);
				uart_stats.rx_buff1_busy++;
			}
		}

		uart_stats.rx_bytes++;
    }
}
开发者ID:AlexFielding,项目名称:luba,代码行数:22,代码来源:apc220.c

示例12: osMailGet

/// Get a mail from a queue
/// \param[in]     queue_id      mail queue ID obtained with \ref osMailCreate.
/// \param[in]     millisec      timeout value or 0 in case of no time-out
/// \return event that contains mail information or error code.
/// \note MUST REMAIN UNCHANGED: \b osMailGet shall be consistent in every CMSIS-RTOS.
osEvent osMailGet (osMailQId queue_id, uint32_t millisec)
{
    portBASE_TYPE taskWoken;
    portTickType ticks;
    osEvent event;

    event.def.mail_id = queue_id;

    if (queue_id == NULL) {
        event.status = osErrorParameter;
        return event;
    }

    taskWoken = pdFALSE;

    ticks = millisec_to_ticks(millisec);

    if (inHandlerMode()) {
        if (xQueueReceiveFromISR(queue_id->handle, &event.value.p, &taskWoken) == pdTRUE) {
            /* We have mail */
            event.status = osEventMail;
        }
        else {
            event.status = osOK;
        }
        portEND_SWITCHING_ISR(taskWoken);
    }
    else {
        if (xQueueReceive(queue_id->handle, &event.value.p, ticks) == pdTRUE) {
            /* We have mail */
            event.status = osEventMail;
        }
        else {
            event.status = (ticks == 0) ? osOK : osEventTimeout;
        }
    }

    return event;
}
开发者ID:geliang201201,项目名称:RTL_Ameba,代码行数:44,代码来源:cmsis_os.c

示例13: debug_port_interrupt_handler

//---------------------------------------------------------------------------------------------
void debug_port_interrupt_handler(void)
{
    char c;

    if (USART_GetITStatus(USART1, USART_IT_TXE) == SET)
    {
        if (xQueueReceiveFromISR(txchars_queue, &c, NULL) == pdPASS)
        {
            USART_SendData(USART1, c);
        }
        else
        {
            USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
        }
    }

    if (USART_GetITStatus(USART1, USART_IT_RXNE))
    {
        c = USART_ReceiveData(USART1);
        cmd_echo(c);
    }
}
开发者ID:yangk,项目名称:FreeRTOS_BOARD_DEMO,代码行数:23,代码来源:debug.c

示例14: vCOM_1_Tx_ISR

void vCOM_1_Tx_ISR( void )
{
	/* This can cause a context switch so this macro must be the first line
	in the function. */
	portENTER_SWITCHING_ISR();

	/* As this is a switching ISR the local variables must be declared as 
	static. */
	static char cTxByte;
	static signed portBASE_TYPE xTaskWokenByTx;

		/* This variable is static so must be explicitly reinitialised each
		time the function executes. */
		xTaskWokenByTx = pdFALSE;

		/* The interrupt was caused by the THR becoming empty.  Are there any
		more characters to transmit?  Note whether or not the Tx interrupt has
		woken a task. */
		if( xQueueReceiveFromISR( xCharsForTx, &cTxByte, &xTaskWokenByTx ) == pdTRUE )
		{
			/* A character was retrieved from the queue so can be sent to the
			THR now. */							
			TDR1 = cTxByte;

			/* Clear the interrupt. */
			SSR1 &= ~serTX_INTERRUPT;
		}
		else
		{
			/* Queue empty, nothing to send so turn off the Tx interrupt. */
			serTX_INTERRUPT_OFF();
		}		

	/* This must be the last line in the function.  We pass cTaskWokenByTx so 
	a context switch will occur if the Tx'ed character woke a task that has
	a priority higher than the task we interrupted. */
	portEXIT_SWITCHING_ISR( xTaskWokenByTx );
}
开发者ID:channgo2203,项目名称:TinyROS,代码行数:38,代码来源:serial.c

示例15: USART1_IRQHandler

void USART1_IRQHandler(void)
{
	/*
	if(USART_GetITStatus(USART1, USART_IT_RXNE))
	{
		u8 RxData = (u8)USART_ReceiveData(USART1);
		test[testlen++] = RxData;
	}

	DisplayString(0, 0, (u8*)test);
	*/
	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
	portCHAR cChar;

	if( USART_GetITStatus( USART1, USART_IT_TXE ) == SET )
	{
		/* The interrupt was caused by the THR becoming empty.  Are there any
		more characters to transmit? */
		if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
		{
			/* A character was retrieved from the queue so can be sent to the
			THR now. */
			USART_SendData( USART1, cChar );
		}
		else
		{
			USART_ITConfig( USART1, USART_IT_TXE, DISABLE );		
		}		
	}
	
	if( USART_GetITStatus( USART1, USART_IT_RXNE ) == SET )
	{
		cChar = USART_ReceiveData( USART1 );
		xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
	}	
	
	portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
开发者ID:eloiz07,项目名称:DPC_Touch,代码行数:38,代码来源:sSerial_test2.c


注:本文中的xQueueReceiveFromISR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。