lu sheng
/
Nucleo_display_temp_LM35
Nucleo_display_temp_LM35
main.cpp@1:b78c70e272ae, 2016-10-20 (annotated)
- Committer:
- anywill
- Date:
- Thu Oct 20 09:11:55 2016 +0000
- Revision:
- 1:b78c70e272ae
- Parent:
- 0:a854d9a733ca
- Child:
- 2:db3ce8717e38
uart2uart
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
anywill | 1:b78c70e272ae | 1 | //平台nucleo 70r+mbed |
anywill | 1:b78c70e272ae | 2 | //USB虚拟串口与PC串口通信 |
anywill | 1:b78c70e272ae | 3 | //波特率9600,无奇偶校验 |
anywill | 0:a854d9a733ca | 4 | #include "mbed.h" |
anywill | 1:b78c70e272ae | 5 | Serial pc(SERIAL_TX, SERIAL_RX); // 虚拟 USART2 tx, rx |
anywill | 1:b78c70e272ae | 6 | Serial device(PB_6, PA_10); // PC机usb转TTL CP2102 USART1 tx, rx |
anywill | 1:b78c70e272ae | 7 | |
anywill | 0:a854d9a733ca | 8 | int main() |
anywill | 0:a854d9a733ca | 9 | { |
anywill | 1:b78c70e272ae | 10 | while(1) |
anywill | 1:b78c70e272ae | 11 | { |
anywill | 1:b78c70e272ae | 12 | if(pc.readable()) |
anywill | 1:b78c70e272ae | 13 | { |
anywill | 1:b78c70e272ae | 14 | device.putc(pc.getc()); // 从虚拟串口接收数据,并发给PC |
anywill | 1:b78c70e272ae | 15 | |
anywill | 1:b78c70e272ae | 16 | } |
anywill | 1:b78c70e272ae | 17 | if(device.readable()) |
anywill | 1:b78c70e272ae | 18 | { |
anywill | 1:b78c70e272ae | 19 | pc.putc(device.getc()); // 从PC物理串口接收数据,并发给虚拟串口 |
anywill | 1:b78c70e272ae | 20 | } |
anywill | 1:b78c70e272ae | 21 | } |
anywill | 0:a854d9a733ca | 22 | } |