示例#1
0
static inline void usart_rx_irq(const usart_dev *dev)    {
#ifdef ISR_PERF
        uint32_t t=stopwatch_getticks();
#endif

	/* Check on Receive Data register Not Empty interrupt */
        uint16_t sr = dev->USARTx->SR;
	if( (sr & USART_F_RXNE) && (dev->USARTx->CR1 & USART_MASK_RXNEIE) ){
#ifdef USART_SAFE_INSERT
	    /* If the buffer is full and the user defines USART_SAFE_INSERT, ignore new bytes. */
	    rb_safe_insert(dev->rxrb, (uint8_t) dev->USARTx->DR);
#else
	    /* By default, push bytes around in the ring buffer. */
	    rb_push_insert(dev->rxrb, (uint8_t)dev->USARTx->DR);
#endif

            if(dev->state->callback) {
                revo_call_handler(dev->state->callback, (uint32_t)dev); 
            }
	}

        if( sr & USART_F_ORE ){
	    (void)dev->USARTx->DR; // cleared after reading sr, dr
	}

#ifdef ISR_PERF
    t = stopwatch_getticks() - t;
    isr_time += t;
    if(t>max_isr_time) max_isr_time=t;
#endif

}
示例#2
0
文件: usart.c 项目: bubi-007/ardurevo
static inline void usart_rx_irq(usart_dev *dev)
    {
	/* Check on Receive Data register Not Empty interrupt */
	if( USART_GetITStatus(dev->USARTx, USART_IT_RXNE) != RESET ){
#ifdef USART_SAFE_INSERT
	    /* If the buffer is full and the user defines USART_SAFE_INSERT,
	     * ignore new bytes. */
	    rb_safe_insert(dev->rxrb, (uint8_t) dev->USARTx->DR);
#else
	    /* By default, push bytes around in the ring buffer. */
	    rb_push_insert(dev->rxrb, (uint8_t)dev->USARTx->DR);
#endif
	}
    }