Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
audio_telemetry.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Paparazzi telemetry via audio channel modem functions
5  *
6  * Copyright (C) 2003 Pascal Brisset, Antoine Drouin
7  *
8  * This file is part of paparazzi.
9  *
10  * paparazzi is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2, or (at your option)
13  * any later version.
14  *
15  * paparazzi is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with paparazzi; see the file COPYING. If not, write to
22  * the Free Software Foundation, 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  */
26 
27 #ifndef AUDIO_TELEMETRY_H
28 #define AUDIO_TELEMETRY_H
29 
30 #include "inttypes.h"
31 
33 
34 #include "generated/airframe.h"
35 #include "audio_telemetry_hw.h"
36 
37 
38 #define TX_BUF_SIZE 255
39 extern uint8_t tx_head;
40 extern volatile uint8_t tx_tail;
41 extern uint8_t tx_buf[ TX_BUF_SIZE ];
42 
43 extern uint8_t tx_byte;
44 extern uint8_t tx_byte_idx;
45 
46 
47 #define AudioTelemetrySendMessage() AUDIO_TELEMETRY_CHECK_RUNNING()
48 
49 #if TX_BUF_SIZE == 256
50 #define UPDATE_HEAD() { \
51  tx_head++; \
52 }
53 #else
54 #define UPDATE_HEAD() { \
55  tx_head++; \
56  if (tx_head >= TX_BUF_SIZE) tx_head = 0; \
57 }
58 #endif
59 
60 #define AudioTelemetryCheckFreeSpace(_space) (tx_head>=tx_tail? _space < (TX_BUF_SIZE - (tx_head - tx_tail)) : _space < (tx_tail - tx_head))
61 
62 #define AudioTelemetryPut1Byte(_byte) { \
63  tx_buf[tx_head] = _byte; \
64  UPDATE_HEAD(); \
65 }
66 
67 #define AUDIO_TELEMETRY_LOAD_NEXT_BYTE() { \
68  tx_byte = tx_buf[tx_tail]; \
69  tx_byte_idx = 0; \
70  tx_tail++; \
71  if( tx_tail >= TX_BUF_SIZE ) \
72  tx_tail = 0; \
73 }
74 
75 #define AudioTelemetryTransmit(_x) Audio_TelemetryPut1Byte(_x)
76 
77 #endif /* AUDIO_TELEMETRY_H */
uint8_t tx_head
uint8_t tx_byte
uint8_t tx_byte_idx
#define TX_BUF_SIZE
volatile uint8_t tx_tail
unsigned char uint8_t
Definition: types.h:14
uint8_t tx_buf[TX_BUF_SIZE]
uint8_t audio_telemetry_nb_ovrn