这个页面的 最新开发版本 可能比这个发布的 0.4.2 版本新。

Uart nonblock_read

功能概述

此应用程序启动后执行下面4个操作:

  1. 初始化串口1

  2. 创建消息队列

  3. 注册回调函数接收串口数据接收状态回调,回调中把状态消息发送到task中去处理;

  4. 循环接收消息,收到消息后从串口1非阻塞方式读数据,再写回到串口1

Uart使用这种方式接收数据,由于不会阻塞task,所以可以在其他模块的task中使用。

环境要求

  1. 注意设备表中串口1的配置和board匹配

编译和烧录

示例位置:examples/peripheral/uart/block_read_write

编译、烧录等操作请参考:快速入门

运行结果

成功运行将输出如下日志

D/dt              [0.002] add device iflash
D/ptb             [0.002] partition table base 0xe000
D/ft              [0.002] ft_0 base 0, ft_1 base 1000
D/ft              [0.004] ft init too
D/ft              [0.004] ft init 1
D/main            [0.004] boot reason 0
D/main            [0.004] heap size 273152(266.75KB)
D/main            [0.006] flash size 0x200000(2MB)
I/exam_uart       [0.006] uart noblock read demo start.

D/dt              [0.006] add device uart1