LP-89 - Port OP_15.05.01 fixes. Release notes:
[librepilot.git] / flight / libraries / inc / ubx_utils.h
blob425b4a07021cae9a41487f24ce959e6f14009d23
1 /**
2 ******************************************************************************
4 * @file ubx_utils.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
6 * @brief UBX Protocol utilities
7 * --
8 * @see The GNU Public License (GPL) Version 3
10 *****************************************************************************/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #ifndef UBX_UTILS_H_
27 #define UBX_UTILS_H_
29 #include <stdint.h>
30 #include <stdbool.h>
32 typedef struct {
33 uint8_t syn1;
34 uint8_t syn2;
35 uint8_t class;
36 uint8_t id;
37 uint16_t len;
38 } __attribute__((packed)) UBXHeader_t;
40 typedef struct {
41 uint8_t chk1;
42 uint8_t chk2;
43 } __attribute__((packed)) UBXFooter_t;
45 typedef union {
46 uint8_t binarystream[0];
47 struct {
48 UBXHeader_t header;
49 uint8_t payload[0];
50 } packet;
51 } UBXPacket_t;
53 #define UBX_HEADER_LEN (sizeof(UBXHeader_t))
55 #define UBX_SYN1 0xB5
56 #define UBX_SYN2 0x62
58 bool ubx_getLastSentence(uint8_t *data, uint16_t bufferCount, uint8_t * *lastSentence, uint16_t *lenght);
59 void ubx_appendChecksum(UBXPacket_t *pkt);
60 void ubx_buildPacket(UBXPacket_t *pkt, uint8_t packetClass, uint8_t packetId, uint16_t len);
62 #endif /* UBX_UTILS_H_ */