1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-18 22:05:15 +03:00

Boilerplate for MAVLink RX

This commit is contained in:
Harry Phillips 2021-02-28 18:05:30 +00:00
parent cb2fccb7a0
commit b51ff817cb
No known key found for this signature in database
GPG key ID: E4F581AA073CD264
8 changed files with 88 additions and 1 deletions

View file

@ -386,6 +386,8 @@ main_sources(COMMON_SRC
rx/ibus.h
rx/jetiexbus.c
rx/jetiexbus.h
rx/mavlink.c
rx/mavlink.h
rx/msp.c
rx/msp.h
rx/msp_override.c

View file

@ -25,7 +25,7 @@ tables:
values: ["NONE", "PPM", "SERIAL", "MSP", "SPI", "UNUSED"]
enum: rxReceiverType_e
- name: serial_rx
values: ["SPEK1024", "SPEK2048", "SBUS", "SUMD", "SUMH", "XB-B", "XB-B-RJ01", "IBUS", "JETIEXBUS", "CRSF", "FPORT", "SBUS_FAST", "FPORT2", "SRXL2", "GHST"]
values: ["SPEK1024", "SPEK2048", "SBUS", "SUMD", "SUMH", "XB-B", "XB-B-RJ01", "IBUS", "JETIEXBUS", "CRSF", "FPORT", "SBUS_FAST", "FPORT2", "SRXL2", "GHST", "MAVLINK"]
- name: rx_spi_protocol
values: ["ELERES"]
enum: rx_spi_protocol_e

51
src/main/rx/mavlink.c Normal file
View file

@ -0,0 +1,51 @@
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "platform.h"
FILE_COMPILE_FOR_SPEED
#ifdef USE_SERIALRX_MAVLINK
#include "build/build_config.h"
#include "build/debug.h"
#include "common/crc.h"
#include "common/maths.h"
#include "common/utils.h"
#include "drivers/time.h"
#include "drivers/serial.h"
#include "drivers/serial_uart.h"
#include "io/serial.h"
#include "rx/rx.h"
#include "rx/mavlink.h"
#define MAVLINK_MAX_CHANNEL 18
bool mavlinkRxInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig)
{
// TODO
return false;
}
#endif

20
src/main/rx/mavlink.h Normal file
View file

@ -0,0 +1,20 @@
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
bool mavlinkRxInit(const struct rxConfig_s *initialRxConfig, struct rxRuntimeConfig_s *rxRuntimeConfig);

View file

@ -68,6 +68,7 @@
#include "rx/sumh.h"
#include "rx/xbus.h"
#include "rx/ghst.h"
#include "rx/mavlink.h"
//#define DEBUG_RX_SIGNAL_LOSS
@ -255,6 +256,11 @@ bool serialRxInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig
case SERIALRX_GHST:
enabled = ghstRxInit(rxConfig, rxRuntimeConfig);
break;
#endif
#ifdef USE_SERIALRX_MAVLINK
case SERIALRX_MAVLINK:
enabled = mavlinkRxInit(rxConfig, rxRuntimeConfig);
break;
#endif
default:
enabled = false;

View file

@ -84,6 +84,7 @@ typedef enum {
SERIALRX_FPORT2 = 12,
SERIALRX_SRXL2 = 13,
SERIALRX_GHST = 14,
SERIALRX_MAVLINK = 15,
} rxSerialReceiverType_e;
#define MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT 16

View file

@ -177,6 +177,7 @@
#define USE_SERIALRX_SUMH
#define USE_SERIALRX_XBUS
#define USE_SERIALRX_JETIEXBUS
#define USE_SERIALRX_MAVLINK
#define USE_SERIALRX_CRSF
#define USE_PWM_SERVO_DRIVER
#define USE_SERIAL_PASSTHROUGH

View file

@ -1010,6 +1010,10 @@ static bool handleIncoming_MISSION_REQUEST(void)
return false;
}
static bool handleIncoming_RC_CHANNELS_OVERRIDE(void) {
}
static bool processMAVLinkIncomingTelemetry(void)
{
while (serialRxBytesWaiting(mavlinkPort) > 0) {
@ -1030,6 +1034,8 @@ static bool processMAVLinkIncomingTelemetry(void)
return handleIncoming_MISSION_REQUEST_LIST();
case MAVLINK_MSG_ID_MISSION_REQUEST:
return handleIncoming_MISSION_REQUEST();
case MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE:
return handleIncoming_RC_CHANNELS_OVERRIDE();
default:
return false;
}