![](/media/cache/profiles/69f65a2e91e6051a23abe7293bf3386a.50x50_q85.jpg)
USBSerial echo example
main.cpp@0:5cd54b826046, 2011-11-11 (annotated)
- Committer:
- samux
- Date:
- Fri Nov 11 09:07:22 2011 +0000
- Revision:
- 0:5cd54b826046
- Child:
- 4:583cafe16ec7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 0:5cd54b826046 | 1 | #include "mbed.h" |
samux | 0:5cd54b826046 | 2 | #include "USBSerial.h" |
samux | 0:5cd54b826046 | 3 | |
samux | 0:5cd54b826046 | 4 | //Virtual serial port over USB |
samux | 0:5cd54b826046 | 5 | USBSerial serial; |
samux | 0:5cd54b826046 | 6 | Serial pc(USBTX, USBRX); |
samux | 0:5cd54b826046 | 7 | |
samux | 0:5cd54b826046 | 8 | int main(void) { |
samux | 0:5cd54b826046 | 9 | uint8_t buf[128]; |
samux | 0:5cd54b826046 | 10 | while(1) |
samux | 0:5cd54b826046 | 11 | { |
samux | 0:5cd54b826046 | 12 | serial.scanf("%s", buf); |
samux | 0:5cd54b826046 | 13 | serial.printf("recv: %s\r\n", buf); |
samux | 0:5cd54b826046 | 14 | pc.printf("recv: %s\r\n", buf); |
samux | 0:5cd54b826046 | 15 | } |
samux | 0:5cd54b826046 | 16 | } |