Esempio n. 1
0
void UART1_Handler(void)
{
    uint8_t ch;
    
    if(UART_GetITStatus(UART1,UART_IT_FLAG_RXI))
    {
        ch = UART_ReceiveData(UART1);
        uart1_rx_cnt++;
    }
    else if(UART_GetITStatus(UART1,UART_IT_FLAG_TXI))
    {
        UART_ClearITPendingBit(UART1,UART_IT_FLAG_TXI);
        uart1_tx_cnt++;
    }
}
Esempio n. 2
0
void UART2_IRQHandler(void)
{
	if(UART_GetITStatus(MDR_UART2,UART_IT_RX) == SET)
	{
		UART_ClearITPendingBit(MDR_UART2,UART_IT_RX);
	}	
}
Esempio n. 3
0
void UART1_IRQHandler(void)
{
	static uint8_t cnt_rx_byte=0;
	static bool start=false;
	uint8_t tmp=0; 
	
	
	if(UART_GetITStatus(MDR_UART1,UART_IT_RX) == SET)
	{
		UART_ClearITPendingBit(MDR_UART1,UART_IT_RX);
		tmp=UART_ReceiveData(MDR_UART1);
		
		if((tmp==0xAA) && (!start))
		{
			start=true;
		}
		else
		{
			if(start)
			{
				if(!RX_ok)
					ArrayRX_PKBA[cnt_rx_byte]=tmp; 
					
				++cnt_rx_byte;
				if(cnt_rx_byte==RX_FRAME_SIZE)
				{	
					RX_ok=true;
					start=false;
					cnt_rx_byte=0;
				}
			}
		}
	}
	MDR_UART1->RSR_ECR = 0;	
}
Esempio n. 4
0
void UART0_IRQHandler(void)
{
	u8 c;
	// if receive irq (FIFO is over trigger level) or receive timeout irq (FIFO is not empty for longer times) has occured
 	if((UART_GetITStatus(UART0, UART_IT_Receive) != RESET) || (UART_GetITStatus(UART0, UART_IT_ReceiveTimeOut) != RESET) )
 	{
   		UART_ClearITPendingBit(UART0, UART_IT_Receive);			// clear receive interrupt flag
   		UART_ClearITPendingBit(UART0, UART_IT_ReceiveTimeOut);	// clear receive timeout interrupt flag

		// if debug UART is UART0
		if (DebugUART == UART0)
		{	// forward received data to the UART1 tx buffer
		 	while(UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)
			{
				// wait for space in the tx buffer of the UART1
				while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) == SET) {};
				// move the byte from the rx buffer of UART0 to the tx buffer of UART1
				UART_SendData(UART1, UART_ReceiveData(UART0));
			}
		}
		else // UART0 is not the DebugUART (normal operation)
		{
			// repeat until no byte is in the RxFIFO
	  		while (UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)
	  		{  
				c = UART_ReceiveData(UART0); // get byte from rx fifo
				switch(UART0_Muxer)
				{
					case UART0_MKGPS:
						UBX_RxParser(c); // if connected to GPS forward byte to ubx parser
						MKProtocol_CollectSerialFrame(&UART0_rx_buffer, c);	// ckeck for MK-Frames also
						break;
					case UART0_MK3MAG:
						// ignore any byte send from MK3MAG
						break;
					case UART0_UNDEF:
					default:
						// ignore the byte from unknown source
						break;
				} // eof switch(UART0_Muxer)
			} // eof while
		}  // eof UART0 is not the DebugUART
	} // eof receive irq or receive timeout irq
}
Esempio n. 5
0
void UART2_IRQHandler(void)
{
    struct mm32_uart *uart;
    uart = &uart2;
    /* enter interrupt */
    rt_interrupt_enter();
    if (UART_GetITStatus(uart->uart_device, UART_IT_RXIEN) != RESET)
    {
        UART_ClearITPendingBit(uart->uart_device, UART_IT_RXIEN);
        rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
    }
    if (UART_GetITStatus(uart->uart, UART_IT_TXIEN) != RESET)
    {
        /* clear interrupt */
        UART_ClearITPendingBit(uart->uart, UART_IT_TXIEN);
    }
    /* leave interrupt */
    rt_interrupt_leave();
}
void UART1_Handler(void)
{
					
				if(UART_GetITStatus(UART1, UART_IT_FLAG_RXI)) {			
					UART_ClearITPendingBit(UART1, UART_IT_FLAG_RXI);

		
									if( (u1rx_wr > u1rx_rd && u1rx_wr-u1rx_rd >= U1RX_BUF_SIZE-1) ||(u1rx_wr < u1rx_rd && u1rx_rd == u1rx_wr+1) )	// Buffer Overflow
									{
													UART_SendData(UART1, (uint8_t)'@');
													return;
									}
									u1rx_buf[u1rx_wr] = (uint8_t)UART_ReceiveData(UART1);
									
									if(u1rx_wr < U1RX_BUF_SIZE-1)
												u1rx_wr++;
									else 
												u1rx_wr = 0;
		}
}