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


C++ rt_device_t::rx_indicate方法代码示例

本文整理汇总了C++中rt_device_t::rx_indicate方法的典型用法代码示例。如果您正苦于以下问题:C++ rt_device_t::rx_indicate方法的具体用法?C++ rt_device_t::rx_indicate怎么用?C++ rt_device_t::rx_indicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rt_device_t的用法示例。


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

示例1: rt_hw_serial_isr

/* ISR for serial interrupt */
void rt_hw_serial_isr(rt_device_t device)
{
    struct serial_device* uart = (struct serial_device*) device->user_data;

    /* interrupt mode receive */
    RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);

    /* save on rx buffer */
    while (uart->uart_device->ustat & USTAT_RCV_READY)
    {
        rt_serial_savechar(uart, uart->uart_device->urxh & 0xff);
    }

    /* invoke callback */
    if (device->rx_indicate != RT_NULL)
    {
        rt_size_t rx_length;

        /* get rx length */
        rx_length = uart->int_rx->read_index > uart->int_rx->save_index ?
                    UART_RX_BUFFER_SIZE - uart->int_rx->read_index + uart->int_rx->save_index :
                    uart->int_rx->save_index - uart->int_rx->read_index;

        device->rx_indicate(device, rx_length);
    }
}
开发者ID:cedar-renjun,项目名称:air-conditioning-assistant,代码行数:27,代码来源:serial.c

示例2: rt_hw_serial_isr

/* ISR for serial interrupt */
void rt_hw_serial_isr(rt_device_t device)
{
	struct stm32_serial_device* uart = (struct stm32_serial_device*) device->user_data;

	if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
	{
		/* interrupt mode receive */
		RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);

		/* save on rx buffer */
		while (uart->uart_device->SR & USART_FLAG_RXNE)
		{
			rt_base_t level;

			/* disable interrupt */
			level = rt_hw_interrupt_disable();

			/* save character */
			uart->int_rx->rx_buffer[uart->int_rx->save_index] = uart->uart_device->DR & 0xff;
			uart->int_rx->save_index ++;
			if (uart->int_rx->save_index >= UART_RX_BUFFER_SIZE)
				uart->int_rx->save_index = 0;

			/* if the next position is read index, discard this 'read char' */
			if (uart->int_rx->save_index == uart->int_rx->read_index)
			{
				uart->int_rx->read_index ++;
				if (uart->int_rx->read_index >= UART_RX_BUFFER_SIZE)
					uart->int_rx->read_index = 0;
			}

			/* enable interrupt */
			rt_hw_interrupt_enable(level);
		}

		/* clear interrupt */
		USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);

		/* invoke callback */
		if (device->rx_indicate != RT_NULL)
		{
			rt_size_t rx_length;

			/* get rx length */
			rx_length = uart->int_rx->read_index > uart->int_rx->save_index ?
				UART_RX_BUFFER_SIZE - uart->int_rx->read_index + uart->int_rx->save_index :
				uart->int_rx->save_index - uart->int_rx->read_index;

			device->rx_indicate(device, rx_length);
		}
	}

	if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
	{
		/* clear interrupt */
		USART_ClearITPendingBit(uart->uart_device, USART_IT_TC);
	}
}
开发者ID:yihui-he,项目名称:Badminton-Robot,代码行数:59,代码来源:serial.c

示例3: rt_hw_serial_isr


//.........这里部分代码省略.........
                                    &&(gprmcbuf[3] =='G')&&(gprmcbuf[4] == 'A'))
                            {
                                isgprmc =1;//位置信息

                            }
                            if ( (gprmcbuf[0] == 'G')
                                    &&(gprmcbuf[1] == 'P')&&(gprmcbuf[2] =='V')
                                    &&(gprmcbuf[3] == 'T')&&(gprmcbuf[4] == 'G'))
                            {
                                isgprmc =2;//速度信息
                                uart3flag =2;
                            }
                        }

                        break;
                    case FIELD_ONE://提取时间
                        uart3flag =1;
                        if(isgprmc == 1)
                        {
                            if(gprmccnt == 10  )
                            {
                                //get the time
                                GetTheGPSTime(gprmcbuf);
                            }
                        }
                        break;
                    case FIELD_TWO: //判断数据是否可信(当GPS天线能接收到有3颗GPS卫星时为A,可信
                        if(isgprmc == 1)
                        {
                            if(gprmccnt == 9 )
                            {
                                //get the time
                                GetGPSLocation1(gprmcbuf);
                            }
                        }
                        break;
                    case FIELD_THREE://提取出纬度
                        break;
                    case FIELD_FOUR://提取出速度
                        if(isgprmc == 1)
                        {
                            if(gprmccnt == 10 )
                            {
                                //get the time
                                GetGPSLocation2(gprmcbuf);
                            }
                        }
                        break;
                    case FIELD_FIVE://提取出经度
                        break;
                    case FIELD_SEVEN:
                        if(isgprmc == 1)
                        {
                            if(gprmccnt == 2 )
                            {
                                //get the singal
                                GettheSinaldata(gprmcbuf);
                            }
                        }
                        break;
                    case FIELD_NIGHT://提取高度
                        break;
                    default:
                        break;
                    }
                }
            }
            if((&uart4_device )== device)
            {
                gprmcbuf[gprmccnt] = uart->uart_device->DR & 0xff;
                gprmccnt++;
            }

            /* enable interrupt */
            rt_hw_interrupt_enable(level);
        }

        /* clear interrupt */
        USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);

        /* invoke callback */
        if (device->rx_indicate != RT_NULL)
        {
            rt_size_t rx_length;

            /* get rx length */
            rx_length = uart->int_rx->read_index > uart->int_rx->save_index ?
                        UART_RX_BUFFER_SIZE - uart->int_rx->read_index + uart->int_rx->save_index :
                        uart->int_rx->save_index - uart->int_rx->read_index;

            device->rx_indicate(device, rx_length);
        }
    }

    if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
    {
        /* clear interrupt */
        USART_ClearITPendingBit(uart->uart_device, USART_IT_TC);
    }
}
开发者ID:mxx,项目名称:cabra,代码行数:101,代码来源:serial.c

示例4: rt_hw_usart_rx_isr

/***************************************************************************//**
 * @brief
 *  USART RX data valid interrupt handler
 *
 * @details
 *
 * @note
 *  9-bit SPI mode has not implemented yet and SPI slave mode is untested
 *
 * @param[in] dev
 *  Pointer to device descriptor
 ******************************************************************************/
void rt_hw_usart_rx_isr(rt_device_t dev)
{
    struct efm32_usart_device_t     *usart;
    struct efm32_usart_int_mode_t   *int_rx;
    rt_uint32_t                     flag;

    /* interrupt mode receive */
    RT_ASSERT(dev->flag & RT_DEVICE_FLAG_INT_RX);
    usart = (struct efm32_usart_device_t *)(dev->user_data);
    int_rx = (struct efm32_usart_int_mode_t *)(usart->rx_mode);
    RT_ASSERT(int_rx->data_ptr != RT_NULL);
#if defined(UART_PRESENT)
    if (usart->state & USART_STATE_ASYNC_ONLY)
    {
        flag = UART_STATUS_RXDATAV;
    }
    else
#endif
    {
        flag = USART_STATUS_RXDATAV;
    }

    /* Set status */
    usart->state |= USART_STATE_RX_BUSY;

    /* save into rx buffer */
    while (usart->usart_device->STATUS & flag)
    {
        rt_base_t level;

        /* disable interrupt */
        level = rt_hw_interrupt_disable();

        /* save character */
        int_rx->data_ptr[int_rx->save_index] = \
                                               (rt_uint8_t)(usart->usart_device->RXDATA & 0xFFUL);
        int_rx->save_index ++;
        if (int_rx->save_index >= USART_RX_BUFFER_SIZE)
            int_rx->save_index = 0;

        /* if the next position is read index, discard this 'read char' */
        if (int_rx->save_index == int_rx->read_index)
        {
            int_rx->read_index ++;
            if (int_rx->read_index >= USART_RX_BUFFER_SIZE)
            {
                int_rx->read_index = 0;
            }
        }

        /* enable interrupt */
        rt_hw_interrupt_enable(level);
    }

    /* invoke callback */
    if (dev->rx_indicate != RT_NULL)
    {
        rt_size_t rx_length;

        /* get rx length */
        rx_length = int_rx->read_index > int_rx->save_index ?
                    USART_RX_BUFFER_SIZE - int_rx->read_index + int_rx->save_index : \
                    int_rx->save_index - int_rx->read_index;

        dev->rx_indicate(dev, rx_length);
    }
}
开发者ID:hduffddybz,项目名称:rt-thread,代码行数:79,代码来源:drv_usart.c


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