Ivaylo Iltchev
/
GPS_REPEATER
Read UART at 4800 then Resend thru the USB
main.cpp@2:2fc8495988a0, 2016-01-28 (annotated)
- Committer:
- icis4
- Date:
- Thu Jan 28 21:43:12 2016 +0000
- Revision:
- 2:2fc8495988a0
- Parent:
- 1:221b87b26f53
Two way transfer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
icis4 | 0:6c5376fa6d72 | 1 | #include "mbed.h" |
icis4 | 0:6c5376fa6d72 | 2 | |
icis4 | 0:6c5376fa6d72 | 3 | //------------------------------------ |
icis4 | 0:6c5376fa6d72 | 4 | // Hyperterminal configuration |
icis4 | 0:6c5376fa6d72 | 5 | // 9600 bauds, 8-bit data, no parity |
icis4 | 0:6c5376fa6d72 | 6 | //------------------------------------ |
icis4 | 0:6c5376fa6d72 | 7 | |
icis4 | 0:6c5376fa6d72 | 8 | Serial pc(SERIAL_TX, SERIAL_RX); |
icis4 | 0:6c5376fa6d72 | 9 | Serial gps(PB_10, PC_5); |
icis4 | 2:2fc8495988a0 | 10 | |
icis4 | 2:2fc8495988a0 | 11 | int main() |
icis4 | 2:2fc8495988a0 | 12 | { |
icis4 | 2:2fc8495988a0 | 13 | uint8_t c; |
icis4 | 2:2fc8495988a0 | 14 | |
icis4 | 2:2fc8495988a0 | 15 | pc.baud(4800); |
icis4 | 2:2fc8495988a0 | 16 | gps.baud(4800); |
icis4 | 2:2fc8495988a0 | 17 | |
icis4 | 2:2fc8495988a0 | 18 | pc.printf("*** GPS ***\n"); |
icis4 | 2:2fc8495988a0 | 19 | while(1) { |
icis4 | 2:2fc8495988a0 | 20 | if (gps.readable()) { |
icis4 | 2:2fc8495988a0 | 21 | c = gps.getc(); |
icis4 | 2:2fc8495988a0 | 22 | pc.putc(c); |
icis4 | 2:2fc8495988a0 | 23 | } |
icis4 | 2:2fc8495988a0 | 24 | if (pc.readable()) { |
icis4 | 2:2fc8495988a0 | 25 | c = pc.getc(); |
icis4 | 2:2fc8495988a0 | 26 | gps.putc(c); |
icis4 | 2:2fc8495988a0 | 27 | } |
icis4 | 2:2fc8495988a0 | 28 | } |
icis4 | 0:6c5376fa6d72 | 29 | } |