Пример #1
0
/*******************************************************************************
函 数 名:	USART1_IRQHandler
功能说明:	串口中断处理
参	  数:	无
返 回 值:	无
*******************************************************************************/ 
void USART1_IRQHandler(void)
{
	if(USART1->SR&(1<<5))//接收到数据
	{	 
		fifo_putc(&rcv433fifo, USART1->DR);
	}

}
Пример #2
0
/*******************************************************************************
函 数 名:	USART1_IRQHandler
功能说明:	串口中断处理
参	  数:	无
返 回 值:	无
*******************************************************************************/
void USART2_IRQHandler(void)
{
    if(USART2->SR&(1<<5))//接收到数据
    {
        CPU_SR_ALLOC();
        ENTER_CRITICAL();
        fifo_putc(&phy_rcvUsartfifo, USART2->DR);
        EXIT_CRITICAL();
    }
    USART2->SR &=~(1<<5);
}
Пример #3
0
//Reads data into uart's fifo.
int uart_read_start(uart_s* uart, int timeout){
	if (!uart->rxfifo){
		uart_printf(CLR_CANCEL,0,"Uart has no rxfifo\n");
		return -1;
	}

	uart_printf(CLR_CANCEL,2,"uart_read_start\n");
	if (!uart->opened){
		uart_open(uart);
	}

	//Wiggle
	/*

	int status = TIOCM_CTS;
	ioctl (uart->fd, TIOCMBIS, &status);
	ioctl (uart->fd, TIOCMBIC, &status);
	*/

	//Use a buffer to flatten the fifo.
	uint8_t* buff = (uint8_t*)malloc(uart->rxfifo->size);

	int n = uart_read(uart,buff,512,timeout);
	//Some debug data:
	uart_printf(CLR_CANCEL,1,"Received %i characters\n",n);
	#if(UARTDEBUG)
	if (n){
	printf_hex_block(buff,n,1);
	}
	#endif

	if (n == -1){
		free(buff);
		return -1;
	}

	//Store in fifo.
	int i =0;
	int r=n;
	while(r--){		
		fifo_putc(uart->rxfifo,buff[i]);
		i++;
	}
	uart_printf(CLR_CANCEL,1,"Done\n");
	free(buff);

	return n;
}