diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-11-19 20:02:14 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-11-19 20:02:14 +0100 |
commit | 307cfe164910eccc70c086c083595d637c7fb987 (patch) | |
tree | f9845dc9647518840faf469580f581cf65d9fced /drivers/gps.cpp | |
parent | c265553652444293f90189c7481fb7eb16f28115 (diff) |
Moved driver related files to a subdirectory.
Diffstat (limited to 'drivers/gps.cpp')
-rw-r--r-- | drivers/gps.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/gps.cpp b/drivers/gps.cpp new file mode 100644 index 0000000..1ae3684 --- /dev/null +++ b/drivers/gps.cpp @@ -0,0 +1,40 @@ +#include "gps.h" + +GPS* GPS::self; + +template<> +void interrupt<Interrupt::USART3>() { + GPS::self->irq(); +} + +void GPS::irq() { + + uint8_t c = USART3.DR; + + if(!incomplete_msg) { + incomplete_msg = msg_pool.create(); + + if(!incomplete_msg) { + return; + } + } + + if(incomplete_msg->n == 0 && c != '$') { + return; + } + + if(incomplete_msg->n >= 128) { + incomplete_msg->n = 0; + return; + } + + incomplete_msg->buf[incomplete_msg->n++] = c; + + if(c == '\n') { + GPIOB.ODR ^= 1 << 1; + + const_cast<P<GPSMsg>&>(complete_msg) = incomplete_msg; + incomplete_msg.reset(); + complete = true; + } +} |