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 #define VTX_SMARTAUDIO_MIN_BAND 1
29 #define VTX_SMARTAUDIO_MAX_BAND 5
30 #define VTX_SMARTAUDIO_MIN_CHANNEL 1
31 #define VTX_SMARTAUDIO_MAX_CHANNEL 8
33 #define VTX_SMARTAUDIO_BAND_COUNT (VTX_SMARTAUDIO_MAX_BAND - VTX_SMARTAUDIO_MIN_BAND + 1)
34 #define VTX_SMARTAUDIO_CHANNEL_COUNT (VTX_SMARTAUDIO_MAX_CHANNEL - VTX_SMARTAUDIO_MIN_CHANNEL + 1)
36 #define VTX_SMARTAUDIO_MAX_POWER_COUNT 8
37 #define VTX_SMARTAUDIO_DEFAULT_POWER_COUNT 4
38 #define VTX_SMARTAUDIO_DEFAULT_POWER 1
40 #define VTX_SMARTAUDIO_MIN_FREQUENCY_MHZ 5000 //min freq in MHz
41 #define VTX_SMARTAUDIO_MAX_FREQUENCY_MHZ 5999 //max freq in MHz
43 // opmode flags, GET side
44 #define SA_MODE_GET_FREQ_BY_FREQ 1
45 #define SA_MODE_GET_PITMODE 2
46 #define SA_MODE_GET_IN_RANGE_PITMODE 4
47 #define SA_MODE_GET_OUT_RANGE_PITMODE 8
48 #define SA_MODE_GET_UNLOCK 16
49 #define SA_MODE_GET_DEFERRED_FREQ 32
51 // opmode flags, SET side
52 #define SA_MODE_SET_IN_RANGE_PITMODE 1 // Immediate
53 #define SA_MODE_SET_OUT_RANGE_PITMODE 2 // Immediate
54 #define SA_MODE_CLR_PITMODE 4 // Immediate
55 #define SA_MODE_SET_UNLOCK 8
56 #define SA_MODE_SET_LOCK 0 // ~UNLOCK
57 #define SA_MODE_SET_DEFERRED_FREQ 16
59 // SetFrequency flags, for pit mode frequency manipulation
60 #define SA_FREQ_GETPIT (1 << 14)
61 #define SA_FREQ_SETPIT (1 << 15)
62 #define SA_FREQ_MASK (~(SA_FREQ_GETPIT|SA_FREQ_SETPIT))
64 // For generic API use, but here for now
66 SA_UNKNOWN
, // or offline
70 } smartAudioVersion_e
;
72 typedef struct smartAudioDevice_s
{
73 smartAudioVersion_e version
;
79 bool willBootIntoPitMode
;
82 typedef struct saPowerTable_s
{
84 int16_t dbi
; // valueV1
87 typedef struct smartAudioStat_s
{
97 extern smartAudioDevice_t saDevice
;
98 extern saPowerTable_t saPowerTable
[];
100 extern uint8_t saPowerCount
;
101 extern const char * saPowerNames
[VTX_SMARTAUDIO_MAX_POWER_COUNT
+ 1];
102 extern smartAudioStat_t saStat
;
104 extern uint16_t sa_smartbaud
;
105 extern bool saDeferred
;
107 int saDacToPowerIndex(int dac
);
108 void saSetBandAndChannel(uint8_t band
, uint8_t channel
);
109 void saSetMode(int mode
);
110 void saSetPowerByIndex(uint8_t index
);
111 void saSetFreq(uint16_t freq
);
112 void saSetPitFreq(uint16_t freq
);
113 bool vtxSmartAudioInit(void);