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