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


C++ UARTCharsAvail函数代码示例

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


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

示例1: UART2_RxTxHandler

static void UART2_RxTxHandler(void)
{
	uint32_t IntStatus, byteCnt, timeout = 1000000;
	uint8_t c;
	IntStatus = UARTIntStatus(UART2_BASE, true);
	UARTIntClear(UART2_BASE, IntStatus);
	if(IntStatus & UART_INT_TX)
	{
		byteCnt = RINGBUF_GetFill(&long_Uart2_TxRingBuf);
		if (byteCnt)
		{
			RINGBUF_Get(&long_Uart2_TxRingBuf, &c);
			UARTCharPutNonBlocking(UART2_BASE, c);
			if (byteCnt == 1)
			{
				UARTIntDisable(UART2_BASE, UART_INT_TX);
			}
		}
		else
		{
			UARTIntDisable(UART2_BASE, UART_INT_TX);
		}
	}
	else if (IntStatus & (UART_INT_RX | UART_INT_RT))
	{
		while(!UARTCharsAvail(UART2_BASE) && (timeout--));
		c = UARTCharGet(UART2_BASE);
		RINGBUF_Put(&long_Uart0_RxRingBuf,c);
	}
	else
	{
		c = UARTCharGet(UART2_BASE);
	}
}
开发者ID:dragon28122007,项目名称:-UNI-VLC_Firmware_REV1.0,代码行数:34,代码来源:long_uart.c

示例2: ReadUARTData

/******************************************************************************
*																			  *
* \brief  Read as many characters from the UART FIFO as we can and move the   *
*         into the CDC transmit buffer.\n                                     *
*                                                                             *
* \param none.																  *
*																		      *
* \return UART error flags read during data reception.                        *
*                                                                             *
******************************************************************************/
static int ReadUARTData(void)
{
    int lChar, lErrors;
    unsigned char ucChar;
    unsigned int ulSpace;

    
    /* Clear our error indicator. */
    
    lErrors = 0;

    
    /* How much space do we have in the buffer? */
    
    ulSpace = USBBufferSpaceAvailable((tUSBBuffer *)&g_sTxBuffer);

    
    /* Read data from the UART FIFO until there is none left or we run
       out of space in our receive buffer.
    */
    while(ulSpace && UARTCharsAvail(USB_UART_BASE))
    {
        
        /* Read a character from the UART FIFO into the ring buffer if no
           errors are reported.
        */
        lChar = UARTCharGetNonBlocking(USB_UART_BASE);

        
        /* If the character did not contain any error notifications,
           copy it to the output buffer.
        */
        if(!(lChar & ~0xFF))
        {
            ucChar = (unsigned char)(lChar & 0xFF);
            USBBufferWrite((tUSBBuffer *)&g_sTxBuffer,
                           (unsigned char *)&ucChar, 1);

            
            /* Decrement the number of bytes we know the buffer can accept. */
            
            ulSpace--;
        }
        else
        {
            
           /* Update our error accumulator. */
            
           lErrors |= lChar;
        }

        /* Update our count of bytes received via the UART. */
        
        g_ulUARTRxCount++;
    }

    /* Pass back the accumulated error indicators. */
    
    return(lErrors);
}
开发者ID:OS-Project,项目名称:Divers,代码行数:70,代码来源:usb_dev_serial.c

示例3: xuart0301Execute

//*****************************************************************************
//
//! xuart0301 test execute main body.
//
//! \return None.
//
//*****************************************************************************
static void xuart0301Execute(void)
{
    unsigned char UartData = 0;
    unsigned char i = 0;
    xtBoolean bTmpBoolean = xfalse;

    UART_Print("\r\nPlease wait 1 s then type the follow string\r\n");
    UART_Print("123456789ABCDE\r\n");

    bTmpBoolean = UARTCharsAvail(UART_BASE);
    TestAssert((xfalse == bTmpBoolean),
            "UART 0301: Function UARTCharsAvail failed!\r\n");
    
    while((UartData = UARTCharGet(UART_BASE)) != '\n')
    {
        UARTCharPut(UART_BASE, UartData);
        if(++i >= 15)
        {
            break;
        }
    }
    UARTCharPut(UART_BASE, '\r');
    UARTCharPut(UART_BASE, '\n');

}
开发者ID:cedar-renjun,项目名称:KL25xx,代码行数:32,代码来源:xuarttest03.c

示例4: Uart2IntHandler

//UART Int Handler. Will handle the data recieved and put in an array. WILL NOT UNDERSTAND JUST STORE
void Uart2IntHandler(void){
	unsigned long ulStatus;

	ulStatus=UARTIntStatus(UART2_BASE, true);	//This reports if the interrupt was a transmit recieve etc, only reports one's setup to be detected in initalization could possibly remove transmit detection

	UARTIntClear(UART2_BASE, ulStatus);	//Clears the interrupt so it does not detect itself.

	if(ulStatus & UART_INT_TX){
		//Transmit was requested I don't think anything needs to be done here I could probably get rid of this and the interrupt for it but for now im leaving it. UARTSend does this job in a cleaner way
	}else if(ulStatus & UART_INT_RX || ulStatus & UART_INT_RT){	//If recieved data
		GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x08);
		while(UARTCharsAvail(UART2_BASE)){	//While there is still data available to read
			char buffer = UARTCharGetNonBlocking(UART2_BASE);	//Read the data into a buffer for scanning
			if((buffer == 0xFA)&&(commandAddress == -2)){	//Is it the first dummy byte
				commandAddress=-1;	//Set the command Address to -1 this way the dummy byte is the only starting byte for a packet to be accepeted
			}else if((buffer == 0xEB)&&(commandAddress == -1)){	//Is the second dummy byte read
				commandAddress=0;	//Prepare to read data the dummy byte's have been validated
			}else if(commandAddress>=0){						//Read in because it's not a dummy byte, prep for reading
				recievedCommands[commandAddress]=buffer;
				commandAddress++;	//Some efficiency could be done here. Remove this line than change the bottom to have ++commandAddress. But that's nitpicky stuff
				commandAddress = (commandAddress>4) ? -2 : commandAddress;			//If greater than 6 set to -1 else set to self
			}
		}
		//UARTCount = ((UARTCount+1)%65534); //Again not sure of datatype sizes so go with what works right.
	}

}
开发者ID:arduic,项目名称:GitHub,代码行数:28,代码来源:main.c

示例5: UART0_Handler

void UART0_Handler()
{
  c_pos_intEnter();

  uint32_t status;

  status = UARTIntStatus(PORTCFG_CON_USART, true);
  UARTIntClear(PORTCFG_CON_USART, status);

  if (status & UART_INT_TX)
    c_nos_putcharReady();

#if NOSCFG_FEATURE_CONIN == 1
  if (status & (UART_INT_RX | UART_INT_RT)) {

    unsigned char ch;

    while (UARTCharsAvail(PORTCFG_CON_USART)) {

      ch = UARTCharGetNonBlocking(PORTCFG_CON_USART);
      c_nos_keyinput(ch);
    }
  }
#endif


  c_pos_intExitQuick();
}
开发者ID:AriZuu,项目名称:picoos,代码行数:28,代码来源:con_usart.c

示例6: UARTinterrupcion

void UARTinterrupcion(void)
{
	char cThisChar;
			int n=0;
			int m_nTxBuffIn1 = 16;
		    unsigned long ulStatus;

		    //
		    // Obtengo el estado de la interrupcion
		    //
		    ulStatus = UARTIntStatus(UART1_BASE, true);
		    //
		    // Limpio los flags de interrupcion
		    //
		    UARTIntClear(UART1_BASE, ulStatus);

		    if(RIGHT_BUTTON){;}

		    if(ulStatus && UART_INT_RX){

		    }
		     while(m_nTxBuffIn1>0 && UARTCharsAvail(UART1_BASE))
		     {
		               //
		               // Lee el proximo caracter de la FIFO de recepcion.
		               //
		     cThisChar = UARTCharGetNonBlocking(UART1_BASE);

		     UARTCharPut(UART0_BASE, cThisChar);

		     m_nTxBuffIn1--;

		     n=n+1;
    }
}
开发者ID:joseomar,项目名称:Proyectos_CCS-TI,代码行数:35,代码来源:main.c

示例7: UARTGenericIntHandler

STATIC void UARTGenericIntHandler(uint32_t uart_id) {
    pyb_uart_obj_t *self;
    uint32_t status;

    if ((self = pyb_uart_find(uart_id))) {
        status = MAP_UARTIntStatus(self->reg, true);
        // receive interrupt
        if (status & (UART_INT_RX | UART_INT_RT)) {
            MAP_UARTIntClear(self->reg, UART_INT_RX | UART_INT_RT);
            while (UARTCharsAvail(self->reg)) {
                int data = MAP_UARTCharGetNonBlocking(self->reg);
                if (MICROPY_STDIO_UART == self->uart_id && data == user_interrupt_char) {
                    // raise exception when interrupts are finished
                    mpexception_keyboard_nlr_jump();
                }
                else if (self->read_buf_len != 0) {
                    uint16_t next_head = (self->read_buf_head + 1) % self->read_buf_len;
                    if (next_head != self->read_buf_tail) {
                        // only store data if room in buf
                        self->read_buf[self->read_buf_head] = data;
                        self->read_buf_head = next_head;
                    }
                }
            }
        }
    }
}
开发者ID:jasongwq,项目名称:micropython,代码行数:27,代码来源:pybuart.c

示例8: UARTIntHandler

void UARTIntHandler(void)
{
	//	UARTCharPut(UART0_BASE, 'a');
	uint32_t ui32Status;
	ui32Status = UARTIntStatus(UART3_BASE, true); //get interrupt status
	//	UARTCharPut(UART0_BASE, 'a');
	UARTIntClear(UART3_BASE, ui32Status); //clear the asserted interrupts

	//	UARTCharPut(UART0_BASE, 'a');
	while(UARTCharsAvail(UART3_BASE)) //loop while there are chars
	{
		//		UARTCharPut(UART0_BASE, 'a');
		char x = UARTCharGetNonBlocking(UART3_BASE);
		UARTCharPut(UART0_BASE, x);
		buf[it++] = x;
	}
	buf[it]='\0';
	char *ptr = strstr(buf,"OK\r\n");
	if(ptr != NULL) {
		SIM908_status = true;
	}
	//	UARTCharPutNonBlocking(UART0_BASE, 'a');
	//  buf[it]='\0';
	//
	//  if(strncmp(buf, "OK", 2) == 0) SIM908_status = true;
	//  else if(strncmp(buf,  "ERROR", 5) == 0) {
	//
	//  }
	//  else {
	//
	//  }
}
开发者ID:CS308-2016,项目名称:Accident_Autodialer,代码行数:32,代码来源:micro_c.c

示例9: uartb_intHandler

void uartb_intHandler(){
    int tmp=0;

    // detect the event that triggered the interrupt
    unsigned long intStatus=UARTIntStatus(UART_BUFFERIZED_BASE,1);
    // Clear the interrupt (done early because rtfm)
    UARTIntClear(UART_BUFFERIZED_BASE,intStatus);

    // if it is on RX fifo limit or RX timeout, put these bits in circular buffer
    if (intStatus==UART_INT_RT || intStatus==UART_INT_RX){
        UARTIntDisable(UART_BUFFERIZED_BASE,(UART_INT_RT | UART_INT_RX));
        while (UARTCharsAvail(UART_BUFFERIZED_BASE)){
            // RDA interrupt
            tmp = (rxbuf.head+1)%UART_BUFFERIZED_CBUFF_SIZE;

            if(tmp != rxbuf.tail){
                rxbuf.cbuf[rxbuf.head] = UARTCharGetNonBlocking(UART_BUFFERIZED_BASE);
                rxbuf.head = tmp;
            }
        }
        UARTIntEnable(UART_BUFFERIZED_BASE,(UART_INT_RT | UART_INT_RX));
    }
    // xxx if it is on TX fifo limit, what should we do ? loop until fifo is free again ? useless if blocking writes are used.

    // otherwise, discard whitout doing anything (done at the beginning of the function, see doc for "why ?".
}
开发者ID:ENAC-Robotique,项目名称:Robots,代码行数:26,代码来源:UART_bufferized.c

示例10: UART0IntHandler

//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void UART0IntHandler(void)
{
    unsigned long ulStatus;

    //
    // Get the interrrupt status.
    //
    ulStatus = UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    UARTIntClear(UART0_BASE, ulStatus);

    //
    // Loop while there are characters in the receive FIFO.
    //
    while(UARTCharsAvail(UART0_BASE))
    {
        //
        // Read the next character from the UART and write it back to the UART.
        //
        UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE));
    }
}
开发者ID:mybays,项目名称:lm3s,代码行数:30,代码来源:main.c

示例11: main

int main(void)
{
	/*Set the clocking to directly run from the crystal at 8MHz*/
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);


    /* Make the UART pins be peripheral controlled. */
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	
	/* Sets the configuration of a UART. */
	UARTConfigSetExpClk(UART0_BASE, 8000000, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    while(1)
    {

    if(UARTCharsAvail(UART0_BASE))
    {
    	/* Unsigned Char */
    	UARTCharPut(UART0_BASE,(unsigned char)(UARTCharGet(UART0_BASE)+1));
    }

    }

}
开发者ID:dhanawadeamit,项目名称:stellaris-guru,代码行数:27,代码来源:main.c

示例12: halSwitchToBootloader

/**
 * Turn off interrupt sources that may interrupt us (SysTick and Ethernet) and then switch control
 * to the Boot Loader. This will never return!
 */
void halSwitchToBootloader()
{
    while(UARTCharsAvail(UART0_BASE))
    {
        UARTCharGet(UART0_BASE);
    }

    EthernetIntDisable(ETH_BASE, 0xFFFF);
    SysTickIntDisable();
    IntDisable(INT_UART0);
    UARTIntDisable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    UARTIntClear(UART0_BASE, UART_INT_RX | UART_INT_RT);


    delayMs(100);
    // Call the boot loader so that it will listen for an update on the UART.
    (*((void (*)(void))(*(unsigned long *)0x2c)))();

    //
    // The boot loader should take control, so this should never be reached.
    // Just in case, loop forever.
    //
    while(1)
    {
    }

}
开发者ID:vtoanb,项目名称:msp430lioamaintain,代码行数:31,代码来源:hal_gw1.c

示例13: getValue

void getValue(char* atCommand, char* response, unsigned maxLen){
    // Take control of the stdio UART
    // The wifi chip is connected to UART1
    UARTStdioConfig(1, 115200, 16000000);
    char rxBuf[200] = {0};
    unsigned index = 0;

    // Send command
    if( !(atCommand[0] == '\0') )
    {
        UARTprintf("%s\r\n", atCommand);
    }

    // read rxBuf

    // Check if data exists on uart1 (non usb uart)
    do
    {
        if( UARTCharsAvail(UART1_BASE) )
        {
            rxBuf[index] = (char)UARTCharGetNonBlocking(UART1_BASE);
            index++;
        }
    }while(index < maxLen);

    memcpy(response, rxBuf, maxLen);
    UARTStdioConfig(0, 115200, 16000000);
    return;
}
开发者ID:bclouser,项目名称:LedMarquee,代码行数:29,代码来源:wifi.c

示例14: stellaris_uart0_irq

void stellaris_uart0_irq(void)
{
	arm_cm_irq_entry();

	//
	// Get the interrrupt status.
	//
	unsigned long ulStatus = UARTIntStatus(DEBUG_UART, true);

	//
	// Clear the asserted interrupts.
	//
	UARTIntClear(DEBUG_UART, ulStatus);

	//
	// Loop while there are characters in the receive FIFO.
	//
	bool resched = false;
	while (UARTCharsAvail(DEBUG_UART)) {
		//
		// Read the next character from the UART and write it back to the UART.
		//
		unsigned char c = UARTCharGetNonBlocking(DEBUG_UART);
		cbuf_write_char(&debug_rx_buf, c, false);

		resched = true;
	}

	arm_cm_irq_exit(resched);
}
开发者ID:DSKIM3,项目名称:lk,代码行数:30,代码来源:debug.c

示例15: UARTIntHandler

void UARTIntHandler(void) {
	uint32_t ui32Status;
	ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
	UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
	if(UARTCharGetNonBlocking(UART0_BASE) == 'S'){
		char m[] = "Enter The Temperature : ";
		char h[100] = "Set temperature Updated to ";
		int i;
		int l;
		l=0;
		for(i=0;m[i];i++){
					UARTCharPut(UART0_BASE, m[i]);
				}
		int x=0;
		while(1){
			char c;
			if(UARTCharsAvail(UART0_BASE)){
				c= UARTCharGetNonBlocking(UART0_BASE);
				UARTCharPut(UART0_BASE, c);
				if(c=='\r') break;
				h[27+l]=c;
				x=10*x+c-'0';
				l++;
			}
		}
		settemp = x;
		for(i=0;i<27+l;i++){
							UARTCharPut(UART0_BASE, h[i]);
						}
		UARTCharPut(UART0_BASE, '*');
		UARTCharPut(UART0_BASE, 'C');
		UARTCharPut(UART0_BASE, '\r');
		UARTCharPut(UART0_BASE,'\n');
	}
}
开发者ID:CS308-2016,项目名称:SmartLuggage,代码行数:35,代码来源:main.c


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