LP-518 Revo/Sparky: Disable simple beacon tone
[librepilot.git] / flight / uavtalk / inc / uavtalk_priv.h
blob73354845a719f45167f6816bd39d3aecb4545ff9
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilotSystem OpenPilot System
4 * @{
5 * @addtogroup OpenPilotLibraries OpenPilot System Libraries
6 * @{
7 * @file uavtalk.h
8 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
9 * @brief Private include file of the UAVTalk library
10 * @see The GNU Public License (GPL) Version 3
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef UAVTALK_PRIV_H
30 #define UAVTALK_PRIV_H
32 #include "uavobjectsinit.h"
34 // Private types and constants
36 // min header : sync(1), type (1), size(2), object ID(4), instance ID(2)
37 #define UAVTALK_MIN_HEADER_LENGTH 10
39 // max header : sync(1), type (1), size(2), object ID(4), instance ID(2), timestamp(2)
40 #define UAVTALK_MAX_HEADER_LENGTH 12
42 #define UAVTALK_CHECKSUM_LENGTH 1
44 #define UAVTALK_MAX_PAYLOAD_LENGTH (UAVOBJECTS_LARGEST + 1)
46 #define UAVTALK_MIN_PACKET_LENGTH UAVTALK_MAX_HEADER_LENGTH + UAVTALK_CHECKSUM_LENGTH
47 #define UAVTALK_MAX_PACKET_LENGTH UAVTALK_MIN_PACKET_LENGTH + UAVTALK_MAX_PAYLOAD_LENGTH
49 typedef struct {
50 uint8_t type;
51 uint16_t packet_size;
52 uint32_t objId;
53 uint16_t instId;
54 uint32_t length;
55 uint8_t timestampLength;
56 uint8_t cs;
57 uint16_t timestamp;
58 uint32_t rxCount;
59 UAVTalkRxState state;
60 uint16_t rxPacketLength;
61 } UAVTalkInputProcessor;
63 typedef struct {
64 uint8_t canari;
65 UAVTalkOutputStream outStream;
66 xSemaphoreHandle lock;
67 xSemaphoreHandle transLock;
68 xSemaphoreHandle respSema;
69 uint8_t respType;
70 uint32_t respObjId;
71 uint16_t respInstId;
72 UAVTalkStats stats;
73 UAVTalkInputProcessor iproc;
74 uint8_t *rxBuffer;
75 uint8_t *txBuffer;
76 } UAVTalkConnectionData;
78 #define UAVTALK_CANARI 0xCA
79 #define UAVTALK_SYNC_VAL 0x3C
81 #define UAVTALK_TYPE_MASK 0x78
82 #define UAVTALK_TYPE_VER 0x20
83 #define UAVTALK_TIMESTAMPED 0x80
84 #define UAVTALK_TYPE_OBJ (UAVTALK_TYPE_VER | 0x00)
85 #define UAVTALK_TYPE_OBJ_REQ (UAVTALK_TYPE_VER | 0x01)
86 #define UAVTALK_TYPE_OBJ_ACK (UAVTALK_TYPE_VER | 0x02)
87 #define UAVTALK_TYPE_ACK (UAVTALK_TYPE_VER | 0x03)
88 #define UAVTALK_TYPE_NACK (UAVTALK_TYPE_VER | 0x04)
89 #define UAVTALK_TYPE_OBJ_TS (UAVTALK_TIMESTAMPED | UAVTALK_TYPE_OBJ)
90 #define UAVTALK_TYPE_OBJ_ACK_TS (UAVTALK_TIMESTAMPED | UAVTALK_TYPE_OBJ_ACK)
92 // macros
93 #define CHECKCONHANDLE(handle, variable, failcommand) \
94 variable = (UAVTalkConnectionData *)handle; \
95 if (variable == NULL || variable->canari != UAVTALK_CANARI) { \
96 failcommand; \
99 #endif // UAVTALK__PRIV_H
101 * @}
102 * @}