44 5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725,
45 5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866,
46 5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945,
47 5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880,
48 5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917
97 static int32_t
tbsvtx_tx_msg(uintptr_t usart_id, uint8_t *buff, uint8_t n_bytes)
107 for (
int i=0;
i<n_bytes;
i++) {
113 int32_t
tbsvtx_rx_msg(uintptr_t usart_id, uint8_t n_bytes, uint8_t *buff, uint16_t timeout)
118 uint8_t bytes_rx = 2;
126 if (c == n_bytes - 2) {
138 while(bytes_rx < n_bytes) {
140 buff[bytes_rx++] = c;
150 if (crc != buff[n_bytes - 1]) {
161 uint8_t msg[7] = {0x00, 0xAA, 0x55, 0x03, 0x00, 0x00, 0x00};
168 if (
tbsvtx_rx_msg(usart_id,
sizeof(info_msg), (uint8_t*)&info_msg, 200) < 0) {
173 if (((info_msg.command & 0x07) != 0x01) || (info_msg.channel >=
NUM_TBS_CH)) {
177 switch ((info_msg.command >> 3) & 0x1F) {
179 info->Model = VTXINFO_MODEL_TBSUNIFYPRO5G8;
183 info->Model = VTXINFO_MODEL_TBSUNIFYPRO5G8HV;
187 info->Model = VTXINFO_MODEL_NONE;
192 info->Frequency =
TBS_CH[info_msg.channel];
196 switch(info_msg.pwr_level) {
214 if (info_msg.operation_mode & 0x02) {
219 switch(info_msg.pwr_level) {
247 uint8_t channel = 255;
254 if (channel == 255) {
259 uint8_t set_ch_msg[8] = {0x00, 0xAA, 0x55, 0x07, 0x01, 0x00, 0x00, 0x00};
260 set_ch_msg[5] = channel;
263 SET_CHANNEL set_ch_resp;
264 if (
tbsvtx_rx_msg(usart_id,
sizeof(set_ch_resp), (uint8_t*)&set_ch_resp, 200) < 0) {
269 if ((set_ch_resp.command != 0x03) || (set_ch_resp.channel != channel)) {
278 uint8_t mode_msg[8] = {0x00, 0xAA, 0x55, 0x0B, 0x01, 0x00, 0x00, 0x00};
282 SET_MODE set_mode_resp;
283 if (
tbsvtx_rx_msg(usart_id,
sizeof(set_mode_resp), (uint8_t*)&set_mode_resp, 200) < 0) {
288 if ((set_mode_resp.command != 0x05) || (set_mode_resp.mode != mode)) {
345 uint8_t set_pwr_msg[8] = {0x00, 0xAA, 0x55, 0x05, 0x01, 0x00, 0x00, 0x00};
346 set_pwr_msg[5] = power_byte;
349 SET_POWER set_pwr_resp;
350 if (
tbsvtx_rx_msg(usart_id,
sizeof(set_pwr_resp), (uint8_t*)&set_pwr_resp, 200) < 0) {
355 if ((set_pwr_resp.command != 0x02) || (set_pwr_resp.pwr != power_byte)) {
uint32_t PIOS_Thread_Systime(void)
static enum TBS_VTX_PROTOCOL vtx_protocol
const uint16_t TBS_CH[NUM_TBS_CH]
int32_t tbsvtx_set_freq(uintptr_t usart_id, uint16_t frequency)
uint16_t PIOS_COM_ReceiveBuffer(uintptr_t com_id, uint8_t *buf, uint16_t buf_len, uint32_t timeout_ms)
int32_t tbsvtx_rx_msg(uintptr_t usart_id, uint8_t n_bytes, uint8_t *buff, uint16_t timeout)
int32_t tbsvtx_set_power(uintptr_t usart_id, uint16_t power)
uint8_t PIOS_CRC_updateCRC_TBS(uint8_t crc, const uint8_t *data, int32_t length)
static int32_t tbsvtx_set_mode(uintptr_t usart_id, uint8_t mode)
static int32_t tbsvtx_tx_msg(uintptr_t usart_id, uint8_t *buff, uint8_t n_bytes)
void PIOS_Thread_Sleep(uint32_t time_ms)
PIOS_COM_SendBuffer(shub_global->frsky_port, shub_global->serial_buf, msg_length)
Includes PiOS and core architecture components.
int32_t tbsvtx_get_state(uintptr_t usart_id, VTXInfoData *info)