GPS and IMU reading works
Dependencies: mbed Servo SDFileSystem
Diff: main.cpp
- Revision:
- 5:451b8203ef99
- Parent:
- 4:37d118f2348c
- Child:
- 6:88209696ed0c
diff -r 37d118f2348c -r 451b8203ef99 main.cpp --- a/main.cpp Sat Aug 22 23:05:03 2015 +0000 +++ b/main.cpp Sat Aug 22 23:29:04 2015 +0000 @@ -3,12 +3,16 @@ DigitalOut led1(LED1); DigitalOut led2(LED2); +DigitalOut led3(LED3); Serial pc(USBTX, USBRX); Serial IMU(p28, p27); // tx, rx +Serial GPS(p13, p14); // tx, rx char IMU_message[256]; int IMU_message_counter=0; +char GPS_message[256]; +int GPS_message_counter=0; void IMU_serial_ISR() { char buf; @@ -26,22 +30,34 @@ if (buf=='\n'){ int i; for(i=0;i<=IMU_message_counter;i++){ - pc.putc(IMU_message[i]); + //pc.putc(IMU_message[i]); } } } led2 = !led2; } +void GPS_serial_ISR() { + char buf; + + while (GPS.readable()) { + buf = GPS.getc(); + //pc.putc(buf); + } + + led3 = !led3; +} int main() { IMU.baud(57600); IMU.attach(&IMU_serial_ISR); + GPS.baud(38400); + GPS.attach(&GPS_serial_ISR); while (1) { led1 = !led1; - wait(0.5); + wait(0.2); } } \ No newline at end of file