![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
All project
Dependencies: MMA8452 MODSERIAL mbed-rtos mbed
Fork of GPS_U-blox_NEO-6M_Test_Code by
Revision 2:a01fc505b443, committed 2016-06-27
- Comitter:
- yanay_amir
- Date:
- Mon Jun 27 19:23:10 2016 +0000
- Parent:
- 1:acd907fbcbae
- Commit message:
- AA;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8452.lib Mon Jun 27 19:23:10 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/yanay_amir/code/MMA8452/#0d00605bf830
--- a/main.cpp Fri Aug 22 12:43:55 2014 +0000 +++ b/main.cpp Mon Jun 27 19:23:10 2016 +0000 @@ -1,30 +1,42 @@ -/* - * Author: Edoardo De Marchi - * Date: 22-08-14 - * Notes: Firmware for GPS U-Blox NEO-6M -*/ - +#include "mbed.h" +#include <math.h> +#include "rtos.h" +#include "MMA8452.h" +#include <string> #include "main.h" + +MMA8452 acc(p28, p27, 100000); +Serial pc(USBTX,USBRX); +Serial BT(p9, p10); +DigitalOut led2(LED2); +Ticker BTtimer; +Timer globalTimer; +static float lat=0,lng=0,speed=0,accelerometer=0; +static int panic=0; +static double x; +//prototypes: +void BTsendInterval(); -void Init() -{ - gps.baud(9600); - pc.baud(115200); - - pc.printf("Init OK\n"); +void DataReceived_ISR(){ + char globalChar = LPC_UART1->RBR; } +void BTCommands (string cmd) +{ + + +} -int main() -{ - Init(); +//GPS Thread +void thread1(void const *args) +{ + char c; - - while(true) - { - if(gps.readable()) + while(true) { + pc.printf("GPS Thread\n"); + if(gps.readable()) { if(gps.getc() == '$'); // wait a $ { @@ -44,47 +56,94 @@ } } } + + Thread::wait(100); + } +} + +void thread2(void const *args) //body thread +{ + + while(true) { + if(!acc.isXReady()) { + wait(0.01); + continue; + } + acc.readXGravity(&x); + pc.printf("ACCELERETOR Thread x:%lf \r\n",x); + pc.printf("ACCELERETOR Thread\n"); + Thread::wait(100); + } + +} + + + +void thread3(void const *args) +{ + + while(true) { + BT.printf("Log %.6f,%.6f,%.1f,%.2f,%d\n",lat,lng,speed,accelerometer,panic); + pc.printf("MQTT Thread\n"); + Thread::wait(100); } } +void BTsendDegrees(float degree) +{ + BT.printf("lat:%f,lng:%f,speed:%f\n",lat,lng,speed); +} + + + +void Init() +{ + gps.baud(9600); + pc.baud(9600); + BT.baud(9600); + //BT.attach(&DataReceived_ISR,Serial::RxIrq); //maor + wait(1); + pc.printf("Init OK\n"); +} + + +int main() +{ + pc.printf("Main\n"); + Init(); + pc.printf("ready\n"); + Thread t1(thread1); + t1.set_priority(osPriorityNormal); + + Thread t2(thread2); + t2.set_priority(osPriorityNormal); + + Thread t3(thread3); + t3.set_priority(osPriorityNormal); + + + while(true) { + + } +} void parse(char *cmd, int n) { char ns, ew, tf, status; int fq, nst, fix, date; // fix quality, Number of satellites being tracked, 3D fix - float latitude, longitude, timefix, speed, altitude; - - - // Global Positioning System Fix Data - if(strncmp(cmd,"$GPGGA", 6) == 0) - { - sscanf(cmd, "$GPGGA,%f,%f,%c,%f,%c,%d,%d,%*f,%f", &timefix, &latitude, &ns, &longitude, &ew, &fq, &nst, &altitude); - pc.printf("GPGGA Fix taken at: %f, Latitude: %f %c, Longitude: %f %c, Fix quality: %d, Number of sat: %d, Altitude: %f M\n", timefix, latitude, ns, longitude, ew, fq, nst, altitude); - } + float latitude, longitude, timefix, spd, altitude; - // Satellite status - if(strncmp(cmd,"$GPGSA", 6) == 0) - { - sscanf(cmd, "$GPGSA,%c,%d,%d", &tf, &fix, &nst); - pc.printf("GPGSA Type fix: %c, 3D fix: %d, number of sat: %d\r\n", tf, fix, nst); - } - - // Geographic position, Latitude and Longitude - if(strncmp(cmd,"$GPGLL", 6) == 0) - { - sscanf(cmd, "$GPGLL,%f,%c,%f,%c,%f", &latitude, &ns, &longitude, &ew, &timefix); - pc.printf("GPGLL Latitude: %f %c, Longitude: %f %c, Fix taken at: %f\n", latitude, ns, longitude, ew, timefix); - } - + // Geographic position, Latitude and Longitude if(strncmp(cmd,"$GPRMC", 6) == 0) { - sscanf(cmd, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,,%d", &timefix, &status, &latitude, &ns, &longitude, &ew, &speed, &date); - pc.printf("GPRMC Fix taken at: %f, Status: %c, Latitude: %f %c, Longitude: %f %c, Speed: %f, Date: %d\n", timefix, status, latitude, ns, longitude, ew, speed, date); + sscanf(cmd, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,,%d", &timefix, &status, &latitude, &ns, &longitude, &ew, &spd, &date); + lat=latitude/100; + lng=longitude/100; + speed=spd; + pc.printf("GPS - Latitude: %f, Longitude: %f, Speed: %.1f\n", lat, lng, speed); + //pc.printf("GPRMC Fix taken at: %f, Status: %c, Latitude: %f %c, Longitude: %f %c, Speed: %f, Date: %d\n", timefix, status, latitude, ns, longitude, ew, spd, date); + } } - - - -
--- a/main.h Fri Aug 22 12:43:55 2014 +0000 +++ b/main.h Mon Jun 27 19:23:10 2016 +0000 @@ -1,8 +1,8 @@ #pragma once -#include "mbed.h" + #include "MODSERIAL.h" -MODSERIAL pc(USBTX,USBRX); + #if defined(TARGET_LPC1768) MODSERIAL gps(p13, p14);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Mon Jun 27 19:23:10 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#bdd541595fc5
--- a/mbed-src.lib Fri Aug 22 12:43:55 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-src/#ec1b66a3d094
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 27 19:23:10 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file