GPS and IMU reading works

Dependencies:   mbed Servo SDFileSystem

/media/uploads/taoqiuyang/img_2352.jpg

Committer:
taoqiuyang
Date:
Sat Aug 08 08:01:25 2015 +0000
Revision:
2:afb333543af5
Parent:
1:e7245ffb4820
Child:
3:ab9f94d112c0
serial repeat using interrupt;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taoqiuyang 0:f4d390c06705 1 #include "mbed.h"
taoqiuyang 0:f4d390c06705 2
taoqiuyang 2:afb333543af5 3 DigitalOut led1(LED1);
taoqiuyang 2:afb333543af5 4 DigitalOut led2(LED2);
taoqiuyang 2:afb333543af5 5
taoqiuyang 2:afb333543af5 6 Serial pc(USBTX, USBRX);
taoqiuyang 2:afb333543af5 7 Serial IMU(p28, p27); // tx, rx
taoqiuyang 2:afb333543af5 8
taoqiuyang 2:afb333543af5 9 char IMU_message[256];
taoqiuyang 2:afb333543af5 10
taoqiuyang 2:afb333543af5 11 void callback() {
taoqiuyang 2:afb333543af5 12 // Note: you need to actually read from the serial to clear the RX interrupt
taoqiuyang 2:afb333543af5 13 pc.putc(IMU.getc());
taoqiuyang 2:afb333543af5 14 led2 = !led2;
taoqiuyang 2:afb333543af5 15 }
taoqiuyang 0:f4d390c06705 16
taoqiuyang 0:f4d390c06705 17 int main() {
taoqiuyang 2:afb333543af5 18 IMU.baud(57600);
taoqiuyang 2:afb333543af5 19 IMU.attach(&callback);
taoqiuyang 1:e7245ffb4820 20
taoqiuyang 2:afb333543af5 21 while (1) {
taoqiuyang 2:afb333543af5 22 led1 = !led1;
taoqiuyang 2:afb333543af5 23 wait(0.5);
taoqiuyang 0:f4d390c06705 24 }
taoqiuyang 0:f4d390c06705 25 }