Eigen
Dependencies: Vector3
Dependents: optWingforHAPS_Eigen hexaTest_Eigen
GPSUBX_UART.hpp
- Committer:
- cocorlow
- Date:
- 2021-09-17
- Revision:
- 4:59f0f651296c
- Parent:
- 3:6c8715574bb8
- Child:
- 5:a92850395dcb
File content as of revision 4:59f0f651296c:
#ifndef __GPSUBX_UART_HPP__ #define __GPSUBX_UART_HPP__ #include "mbed.h" #include "Vector3.hpp" #define POSECEF_LEN 20 #define POSLLH_LEN 28 #define TIMEUTC_LEN 20 #define VELECEF_LEN 20 #define VELNED_LEN 36 #define UBX_SYNC 0x62 << 8 | 0xb5 #define RECEIVE_SIZE 1024 #define SENTENCE_SIZE 64 extern Serial pc; //// 0x01 0x01 //union POSECEF //{ // char byte_data[POSECEF_LEN+8]; // struct // { // unsigned short sync; // char m_class; // char m_id; // unsigned short pay_len; // unsigned int iTOW; // int ecefX; // int ecefY; // int ecefZ; // unsigned int pAcc; // char check_a; // char check_b; // } data; //}; // 0x01 0x02 union POSLLH { char byte_data[POSLLH_LEN]; struct { unsigned int iTOW; int lon; int lat; int height; int hMSL; unsigned int hAcc; unsigned int vAcc; } data; }; // 0x01 0x21 union TIMEUTC { char byte_data[TIMEUTC_LEN]; struct { unsigned int iTOW; unsigned int tAcc; int nano; unsigned short year; unsigned char month; unsigned char day; unsigned char hour; unsigned char min; unsigned char sec; unsigned char valid; } data; }; //// 0x01 0x11 //union VELECEF //{ // char byte_data[VELECEF_LEN]; // struct // { // unsigned int iTOW; // int ecefVX; // int ecefVY; // int ecefVZ; // unsigned int sAcc; // } data; //}; // 0x01 0x12 union VELNED { char byte_data[VELNED_LEN]; struct { unsigned int iTOW; int velN; int velE; int velD; unsigned int speed; unsigned int gSpeed; signed int heading; unsigned int sAcc; unsigned int cAcc; } data; }; /** My HelloWorld class. * Used for printing "Hello World" on USB serial. */ class GPSUBX_UART { private: RawSerial serial; char receive_buffer[RECEIVE_SIZE]; char sentence_buffer[SENTENCE_SIZE]; static const float Radius = 6378136.6f; volatile int receive_index; void Receive(); void Decode(char buffer[], int mc, int mi); public: int dummy; // Compiler bug? If "dummy" does not exist, the value of "Year" (under "public:") may include bugs. volatile int Year; volatile int Month; volatile int Day; volatile int Hours; volatile int Minutes; volatile int Seconds; volatile float Latitude; volatile float Longitude; volatile float Height; volatile int iTOW_POSLLH; volatile Vector3 VelocityNED; volatile float Speed; volatile float GroundSpeed; volatile float Heading; volatile int iTOW_VELNED; volatile int TimeZone; Vector3 UniversalZeroPosition; Vector3 UniversalZeroUnitN; Vector3 UniversalZeroUnitE; Vector3 UniversalZeroUnitD; Vector3 UniversalPosition; Vector3 PositionNED; /** *@param tx UART TX pin *@param rx UART RX pin *@param baud UART baud rate (default: 38400) *@param timezone Time zone (default: +9) */ GPSUBX_UART(PinName tx, PinName rx, int baud = 38400, int timezone = +9); void Update(); void Attach(); Vector3 ToUniversalUnit(); Vector3 ToUniversal(); void CalculateUnit(); void Calculate(); Vector3 Calculate(Vector3 position); static void Checksum(char payload[], int n, char* ck_a, char* ck_b); }; #endif