1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

Added PPM output to OPLink firmware

This commit is contained in:
Brian Webb 2013-01-04 06:51:27 -07:00
parent 7d86ddc6f7
commit be444db7f8
9 changed files with 92 additions and 12 deletions

View File

@ -180,6 +180,7 @@ 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_ppm_rcvr_id;
extern uint32_t pios_ppm_out_id;
#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
#define PIOS_COM_TELEM_VCP (pios_com_telem_vcp_id)
#define PIOS_COM_TELEM_UART_FLEXI (pios_com_telem_uart_flexi_id)
@ -188,6 +189,7 @@ extern uint32_t pios_ppm_rcvr_id;
#define PIOS_COM_RFM22B (pios_com_rfm22b_id)
#define PIOS_COM_RADIO (pios_com_radio_id)
#define PIOS_PPM_RECEIVER (pios_ppm_rcvr_id)
#define PIOS_PPM_OUTPUT (pios_ppm_out_id)
#define DEBUG_LEVEL 2
#if DEBUG_LEVEL > 1000

View File

@ -54,6 +54,7 @@
#include <pios_spi_priv.h>
#include <packet_handler.h>
#include <pios_rfm22b_priv.h>
#include <pios_ppm_out_priv.h>
#include <ecc.h>
/* Local Defines */
@ -1786,7 +1787,13 @@ static enum pios_rfm22b_event rfm22_rxData(struct pios_rfm22b_dev *rfm22b_dev)
{
PHPpmPacketHandle ppmp = (PHPpmPacketHandle)&(rfm22b_dev->rx_packet);
for (uint8_t i = 0; i < PIOS_RFM22B_RCVR_MAX_CHANNELS; ++i)
{
rfm22b_dev->ppm_channel[i] = ppmp->channels[i];
#if defined(PIOS_INCLUDE_PPM_OUT) && defined(PIOS_PPM_OUTPUT)
if (PIOS_PPM_OUTPUT)
PIOS_PPM_OUT_Set(PIOS_PPM_OUTPUT, i, ppmp->channels[i]);
#endif /* PIOS_INCLUDE_PPM_OUT && PIOS_PPM_OUTPUT */
}
rfm22b_dev->ppm_fresh = true;
break;
}

View File

@ -160,6 +160,7 @@ SRC += $(PIOSSTM32F10X)/pios_usart.c
SRC += $(PIOSSTM32F10X)/pios_irq.c
SRC += $(PIOSSTM32F10X)/pios_spi.c
SRC += $(PIOSSTM32F10X)/pios_ppm.c
SRC += $(PIOSSTM32F10X)/pios_ppm_out.c
SRC += $(PIOSSTM32F10X)/pios_debug.c
SRC += $(PIOSSTM32F10X)/pios_gpio.c
SRC += $(PIOSSTM32F10X)/pios_exti.c

View File

@ -64,6 +64,7 @@
#define PIOS_INCLUDE_FLASH_EEPROM
#define PIOS_INCLUDE_RFM22B
#define PIOS_INCLUDE_PACKET_HANDLER
#define PIOS_INCLUDE_PPM_OUT
/* Defaults for Logging */
#define LOG_FILENAME "PIOS.LOG"

View File

@ -53,6 +53,9 @@ uint32_t pios_com_telemetry_id = 0;
#if defined(PIOS_INCLUDE_PPM)
uint32_t pios_ppm_rcvr_id = 0;
#endif
#if defined(PIOS_INCLUDE_PPM_OUT)
uint32_t pios_ppm_out_id = 0;
#endif
#if defined(PIOS_INCLUDE_RFM22B)
uint32_t pios_rfm22b_id = 0;
uint32_t pios_com_rfm22b_id = 0;
@ -197,20 +200,29 @@ void PIOS_Board_Init(void) {
#endif
/* Configure PPM input */
switch (oplinkSettings.PPM)
{
#if defined(PIOS_INCLUDE_PPM)
if (oplinkSettings.PPM == OPLINKSETTINGS_PPM_TRUE)
case OPLINKSETTINGS_PPM_INPUT:
{
uint32_t pios_ppm_id;
PIOS_PPM_Init(&pios_ppm_id, &pios_ppm_cfg);
if (PIOS_RCVR_Init(&pios_ppm_rcvr_id, &pios_ppm_rcvr_driver, pios_ppm_id))
PIOS_Assert(0);
break;
}
else
#endif /* PIOS_INCLUDE_PPM */
/* Configure the flexi serial port */
#if defined(PIOS_INCLUDE_PPM_OUT)
case OPLINKSETTINGS_PPM_OUTPUT:
PIOS_PPM_Out_Init(&pios_ppm_out_id, &pios_ppm_out_cfg);
break;
#endif /* PIOS_INCLUDE_PPM_OUT */
default:
{
/* Configure the flexi serial port if PPM not selected */
uint32_t pios_usart3_id;
if (PIOS_USART_Init(&pios_usart3_id, &pios_usart_telem_flexi_cfg)) {
PIOS_Assert(0);
@ -225,6 +237,7 @@ void PIOS_Board_Init(void) {
PIOS_Assert(0);
}
}
}
/* Initalize the RFM22B radio COM device. */
#if defined(PIOS_INCLUDE_RFM22B)

View File

@ -554,6 +554,46 @@ const struct pios_ppm_cfg pios_ppm_cfg = {
#endif /* PIOS_INCLUDE_PPM */
/*
* PPM Output
*/
#if defined(PIOS_INCLUDE_PPM_OUT)
#include <pios_ppm_out_priv.h>
uint32_t pios_ppm_id;
static const struct pios_tim_channel pios_tim_ppmout[] = {
{
.timer = TIM2,
.timer_chan = TIM_Channel_3,
.pin = {
.gpio = GPIOB,
.init = {
.GPIO_Pin = GPIO_Pin_10,
.GPIO_Mode = GPIO_Mode_AF_PP,
.GPIO_Speed = GPIO_Speed_2MHz,
},
},
.remap = GPIO_FullRemap_TIM2,
}
};
const struct pios_ppm_out_cfg pios_ppm_out_cfg = {
.tim_oc_init = {
.TIM_OCMode = TIM_OCMode_PWM1,
.TIM_OutputState = TIM_OutputState_Enable,
.TIM_OutputNState = TIM_OutputNState_Disable,
.TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
.TIM_OCPolarity = TIM_OCPolarity_Low,
.TIM_OCNPolarity = TIM_OCPolarity_Low,
.TIM_OCIdleState = TIM_OCIdleState_Reset,
.TIM_OCNIdleState = TIM_OCNIdleState_Reset,
},
.channel = pios_tim_ppmout,
};
#endif /* PIOS_INCLUDE_PPM_OUT */
#if defined(PIOS_INCLUDE_RCVR)
#include "pios_rcvr_priv.h"

View File

@ -56,8 +56,8 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget
addApplySaveButtons(m_oplink->Apply, m_oplink->Save);
addUAVObjectToWidgetRelation("OPLinkSettings", "Coordinator", m_oplink->Coordinator);
addUAVObjectToWidgetRelation("OPLinkSettings", "PPM", m_oplink->PPM);
addUAVObjectToWidgetRelation("OPLinkSettings", "UAVTalk", m_oplink->UAVTalk);
addUAVObjectToWidgetRelation("OPLinkSettings", "PPM", m_oplink->PPM);
addUAVObjectToWidgetRelation("OPLinkSettings", "InputConnection", m_oplink->InputConnection);
addUAVObjectToWidgetRelation("OPLinkSettings", "OutputConnection", m_oplink->OutputConnection);
addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed);

View File

@ -1559,19 +1559,35 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="PPM">
<property name="text">
<string>PPM</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="UAVTalk">
<property name="text">
<string>UAVTalk</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="PPMLabel">
<property name="text">
<string>PPM</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="PPM">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Choose the PPM function</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="InputConnectionLabel">
<property name="text">

View File

@ -3,8 +3,8 @@
<description>OPLink configurations options.</description>
<field name="PairID" units="" type="uint32" elements="1" defaultvalue="0"/>
<field name="Coordinator" units="binary" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="FALSE"/>
<field name="PPM" units="binary" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="FALSE"/>
<field name="UAVTalk" units="binary" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="FALSE"/>
<field name="PPM" units="" type="enum" elements="1" options="Disabled,Input,Output" defaultvalue="Disabled"/>
<field name="InputConnection" units="function" type="enum" elements="1" options="HID,VCP,Telemetry,Flexi" defaultvalue="HID"/>
<field name="OutputConnection" units="function" type="enum" elements="1" options="RemoteHID,RemoteVCP,RemoteTelemetry,RemoteFlexi,Telemetry,Flexi" defaultvalue="RemoteTelemetry"/>
<field name="ComSpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200" defaultvalue="38400"/>