summaryrefslogtreecommitdiff
path: root/gps.h
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 20:02:14 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 20:02:14 +0100
commit307cfe164910eccc70c086c083595d637c7fb987 (patch)
treef9845dc9647518840faf469580f581cf65d9fced /gps.h
parentc265553652444293f90189c7481fb7eb16f28115 (diff)
Moved driver related files to a subdirectory.
Diffstat (limited to 'gps.h')
-rw-r--r--gps.h60
1 files changed, 0 insertions, 60 deletions
diff --git a/gps.h b/gps.h
deleted file mode 100644
index c37fc8a..0000000
--- a/gps.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef GPS_H
-#define GPS_H
-
-#include "stm32.h"
-#include "interrupt.h"
-#include "thread.h"
-
-#include "pool.h"
-
-struct GPSMsg {
- unsigned int n;
- uint8_t buf[128];
-
- GPSMsg() : n(0) {}
-};
-
-class GPS {
- friend void interrupt<Interrupt::USART3>();
-
- private:
- static GPS* self;
-
- void irq();
-
- Pool<GPSMsg, 4> msg_pool;
-
- P<GPSMsg> incomplete_msg;
- volatile P<GPSMsg> complete_msg;
-
- volatile bool complete;
-
- public:
- GPS() {
- self = this;
- }
-
- void enable() {
- RCC.enable(RCC.USART3);
- USART3.BRR = 7500; // 4800 baud
- USART3.CR1 = 0x202c;
-
- Interrupt::enable(Interrupt::USART3);
- }
-
- P<GPSMsg> read() {
- while(!complete) {
- Thread::yield();
- }
-
- complete = false;
-
- P<GPSMsg> msg = const_cast<P<GPSMsg>&>(complete_msg);
-
- const_cast<P<GPSMsg>&>(complete_msg).reset();
-
- return msg;
- }
-};
-
-#endif