Demo to get GPS data.
Dependencies: mbed
main.cpp@0:e80d81207d7a, 2016-07-13 (annotated)
- Committer:
- uBerry
- Date:
- Wed Jul 13 16:29:59 2016 +0000
- Revision:
- 0:e80d81207d7a
commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uBerry | 0:e80d81207d7a | 1 | #include "mbed.h" |
uBerry | 0:e80d81207d7a | 2 | |
uBerry | 0:e80d81207d7a | 3 | Serial pc(USBTX, USBRX); |
uBerry | 0:e80d81207d7a | 4 | Serial gps(PTC15, PTC14); // UART4 |
uBerry | 0:e80d81207d7a | 5 | |
uBerry | 0:e80d81207d7a | 6 | DigitalOut RESET(PTC9); |
uBerry | 0:e80d81207d7a | 7 | DigitalOut WAKEUP(PTC7); |
uBerry | 0:e80d81207d7a | 8 | DigitalOut POWER(PTC8); |
uBerry | 0:e80d81207d7a | 9 | |
uBerry | 0:e80d81207d7a | 10 | void setupGPS() |
uBerry | 0:e80d81207d7a | 11 | { |
uBerry | 0:e80d81207d7a | 12 | RESET = 1; |
uBerry | 0:e80d81207d7a | 13 | wait_ms(300); |
uBerry | 0:e80d81207d7a | 14 | RESET = 0; |
uBerry | 0:e80d81207d7a | 15 | |
uBerry | 0:e80d81207d7a | 16 | // WAKEUP signal will be issued whe ON_OFF signal goes high |
uBerry | 0:e80d81207d7a | 17 | WAKEUP = 0; |
uBerry | 0:e80d81207d7a | 18 | wait_ms(100); |
uBerry | 0:e80d81207d7a | 19 | WAKEUP = 1; |
uBerry | 0:e80d81207d7a | 20 | wait(2.0f); |
uBerry | 0:e80d81207d7a | 21 | WAKEUP = 0; |
uBerry | 0:e80d81207d7a | 22 | wait_ms(100); |
uBerry | 0:e80d81207d7a | 23 | |
uBerry | 0:e80d81207d7a | 24 | POWER = 1; |
uBerry | 0:e80d81207d7a | 25 | wait_ms(200); |
uBerry | 0:e80d81207d7a | 26 | POWER = 0; |
uBerry | 0:e80d81207d7a | 27 | |
uBerry | 0:e80d81207d7a | 28 | gps.baud(4800); |
uBerry | 0:e80d81207d7a | 29 | } |
uBerry | 0:e80d81207d7a | 30 | |
uBerry | 0:e80d81207d7a | 31 | char dataRaw[100]; |
uBerry | 0:e80d81207d7a | 32 | short nmeaReady; |
uBerry | 0:e80d81207d7a | 33 | int count; |
uBerry | 0:e80d81207d7a | 34 | |
uBerry | 0:e80d81207d7a | 35 | int main() |
uBerry | 0:e80d81207d7a | 36 | { |
uBerry | 0:e80d81207d7a | 37 | pc.printf("Hello uBerry\r\n"); |
uBerry | 0:e80d81207d7a | 38 | |
uBerry | 0:e80d81207d7a | 39 | setupGPS(); |
uBerry | 0:e80d81207d7a | 40 | |
uBerry | 0:e80d81207d7a | 41 | while (1) |
uBerry | 0:e80d81207d7a | 42 | { |
uBerry | 0:e80d81207d7a | 43 | if(gps.readable()) |
uBerry | 0:e80d81207d7a | 44 | { |
uBerry | 0:e80d81207d7a | 45 | //pc.putc(gps.getc()); |
uBerry | 0:e80d81207d7a | 46 | count = 0; |
uBerry | 0:e80d81207d7a | 47 | dataRaw[count] = gps.getc(); |
uBerry | 0:e80d81207d7a | 48 | count++; |
uBerry | 0:e80d81207d7a | 49 | pc.printf((char*)dataRaw); |
uBerry | 0:e80d81207d7a | 50 | } else { |
uBerry | 0:e80d81207d7a | 51 | |
uBerry | 0:e80d81207d7a | 52 | } |
uBerry | 0:e80d81207d7a | 53 | } |
uBerry | 0:e80d81207d7a | 54 | } |