Generation 2 of the Harp project
Dependencies: Servo TMP36 GZ chan_fatfs_sd buffered-serial1 nmea_parser watchdog mbed-rtos mbed
main.cpp
- Committer:
- tylerjw
- Date:
- 2012-12-07
- Revision:
- 7:d8ecabe16c9e
- Parent:
- 6:204487243310
- Child:
- 8:13360ec824a7
File content as of revision 7:d8ecabe16c9e:
#include "mbed.h" #include "rtos.h" #include "MODSERIAL.h" Serial pc(USBTX, USBRX); float test_lat = 39.943039; float test_long = -104.978226; // Connect the TX of the GPS module to p10 RX input MODSERIAL gps(NC, p14); DigitalOut irq_led(LED1); bool newline_detected = false; // Called everytime a new character goes into // the RX buffer. Test that character for \n // Note, rxGetLastChar() gets the last char that // we received but it does NOT remove it from // the RX buffer. void rxCallback(MODSERIAL_IRQ_INFO *q) { newline_detected = true; irq_led = !irq_led; } void gps_thread(void const *args) { char buffer[512]; gps.baud(4800); pc.baud(9600); gps.autoDetectChar('\n'); gps.attach(&rxCallback, MODSERIAL::RxAutoDetect); while(true) { // Wait here until we detect the \n going into the buffer. while (! newline_detected ) ; // When we get here the RX buffer now contains a NMEA sentence. // ... memset(buffer, 0, 512); gps.move(buffer, 512); pc.puts(buffer); } } int main() { Thread thread(gps_thread); while(true); }