#ifndef GPS_H #define GPS_H #include #include #include #include #include struct GPSMsg { unsigned int n; uint8_t buf[128]; GPSMsg() : n(0) {} }; class GPS { friend void interrupt(); private: static GPS* self; void irq(); Pool msg_pool; P incomplete_msg; volatile P complete_msg; volatile bool complete; public: GPS() { self = this; } void enable() { RCC.enable(RCC.USART3); USART3.set_baudrate(4800); USART3.enable(); Interrupt::enable(Interrupt::USART3); } P read() { while(!complete) { Thread::yield(); } complete = false; P msg = const_cast&>(complete_msg); const_cast&>(complete_msg).reset(); return msg; } }; #endif