2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
28 #ifdef USE_SMARTAUDIO_DPRINTF
29 #include "io/serial.h"
30 #include "common/printf.h"
31 #include "common/printf_serial.h"
34 #define VTX_SMARTAUDIO_MIN_BAND 1
35 #define VTX_SMARTAUDIO_MIN_CHANNEL 1
38 #define VTX_SMARTAUDIO_MIN_FREQUENCY_MHZ 5000 //min freq in MHz
39 #define VTX_SMARTAUDIO_MAX_FREQUENCY_MHZ 5999 //max freq in MHz
41 // opmode flags, GET side
42 #define SA_MODE_GET_FREQ_BY_FREQ 1
43 #define SA_MODE_GET_PITMODE 2
44 #define SA_MODE_GET_IN_RANGE_PITMODE 4
45 #define SA_MODE_GET_OUT_RANGE_PITMODE 8
46 #define SA_MODE_GET_UNLOCK 16
47 #define SA_MODE_GET_DEFERRED_FREQ 32
49 // opmode flags, SET side
50 #define SA_MODE_SET_IN_RANGE_PITMODE 1 // Immediate
51 #define SA_MODE_SET_OUT_RANGE_PITMODE 2 // Immediate
52 #define SA_MODE_CLR_PITMODE 4 // Immediate
53 #define SA_MODE_SET_UNLOCK 8
54 #define SA_MODE_SET_LOCK 0 // ~UNLOCK
55 #define SA_MODE_SET_DEFERRED_FREQ 16
57 // SetFrequency flags, for pit mode frequency manipulation
58 #define SA_FREQ_GETPIT (1 << 14)
59 #define SA_FREQ_SETPIT (1 << 15)
60 #define SA_FREQ_MASK (~(SA_FREQ_GETPIT|SA_FREQ_SETPIT))
62 // For generic API use, but here for now
64 typedef struct smartAudioDevice_s
{
71 bool willBootIntoPitMode
;
74 typedef struct smartAudioStat_s
{
84 extern smartAudioDevice_t saDevice
;
85 extern smartAudioStat_t saStat
;
87 extern uint16_t sa_smartbaud
;
88 extern bool saDeferred
;
90 void saSetMode(int mode
);
91 void saSetFreq(uint16_t freq
);
92 void saSetPitFreq(uint16_t freq
);
93 bool vtxSmartAudioInit(void);
95 #ifdef USE_SMARTAUDIO_DPRINTF
96 #define DPRINTF_SERIAL_PORT SERIAL_PORT_USART3
97 extern serialPort_t
*debugSerialPort
;
98 #define dprintf(x) if (debugSerialPort) tfp_printf x
101 #endif // USE_SMARTAUDIO_DPRINTF