Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
hott.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Sergey Krukowski <softsr@yahoo.de>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
27#include "hott/hott.h"
28#if HOTT_SIM_GAM_SENSOR
29#include "hott/hott_gam.h"
30#endif
31#if HOTT_SIM_EAM_SENSOR
32#include "hott/hott_eam.h"
33#endif
34#if HOTT_SIM_GPS_SENSOR
35#include "hott/hott_gps.h"
36#endif
37#if HOTT_SIM_VARIO_SENSOR
38#include "hott/hott_vario.h"
39#endif
40
41#include "mcu_periph/sys_time.h"
42#include "mcu_periph/uart.h"
43
44#define HOTT_TEXT_MODE_REQUEST_ID 0x7f
45#define HOTT_BINARY_MODE_REQUEST_ID 0x80
46//Sensor Ids
47
48//Graupner #33600 GPS Module
49#define HOTT_TELEMETRY_GPS_SENSOR_ID 0x8A
50//Graupner #33601 Vario Module
51#define HOTT_TELEMETRY_VARIO_SENSOR_ID 0x89
52
53static uint32_t hott_event_timer; // 1ms software timer
54static bool hott_telemetry_is_sending = false;
56
57#if HOTT_SIM_GPS_SENSOR
58bool HOTT_REQ_UPDATE_GPS = false;
59#endif
60#if HOTT_SIM_EAM_SENSOR
61bool HOTT_REQ_UPDATE_EAM = false;
62#endif
63#if HOTT_SIM_VARIO_SENSOR
64bool HOTT_REQ_UPDATE_VARIO = false;
65#endif
66#if HOTT_SIM_GAM_SENSOR
67bool HOTT_REQ_UPDATE_GAM = false;
68#endif
69
70// HoTT serial send buffer pointer
71static int8_t *hott_msg_ptr = 0;
72// Len of HoTT serial buffer
74
75#if HOTT_SIM_GAM_SENSOR
76static struct HOTT_GAM_MSG hott_gam_msg;
77#endif
78#if HOTT_SIM_EAM_SENSOR
79static struct HOTT_EAM_MSG hott_eam_msg;
80#endif
81#if HOTT_SIM_GPS_SENSOR
82static struct HOTT_GPS_MSG hott_gps_msg;
83#endif
84#if HOTT_SIM_VARIO_SENSOR
85static struct HOTT_VARIO_MSG hott_vario_msg;
86#endif
87
91static void hott_msgs_init(void)
92{
93
94#if HOTT_SIM_EAM_SENSOR
96#endif
97#if HOTT_SIM_GAM_SENSOR
99#endif
100#if HOTT_SIM_GPS_SENSOR
102#endif
103#if HOTT_SIM_VARIO_SENSOR
105#endif
106#if HOTT_SIM_TEXTMODE
108#endif
109}
110
111static void hott_enable_transmitter(void)
112{
113 //enables serial transmitter, disables receiver
115}
116
117static void hott_enable_receiver(void)
118{
119 //enables serial receiver, disables transmitter
121}
122
123void hott_init(void)
124{
126}
127
128
130{
131#if HOTT_SIM_EAM_SENSOR
135 HOTT_REQ_UPDATE_EAM = false;
136 }
137#endif
138#if HOTT_SIM_GAM_SENSOR
142 HOTT_REQ_UPDATE_GAM = false;
143 }
144#endif
145#if HOTT_SIM_GPS_SENSOR
149 HOTT_REQ_UPDATE_GPS = false;
150 }
151#endif
152#if HOTT_SIM_VARIO_SENSOR
156 HOTT_REQ_UPDATE_VARIO = false;
157 }
158#endif
159}
160
161static void hott_send_msg(int8_t *buffer, int16_t len)
162{
163 if (hott_telemetry_is_sending == TRUE) { return; }
164 hott_msg_ptr = buffer;
165 hott_msg_len = len + 1; //len + 1 byte for crc
166 hott_telemetry_sendig_msgs_id = buffer[1]; //HoTT msgs id is the 2. byte
167}
168
170{
171 static int16_t msg_crc = 0;
175 }
176
177 if (hott_msg_len == 0) {
178 hott_msg_ptr = 0;
181 msg_crc = 0;
185 }
186 } else {
187 --hott_msg_len;
188 if (hott_msg_len != 0) {
191 } else {
193 }
194 }
195}
196
198{
200 if (hott_telemetry_is_sending == TRUE) { return; }
201 if (uart_char_available(&HOTT_PORT) > 1) {
202 if (uart_char_available(&HOTT_PORT) == 2) {
203 if (hott_serial_request_timer == 0) {
205 return;
206 } else {
207 if (tnow - hott_serial_request_timer < 4600) { //wait ca. 5ms
208 return;
209 }
211 }
214
215 switch (c) {
216#if HOTT_SIM_TEXTMODE
218 //Text mode, handle only if not armed!
220 hott_txt_msg.start_byte = 0x7b;
221 hott_txt_msg.stop_byte = 0x7d;
222 uint8_t tmp = (addr >> 4); // Sensor type
223 if (tmp == (HOTT_SIM_TEXTMODE_ADDRESS & 0x0f)) {
227 }
228 }
229 break;
230#endif
232#if HOTT_SIM_EAM_SENSOR
233 if (addr == HOTT_TELEMETRY_EAM_SENSOR_ID) {
234 hott_send_msg((int8_t *)&hott_eam_msg, sizeof(struct HOTT_EAM_MSG));
235 HOTT_REQ_UPDATE_EAM = true;
236 break;
237 }
238#endif
239#if HOTT_SIM_GAM_SENSOR
240 if (addr == HOTT_TELEMETRY_GAM_SENSOR_ID) {
241 hott_send_msg((int8_t *)&hott_gam_msg, sizeof(struct HOTT_GAM_MSG));
242 HOTT_REQ_UPDATE_GAM = true;
243 break;
244 }
245#endif
246#if HOTT_SIM_GPS_SENSOR
247 if (addr == HOTT_TELEMETRY_GPS_SENSOR_ID) {
248 hott_send_msg((int8_t *)&hott_gps_msg, sizeof(struct HOTT_GPS_MSG));
249 HOTT_REQ_UPDATE_GPS = true;
250 break;
251 }
252#endif
253#if HOTT_SIM_VARIO_SENSOR
254 if (addr == HOTT_TELEMETRY_VARIO_SENSOR_ID) {
257 break;
258 }
259#endif
260 break; // HOTT_BINARY_MODE_REQUEST_ID:
261
262 default:
263 break;
264 }
265 } else {
268 }
270 }
271 }
272}
273
275{
277
279 if (hott_msg_ptr == 0) { return; }
281 if (tnow - hott_serial_timer < 3000) { //delay ca. 3,5 mS. 19200 baud = 520uS / int8_t + 3ms required delay
282 return;
283 }
284 } else {
286 }
289}
290
bool autopilot_get_motors_on(void)
get motors status
Definition autopilot.c:295
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
static uint32_t hott_event_timer
Definition hott.c:53
static int8_t * hott_msg_ptr
Definition hott.c:71
static bool hott_telemetry_is_sending
Definition hott.c:54
#define HOTT_BINARY_MODE_REQUEST_ID
Definition hott.c:45
static void hott_enable_receiver(void)
Definition hott.c:117
static void hott_send_telemetry_data(void)
Definition hott.c:169
#define HOTT_TEXT_MODE_REQUEST_ID
Definition hott.c:44
static void hott_send_msg(int8_t *buffer, int16_t len)
Definition hott.c:161
static void hott_enable_transmitter(void)
Definition hott.c:111
static void hott_periodic_event(uint32_t tnow)
Definition hott.c:274
#define HOTT_TELEMETRY_VARIO_SENSOR_ID
Definition hott.c:51
static void hott_msgs_init(void)
Initializes a HoTT GPS message (Receiver answer type !Not Smartbox)
Definition hott.c:91
void hott_init(void)
RC init function.
Definition hott.c:123
static int16_t hott_msg_len
Definition hott.c:73
static void hott_check_serial_data(uint32_t tnow)
Definition hott.c:197
#define HOTT_TELEMETRY_GPS_SENSOR_ID
Definition hott.c:49
static uint16_t hott_telemetry_sendig_msgs_id
Definition hott.c:55
void hott_periodic(void)
Definition hott.c:129
void hott_event(void)
RC event function.
Definition hott.c:291
Graupner HOTT telemetry control module.
Graupner HOTT electric air module description.
static void hott_update_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition hott_eam.h:140
static void hott_init_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition hott_eam.h:131
#define HOTT_TELEMETRY_EAM_SENSOR_ID
Definition hott_eam.h:36
#define HOTT_TELEMETRY_GAM_SENSOR_ID
Definition hott_gam.h:33
static void hott_init_gam_msg(struct HOTT_GAM_MSG *hott_gam_msg)
Definition hott_gam.h:125
static void hott_update_gam_msg(struct HOTT_GAM_MSG *hott_gam_msg)
Definition hott_gam.h:134
void uart_put_byte(struct uart_periph *periph, long fd, uint8_t data)
Definition uart_arch.c:306
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Definition uart_arch.c:357
uint8_t uart_getch(struct uart_periph *p)
Definition uart_arch.c:348
uint16_t foo
Definition main_demo5.c:58
#define TRUE
Definition std.h:4
#define FALSE
Definition std.h:5
void uart_periph_set_mode(struct uart_periph *p, bool tx_enabled, bool rx_enabled, bool hw_flow_control)
Definition uart_arch.c:92
Architecture independent timing functions.
#define SysTimeTimerStart(_t)
Definition sys_time.h:227
#define SysTimeTimer(_t)
Definition sys_time.h:228
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.