mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
LP-322 Added USB ComBridge functionality to OPLink. Updated GCS code.
This commit is contained in:
parent
1647982fca
commit
a5a45576a1
@ -29,6 +29,7 @@ override USE_DSP_LIB := NO
|
||||
|
||||
# List of mandatory modules to include
|
||||
MODULES += RadioComBridge
|
||||
MODULES += ComUsbBridge
|
||||
|
||||
# List of optional modules to include
|
||||
OPTMODULES =
|
||||
|
@ -65,6 +65,8 @@ uint32_t pios_com_telem_vcp_id = 0;
|
||||
uint32_t pios_com_telem_uart_main_id = 0;
|
||||
uint32_t pios_com_telem_uart_flexi_id = 0;
|
||||
uint32_t pios_com_telemetry_id = 0;
|
||||
uint32_t pios_com_bridge_id = 0;
|
||||
uint32_t pios_com_vcp_id = 0;
|
||||
#if defined(PIOS_INCLUDE_PPM)
|
||||
uint32_t pios_ppm_rcvr_id = 0;
|
||||
#endif
|
||||
@ -76,14 +78,47 @@ uint32_t pios_rfm22b_id = 0;
|
||||
uint32_t pios_com_rfm22b_id = 0;
|
||||
uint32_t pios_com_radio_id = 0;
|
||||
#endif
|
||||
uint8_t *pios_uart_rx_buffer;
|
||||
uint8_t *pios_uart_tx_buffer;
|
||||
|
||||
uintptr_t pios_uavo_settings_fs_id;
|
||||
uintptr_t pios_user_fs_id = 0;
|
||||
|
||||
uint8_t servo_count = 0;
|
||||
|
||||
/*
|
||||
* Setup a com port based on the passed cfg, driver and buffer sizes.
|
||||
* tx size of -1 make the port rx only
|
||||
* rx size of -1 make the port tx only
|
||||
* having both tx and rx size of -1 is not valid and will fail further down in PIOS_COM_Init()
|
||||
*/
|
||||
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||
{
|
||||
uint32_t pios_usart_id;
|
||||
|
||||
if (PIOS_USART_Init(&pios_usart_id, usart_port_cfg)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
|
||||
uint8_t *rx_buffer = 0, *tx_buffer = 0;
|
||||
|
||||
if (rx_buf_len > 0) {
|
||||
rx_buffer = (uint8_t *)pios_malloc(rx_buf_len);
|
||||
PIOS_Assert(rx_buffer);
|
||||
}
|
||||
|
||||
if (tx_buf_len > 0) {
|
||||
tx_buffer = (uint8_t *)pios_malloc(tx_buf_len);
|
||||
PIOS_Assert(tx_buffer);
|
||||
}
|
||||
|
||||
if (PIOS_COM_Init(pios_com_id, com_driver, pios_usart_id,
|
||||
rx_buffer, rx_buf_len,
|
||||
tx_buffer, tx_buf_len)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Forward definitions
|
||||
static void PIOS_Board_PPM_callback(const int16_t *channels);
|
||||
|
||||
@ -218,10 +253,6 @@ void PIOS_Board_Init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate the uart buffers. */
|
||||
pios_uart_rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RX_BUF_LEN);
|
||||
pios_uart_tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_TX_BUF_LEN);
|
||||
|
||||
// Configure the main port
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
OPLinkSettingsGet(&oplinkSettings);
|
||||
@ -242,21 +273,19 @@ void PIOS_Board_Init(void)
|
||||
{
|
||||
/* Configure the main port for uart serial */
|
||||
#ifndef PIOS_RFM22B_DEBUG_ON_TELEM
|
||||
uint32_t pios_usart1_id;
|
||||
if (PIOS_USART_Init(&pios_usart1_id, &pios_usart_serial_cfg)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
PIOS_Assert(pios_uart_rx_buffer);
|
||||
PIOS_Assert(pios_uart_tx_buffer);
|
||||
if (PIOS_COM_Init(&pios_com_telem_uart_main_id, &pios_usart_com_driver, pios_usart1_id,
|
||||
pios_uart_rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN,
|
||||
pios_uart_tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
PIOS_Board_configure_com(&pios_usart_serial_cfg,
|
||||
PIOS_COM_TELEM_RX_BUF_LEN, PIOS_COM_TELEM_TX_BUF_LEN,
|
||||
&pios_usart_com_driver, &pios_com_telem_uart_main_id);
|
||||
|
||||
PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_MAIN;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case OPLINKSETTINGS_MAINPORT_COMBRIDGE:
|
||||
PIOS_Board_configure_com(&pios_usart_serial_cfg,
|
||||
PIOS_COM_TELEM_RX_BUF_LEN, PIOS_COM_TELEM_TX_BUF_LEN,
|
||||
&pios_usart_com_driver, &pios_com_bridge_id);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAINPORT_PPM:
|
||||
{
|
||||
#if defined(PIOS_INCLUDE_PPM)
|
||||
@ -291,21 +320,19 @@ void PIOS_Board_Init(void)
|
||||
case OPLINKSETTINGS_FLEXIPORT_SERIAL:
|
||||
{
|
||||
/* Configure the flexi port as uart serial */
|
||||
uint32_t pios_usart3_id;
|
||||
|
||||
if (PIOS_USART_Init(&pios_usart3_id, &pios_usart_telem_flexi_cfg)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
PIOS_Assert(pios_uart_rx_buffer);
|
||||
PIOS_Assert(pios_uart_tx_buffer);
|
||||
if (PIOS_COM_Init(&pios_com_telem_uart_flexi_id, &pios_usart_com_driver, pios_usart3_id,
|
||||
pios_uart_rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN,
|
||||
pios_uart_tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
PIOS_Board_configure_com(&pios_usart_telem_flexi_cfg,
|
||||
PIOS_COM_TELEM_RX_BUF_LEN, PIOS_COM_TELEM_TX_BUF_LEN,
|
||||
&pios_usart_com_driver,
|
||||
&pios_com_telem_uart_flexi_id);
|
||||
PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_FLEXI;
|
||||
break;
|
||||
}
|
||||
case OPLINKSETTINGS_FLEXIPORT_COMBRIDGE:
|
||||
PIOS_Board_configure_com(&pios_usart_telem_flexi_cfg,
|
||||
PIOS_COM_TELEM_RX_BUF_LEN, PIOS_COM_TELEM_TX_BUF_LEN,
|
||||
&pios_usart_com_driver,
|
||||
&pios_com_bridge_id);
|
||||
break;
|
||||
case OPLINKSETTINGS_FLEXIPORT_PPM:
|
||||
{
|
||||
#if defined(PIOS_INCLUDE_PPM)
|
||||
@ -335,6 +362,9 @@ void PIOS_Board_Init(void)
|
||||
case OPLINKSETTINGS_VCPPORT_SERIAL:
|
||||
PIOS_COM_TELEMETRY = PIOS_COM_TELEM_USB_VCP;
|
||||
break;
|
||||
case OPLINKSETTINGS_VCPPORT_COMBRIDGE:
|
||||
PIOS_COM_VCP = PIOS_COM_TELEM_USB_VCP;
|
||||
break;
|
||||
case OPLINKSETTINGS_VCPPORT_DISABLED:
|
||||
break;
|
||||
}
|
||||
|
@ -181,19 +181,22 @@ extern uint32_t pios_com_telem_uart_flexi_id;
|
||||
extern uint32_t pios_com_telemetry_id;
|
||||
extern uint32_t pios_com_rfm22b_id;
|
||||
extern uint32_t pios_com_radio_id;
|
||||
extern uint32_t pios_com_bridge_id;
|
||||
extern uint32_t pios_com_vcp_id;
|
||||
extern uint32_t pios_ppm_rcvr_id;
|
||||
extern uint32_t pios_ppm_out_id;
|
||||
#define PIOS_COM_TELEM_USB_HID (pios_com_telem_usb_id)
|
||||
#define PIOS_COM_TELEM_USB PIOS_COM_TELEM_USB_HID
|
||||
#define PIOS_COM_TELEM_USB_VCP (pios_com_telem_vcp_id)
|
||||
#define PIOS_COM_VCP (pios_com_vcp_id)
|
||||
#define PIOS_COM_TELEM_UART_MAIN (pios_com_telem_uart_main_id)
|
||||
#define PIOS_COM_TELEM_UART_FLEXI (pios_com_telem_uart_flexi_id)
|
||||
#define PIOS_COM_TELEMETRY (pios_com_telemetry_id)
|
||||
#define PIOS_COM_RFM22B (pios_com_rfm22b_id)
|
||||
#define PIOS_COM_RADIO (pios_com_radio_id)
|
||||
#define PIOS_COM_BRIDGE (pios_com_bridge_id)
|
||||
#define PIOS_PPM_RECEIVER (pios_ppm_rcvr_id)
|
||||
#define PIOS_PPM_OUTPUT (pios_ppm_out_id)
|
||||
|
||||
#define RFM22_DEBUG 1
|
||||
|
||||
// -------------------------
|
||||
|
@ -102,11 +102,14 @@ ConfigOPLinkWidget::ConfigOPLinkWidget(QWidget *parent) : ConfigTaskWidget(paren
|
||||
addWidgetBinding("OPLinkStatus", "TXPacketRate", m_oplink->TXPacketRate);
|
||||
|
||||
// Connect the selection changed signals.
|
||||
connect(m_oplink->Protocol, SIGNAL(valueChanged(int)), this, SLOT(protocolChanged()));
|
||||
connect(m_oplink->LinkType, SIGNAL(valueChanged(int)), this, SLOT(linkTypeChanged()));
|
||||
connect(m_oplink->Protocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolChanged()));
|
||||
connect(m_oplink->LinkType, SIGNAL(currentIndexChanged(int)), this, SLOT(linkTypeChanged()));
|
||||
connect(m_oplink->MinimumChannel, SIGNAL(valueChanged(int)), this, SLOT(minChannelChanged()));
|
||||
connect(m_oplink->MaximumChannel, SIGNAL(valueChanged(int)), this, SLOT(maxChannelChanged()));
|
||||
connect(m_oplink->CustomDeviceID, SIGNAL(editingFinished()), this, SLOT(updateCustomDeviceID()));
|
||||
connect(m_oplink->MainPort, SIGNAL(currentIndexChanged(int)), this, SLOT(mainPortChanged()));
|
||||
connect(m_oplink->FlexiPort, SIGNAL(currentIndexChanged(int)), this, SLOT(flexiPortChanged()));
|
||||
connect(m_oplink->VCPPort, SIGNAL(currentIndexChanged(int)), this, SLOT(vcpPortChanged()));
|
||||
|
||||
// Connect the Unbind button
|
||||
connect(m_oplink->UnbindButton, SIGNAL(released()), this, SLOT(unbind()));
|
||||
@ -268,7 +271,14 @@ void ConfigOPLinkWidget::protocolChanged()
|
||||
m_oplink->MaximumChannel->setEnabled(is_receiver || is_coordinator);
|
||||
m_oplink->MainPort->setEnabled(is_oplm);
|
||||
m_oplink->FlexiPort->setEnabled(is_oplm);
|
||||
m_oplink->VCPPort->setEnabled((is_receiver || is_coordinator) && is_oplm);
|
||||
m_oplink->VCPPort->setEnabled(is_oplm);
|
||||
|
||||
enableComboBoxOptionItem(m_oplink->VCPPort, OPLinkSettings::VCPPORT_SERIAL, (is_receiver || is_coordinator));
|
||||
|
||||
if (isComboboxOptionSelected(m_oplink->VCPPort, OPLinkSettings::VCPPORT_SERIAL) && !(is_receiver || is_coordinator)) {
|
||||
setComboboxSelectedOption(m_oplink->VCPPort, OPLinkSettings::VCPPORT_DISABLED);
|
||||
}
|
||||
|
||||
m_oplink->LinkType->setEnabled(is_enabled && !is_openlrs);
|
||||
m_oplink->MaxRFTxPower->setEnabled(is_enabled && !is_openlrs);
|
||||
}
|
||||
@ -322,6 +332,70 @@ void ConfigOPLinkWidget::channelChanged(bool isMax)
|
||||
m_oplink->MaxFreq->setText("(" + QString::number(maxFrequency, 'f', 3) + " MHz)");
|
||||
}
|
||||
|
||||
void ConfigOPLinkWidget::mainPortChanged()
|
||||
{
|
||||
switch (getComboboxSelectedOption(m_oplink->MainPort)) {
|
||||
case OPLinkSettings::MAINPORT_TELEMETRY:
|
||||
case OPLinkSettings::MAINPORT_SERIAL:
|
||||
if (isComboboxOptionSelected(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_TELEMETRY)
|
||||
|| isComboboxOptionSelected(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_SERIAL)) {
|
||||
setComboboxSelectedOption(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_DISABLED);
|
||||
}
|
||||
break;
|
||||
case OPLinkSettings::MAINPORT_COMBRIDGE:
|
||||
if (isComboboxOptionSelected(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_COMBRIDGE)) {
|
||||
setComboboxSelectedOption(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_DISABLED);
|
||||
}
|
||||
break;
|
||||
case OPLinkSettings::MAINPORT_PPM:
|
||||
if (isComboboxOptionSelected(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_PPM)) {
|
||||
setComboboxSelectedOption(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_DISABLED);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigOPLinkWidget::flexiPortChanged()
|
||||
{
|
||||
switch (getComboboxSelectedOption(m_oplink->FlexiPort)) {
|
||||
case OPLinkSettings::FLEXIPORT_TELEMETRY:
|
||||
case OPLinkSettings::FLEXIPORT_SERIAL:
|
||||
if (isComboboxOptionSelected(m_oplink->MainPort, OPLinkSettings::MAINPORT_TELEMETRY)
|
||||
|| isComboboxOptionSelected(m_oplink->MainPort, OPLinkSettings::MAINPORT_SERIAL)) {
|
||||
setComboboxSelectedOption(m_oplink->MainPort, OPLinkSettings::MAINPORT_DISABLED);
|
||||
}
|
||||
break;
|
||||
case OPLinkSettings::FLEXIPORT_COMBRIDGE:
|
||||
if (isComboboxOptionSelected(m_oplink->MainPort, OPLinkSettings::MAINPORT_COMBRIDGE)) {
|
||||
setComboboxSelectedOption(m_oplink->MainPort, OPLinkSettings::MAINPORT_DISABLED);
|
||||
}
|
||||
break;
|
||||
case OPLinkSettings::FLEXIPORT_PPM:
|
||||
if (isComboboxOptionSelected(m_oplink->MainPort, OPLinkSettings::MAINPORT_PPM)) {
|
||||
setComboboxSelectedOption(m_oplink->MainPort, OPLinkSettings::MAINPORT_DISABLED);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigOPLinkWidget::vcpPortChanged()
|
||||
{
|
||||
bool vcpComBridgeEnabled = isComboboxOptionSelected(m_oplink->VCPPort, OPLinkSettings::VCPPORT_COMBRIDGE);
|
||||
|
||||
enableComboBoxOptionItem(m_oplink->MainPort, OPLinkSettings::MAINPORT_COMBRIDGE, vcpComBridgeEnabled);
|
||||
enableComboBoxOptionItem(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_COMBRIDGE, vcpComBridgeEnabled);
|
||||
|
||||
if (!vcpComBridgeEnabled) {
|
||||
if (isComboboxOptionSelected(m_oplink->MainPort, OPLinkSettings::MAINPORT_COMBRIDGE)) {
|
||||
setComboboxSelectedOption(m_oplink->MainPort, OPLinkSettings::MAINPORT_DISABLED);
|
||||
}
|
||||
if (isComboboxOptionSelected(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_COMBRIDGE)) {
|
||||
setComboboxSelectedOption(m_oplink->FlexiPort, OPLinkSettings::FLEXIPORT_DISABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConfigOPLinkWidget::updateCoordID()
|
||||
{
|
||||
bool coordinatorNotSet = (m_oplink->CoordID->text() == "0");
|
||||
|
@ -70,6 +70,9 @@ private slots:
|
||||
void updateCustomDeviceID();
|
||||
void unbind();
|
||||
void channelChanged(bool isMax);
|
||||
void mainPortChanged();
|
||||
void flexiPortChanged();
|
||||
void vcpPortChanged();
|
||||
};
|
||||
|
||||
#endif // CONFIGOPLINKWIDGET_H
|
||||
|
@ -4,9 +4,9 @@
|
||||
<field name="Protocol" units="" type="enum" elements="1" options="Disabled,OPLinkReceiver,OPLinkCoordinator,OpenLRS" defaultvalue="Disabled"/>
|
||||
<field name="LinkType" units="" type="enum" elements="1" options="Data,Control,DataAndControl" defaultvalue="Data"/>
|
||||
<field name="CoordID" units="hex" type="uint32" elements="1" defaultvalue="0"/>
|
||||
<field name="MainPort" units="" type="enum" elements="1" options="Disabled,Telemetry,Serial,PPM,PWM" defaultvalue="Disabled"/>
|
||||
<field name="FlexiPort" units="" type="enum" elements="1" options="Disabled,Telemetry,Serial,PPM,PWM" defaultvalue="Disabled"/>
|
||||
<field name="VCPPort" units="" type="enum" elements="1" options="Disabled,Serial" defaultvalue="Disabled"/>
|
||||
<field name="MainPort" units="" type="enum" elements="1" options="Disabled,Telemetry,Serial,ComBridge,PPM,PWM" defaultvalue="Disabled"/>
|
||||
<field name="FlexiPort" units="" type="enum" elements="1" options="Disabled,Telemetry,Serial,ComBridge,PPM,PWM" defaultvalue="Disabled"/>
|
||||
<field name="VCPPort" units="" type="enum" elements="1" options="Disabled,Serial,ComBridge" defaultvalue="Disabled"/>
|
||||
<field name="ComSpeed" units="bps" type="enum" elements="1" options="4800,9600,19200,38400,57600,115200" defaultvalue="38400"/>
|
||||
<field name="MaxRFPower" units="mW" type="enum" elements="1" options="0,1.25,1.6,3.16,6.3,12.6,25,50,100" defaultvalue="0"/>
|
||||
<field name="MinChannel" units="" type="uint8" elements="1" defaultvalue="0"/>
|
||||
|
Loading…
Reference in New Issue
Block a user