device->rx_indicate(device, rx_length); } } 开发者ID:cedar-renjun,项目名称:air-conditioning-assistant,代码行数:27,代码来源:serial.c 示例2: rt_hw_serial_isr /* ISR for serial interrupt */voidrt_hw_serial_isr(rt_device_tdevice){structstm32_serial_device*uart= (structstm32_serial_device...
rt_sem_init(&rx_semRxTimeOut, "rx_semRxTimeOut", 0, RT_IPC_FLAG_FIFO); /* 以中断接收及轮询发送模式打开串口设备 */ rt_device_open(serial, RT_DEVICE_FLAG_INT_RX); /* 设置接收回调函数 */ rt_device_set_rx_indicate(serial, uart_input); /* 发送字符串 */ //rt_device_write(seria...
6rt_device_open(hw_dev, RT_DEVICE_OFLAG_RDWR); 1. 2. 3. 4. 5. 6. 设置超时回调函数 通过如下函数设置定时器超时回调函数,当定时器超时将会调用此回调函数: 1rt_err_t rt_device_set_rx_indicate(rt_device_t dev, rt_err_t (*rx_ind)(rt_device_t dev,rt_size_t size)) 1. 使用示例如...
uart_open函数使用到的设备操作接口有:rt_device_find、rt_device_set_rx_indicate、rt_device_open。 uart_open函数首先调用rt_device_find根据串口名字获得串口句柄,保存在静态全局变量uart_device中,后面关于串口的操作都是基于这个串口句柄。这里的名字是在drv_usart.c中调用注册函数rt_hw_serial_register决定的,...
#define RT_DEVICE_FLAG_DMA_RX 0x200 /* DMA 接收 */ #define RT_DEVICE_FLAG_INT_TX 0x400 /* 中断发送 */ #define RT_DEVICE_FLAG_DMA_TX 0x800 /* DMA 发送 */ 设备注销后的,设备将从设备管理器中移除,也就不能再通过设备查找搜索到该设备。注销设备不会释放设备控制块占用的内存 ...
rt_sem_release(&rx_sem); return RT_EOK; } static void can_rx_thread(voidparameter) { int i; rt_err_t res; struct rt_can_msg rxmsg = {0}; /设置接收回调函数/ rt_device_set_rx_indicate(can_dev, can_rx_call); #ifdef RT_CAN_USING_HDR ...
rt_err_t rt_device_set_rx_indicate(rt_device_t dev, rt_err_t (*rx_ind)(rt_device_t dev,rt_size_t size)); 该函数的回调函数由调用者提供。若串口以中断接收模式打开,当串口接收到一个数据产生中断时,就会调用回调函数,并且会把此时缓冲区的数据大小放在 size 参数里,把串口设备句柄放在 dev 参...
RT_DEVICE_FLAG_RDWR| RT_DEVICE_FLAG_INT_RX,//dev->flag (not dev->open_flag)uart); 显然,函数 stm32_hw_usart_init(),顾名思义,是用于初始化USART硬件的函数,因此这个函数一定会在USART使用之前被调用。搜索工程发现,这个函数是在board.c中rt_hw_board_init函数中被调用,而rt_hw_board_init函数又...
RT_DEVICE_FLAG_STREAM 流模式 RT_DEVICE_FLAG_INT_RX 中断接收模式 RT_DEVICE_FLAG_DMA_RX DMA接收...
static rt_device_t uart_handle = RT_NULL; /* 消息队列控制块 */ struct rt_messagequeue uart_rx_mq; /** * @brief 串口发送接口 * @param buff:待发送的数据 * len:待发送的数据长度 * @return 0:发送数据为空或者数据长度小于1,其他:实际发送的数据长度 ...