From 261e6be038754388212e7a7b69da1318d6a171d2 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Mon, 10 Oct 2011 01:13:52 +0200 Subject: Add GPS code. --- main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 471e40e..c95731f 100644 --- a/main.cpp +++ b/main.cpp @@ -11,6 +11,7 @@ #include "usart.h" #include "xbee.h" +#include "gps.h" template inline void saturate(T& var, T absmax) { @@ -82,6 +83,22 @@ uint32_t thstack[1024]; Thread thread(thstack, sizeof(thstack), threadmain); +GPS gps; + +void gps_thread_main() { + while(1) { + P msg = gps.read(); + + if(msg->n < 128) { + xbee_send(2, msg->n, msg->buf); + } + } +} + +uint32_t gps_stack[256]; + +Thread gps_thread(gps_stack, sizeof(gps_stack), gps_thread_main); + int main() { // Initialize system timer. Time::init(); @@ -124,8 +141,10 @@ int main() { PID pid_yaw(6000, 0, 0); usart_enable(); + gps.enable(); thread.start(); + gps_thread.start(); while(1) { // Wait for a new update. -- cgit v1.2.3