The latest development version of this page may be more current than this released 0.4.3 version.

nonblock_receive

Overview

After the application starts, perform the following 4 operations:

  1. Initialize serial port 1

  2. Create message queue

  3. Register the callback function to receive the serial port data receiving status callback, and send the status message to task for processing in the callback;

  4. Receive the message circularly. After receiving the message, obtain the pointer of the received data and the current block length from the driver, write the data back to serial port 1 according to the pointer and length, and release the data pointer.

Uart receives data in this way, does not block tasks, and can be used in the task of other module. Because the data pointer in the receiving buffer is directly processed, there is no need to copy it, which is more efficient.

Requirements

  1. Note that the configuration of serial port 1 in the device table matches the board

Building and flashing

Sample location: examples/peripheral/uart/block_read_write For operations such as compiling and burning, please refer to: [Quick Start] (../../../../../get_started/index. html # build function)

Running result

Successfully running will output the following logs

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 receive demo start.

D/dt              [0.006] add device uart1