LORA_RA_L475VG
Dependencies: mbed
main.cpp@0:90ef95476204, 2020-08-06 (annotated)
- Committer:
- peng103617
- Date:
- Thu Aug 06 06:45:21 2020 +0000
- Revision:
- 0:90ef95476204
LORA_RA_L475VG
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| peng103617 | 0:90ef95476204 | 1 | #include "mbed.h" |
| peng103617 | 0:90ef95476204 | 2 | #include <string> |
| peng103617 | 0:90ef95476204 | 3 | |
| peng103617 | 0:90ef95476204 | 4 | Serial pc(USBTX, USBRX); |
| peng103617 | 0:90ef95476204 | 5 | Serial uart(PA_0, PA_1);//TX4,RX4 |
| peng103617 | 0:90ef95476204 | 6 | int idx=0; |
| peng103617 | 0:90ef95476204 | 7 | string inputdata; |
| peng103617 | 0:90ef95476204 | 8 | |
| peng103617 | 0:90ef95476204 | 9 | void newData() |
| peng103617 | 0:90ef95476204 | 10 | { |
| peng103617 | 0:90ef95476204 | 11 | char ch; |
| peng103617 | 0:90ef95476204 | 12 | while (uart.readable()) { |
| peng103617 | 0:90ef95476204 | 13 | ch = uart.getc(); |
| peng103617 | 0:90ef95476204 | 14 | if (ch == 's') { |
| peng103617 | 0:90ef95476204 | 15 | inputdata.clear(); |
| peng103617 | 0:90ef95476204 | 16 | } |
| peng103617 | 0:90ef95476204 | 17 | inputdata += ch; |
| peng103617 | 0:90ef95476204 | 18 | if (ch == '#') { |
| peng103617 | 0:90ef95476204 | 19 | inputdata.erase(0,1); |
| peng103617 | 0:90ef95476204 | 20 | inputdata.erase(inputdata.length()-1,1); |
| peng103617 | 0:90ef95476204 | 21 | pc.printf("%s\n\r",inputdata); |
| peng103617 | 0:90ef95476204 | 22 | wait(0.01); |
| peng103617 | 0:90ef95476204 | 23 | } |
| peng103617 | 0:90ef95476204 | 24 | //pc.printf("wwwwwww"); |
| peng103617 | 0:90ef95476204 | 25 | |
| peng103617 | 0:90ef95476204 | 26 | } |
| peng103617 | 0:90ef95476204 | 27 | } |
| peng103617 | 0:90ef95476204 | 28 | |
| peng103617 | 0:90ef95476204 | 29 | int main() |
| peng103617 | 0:90ef95476204 | 30 | { |
| peng103617 | 0:90ef95476204 | 31 | |
| peng103617 | 0:90ef95476204 | 32 | uart.baud(9600); |
| peng103617 | 0:90ef95476204 | 33 | uart.attach(&newData); |
| peng103617 | 0:90ef95476204 | 34 | while(1) { |
| peng103617 | 0:90ef95476204 | 35 | |
| peng103617 | 0:90ef95476204 | 36 | |
| peng103617 | 0:90ef95476204 | 37 | } |
| peng103617 | 0:90ef95476204 | 38 | } |