1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Merge remote-tracking branch 'raid/Brian-PipXtreme-V2' into Brian-PipXtreme-V2

This commit is contained in:
Brian Webb 2012-05-20 18:31:34 -07:00
commit 19c79d627a
12 changed files with 182 additions and 85 deletions

View File

@ -353,7 +353,7 @@ uint8_t PHReceivePacket(PHInstHandle h, PHPacketHandle p, bool rx_error)
if (!rx_error)
// Pass on the channels to the PPM handler.
// Pass on the channels to the status handler.
if(data->status_handler)
data->status_handler((PHStatusPacketHandle)p);

View File

@ -85,6 +85,7 @@ typedef struct {
xTaskHandle sendDataTaskHandle;
xTaskHandle radioStatusTaskHandle;
xTaskHandle transparentCommTaskHandle;
xTaskHandle ppmInputTaskHandle;
// The UAVTalk connection on the com side.
UAVTalkConnection inUAVTalkCon;
@ -135,6 +136,7 @@ static void sendPacketTask(void *parameters);
static void sendDataTask(void *parameters);
static void transparentCommTask(void * parameters);
static void radioStatusTask(void *parameters);
static void ppmInputTask(void *parameters);
static int32_t transmitData(uint8_t * data, int32_t length);
static int32_t transmitPacket(PHPacketHandle packet);
static void receiveData(uint8_t *buf, uint8_t len);
@ -166,6 +168,8 @@ static int32_t RadioComBridgeStart(void)
xTaskCreate(sendPacketTask, (signed char *)"SendPacketTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY + 2, &(data->sendPacketTaskHandle));
xTaskCreate(sendDataTask, (signed char *)"SendDataTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY+ 2, &(data->sendDataTaskHandle));
xTaskCreate(radioStatusTask, (signed char *)"RadioStatus", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioStatusTaskHandle));
if(PIOS_PPM_RECEIVER)
xTaskCreate(ppmInputTask, (signed char *)"PPMInputTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY + 2, &(data->ppmInputTaskHandle));
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_RegisterFlag(PIOS_WDG_COMUAVTALK);
if(PIOS_COM_TRANS_COM)
@ -173,6 +177,8 @@ static int32_t RadioComBridgeStart(void)
PIOS_WDG_RegisterFlag(PIOS_WDG_RADIORECEIVE);
PIOS_WDG_RegisterFlag(PIOS_WDG_SENDPACKET);
//PIOS_WDG_RegisterFlag(PIOS_WDG_SENDDATA);
if(PIOS_PPM_RECEIVER)
PIOS_WDG_RegisterFlag(PIOS_WDG_PPMINPUT);
#endif
return 0;
}
@ -330,7 +336,8 @@ static void comUAVTalkTask(void *parameters)
if (state == UAVTALK_STATE_COMPLETE)
{
// Is this a local UAVObject?
if (iproc->obj != NULL)
// We only generate GcsReceiver ojects, we don't consume them.
if ((iproc->obj != NULL) && (iproc->objId != GCSRECEIVER_OBJID))
{
// We treat the ObjectPersistence object differently
if(iproc->objId == OBJECTPERSISTENCE_OBJID)
@ -678,9 +685,6 @@ static void transparentCommTask(void * parameters)
static void radioStatusTask(void *parameters)
{
PHStatusPacket status_packet;
status_packet.header.destination_id = 0xffffffff;
status_packet.header.type = PACKET_TYPE_STATUS;
status_packet.header.data_size = PH_STATUS_DATA_SIZE(&status_packet);
while (1) {
PipXStatusData pipxStatus;
@ -691,7 +695,6 @@ static void radioStatusTask(void *parameters)
PipXSettingsPairIDGet(&pairID);
// Update the status
PIOS_BL_HELPER_FLASH_Read_Description(pipxStatus.Description, PIPXSTATUS_DESCRIPTION_NUMELEM);
pipxStatus.DeviceID = PIOS_RFM22B_DeviceID(pios_rfm22b_id);
pipxStatus.RSSI = PIOS_RFM22B_RSSI(pios_rfm22b_id);
pipxStatus.Retries = data->comTxRetries;
@ -730,6 +733,9 @@ static void radioStatusTask(void *parameters)
if(cntr++ == RADIOSTATS_UPDATE_PERIOD_MS / STATS_UPDATE_PERIOD_MS)
{
// Queue the status message
status_packet.header.destination_id = 0xffffffff;
status_packet.header.type = PACKET_TYPE_STATUS;
status_packet.header.data_size = PH_STATUS_DATA_SIZE(&status_packet);
status_packet.header.source_id = pipxStatus.DeviceID;
status_packet.header.rssi = pipxStatus.RSSI;
status_packet.retries = data->comTxRetries;
@ -747,6 +753,37 @@ static void radioStatusTask(void *parameters)
}
}
/**
* The PPM input task.
*/
static void ppmInputTask(void *parameters)
{
PHPpmPacket ppm_packet;
PHPacketHandle pph = (PHPacketHandle)&ppm_packet;
while (1) {
#ifdef PIOS_INCLUDE_WDG
// Update the watchdog timer.
PIOS_WDG_UpdateFlag(PIOS_WDG_PPMINPUT);
#endif /* PIOS_INCLUDE_WDG */
// Send the PPM packet
for (uint8_t i = 1; i <= PIOS_PPM_NUM_INPUTS; ++i)
ppm_packet.channels[i - 1] = PIOS_RCVR_Read(PIOS_PPM_RECEIVER, i);
// Send the packet.
ppm_packet.header.destination_id = data->destination_id;
ppm_packet.header.source_id = PIOS_RFM22B_DeviceID(pios_rfm22b_id);
ppm_packet.header.type = PACKET_TYPE_PPM;
ppm_packet.header.data_size = PH_PPM_DATA_SIZE(&ppm_packet);
xQueueSend(data->sendPacketQueue, &pph, MAX_PORT_DELAY);
// Delay until the next update period.
vTaskDelay(PIOS_PPM_PACKET_UPDATE_PERIOD_MS / portTICK_RATE_MS);
}
}
/**
* Transmit data buffer to the com port.
* \param[in] buf Data buffer to send

View File

@ -215,6 +215,7 @@ extern uint32_t pios_com_telem_usb_id;
//------------------------
#define PIOS_RCVR_MAX_DEVS 3
#define PIOS_RCVR_MAX_CHANNELS 12
#define PIOS_GCSRCVR_TIMEOUT_MS 100
//-------------------------
// Receiver PPM input

View File

@ -76,6 +76,7 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
#define PIOS_WDG_SENDPACKET 0x0004
#define PIOS_WDG_SENDDATA 0x0008
#define PIOS_WDG_TRANSCOMM 0x0010
#define PIOS_WDG_PPMINPUT 0x0020
//------------------------
// TELEMETRY
@ -159,6 +160,7 @@ extern uint32_t pios_com_uavtalk_com_id;
extern uint32_t pios_com_trans_com_id;
extern uint32_t pios_com_debug_id;
extern uint32_t pios_com_rfm22b_id;
extern uint32_t pios_ppm_rcvr_id;
#define PIOS_COM_USB_HID (pios_com_telem_usb_id)
#define PIOS_COM_TELEMETRY (pios_com_telemetry_id)
#define PIOS_COM_FLEXI (pios_com_flexi_id)
@ -168,6 +170,7 @@ extern uint32_t pios_com_rfm22b_id;
#define PIOS_COM_DEBUG (pios_com_debug_id)
#define PIOS_COM_RADIO (pios_com_rfm22b_id)
#define PIOS_COM_TELEM_USB PIOS_COM_USB_HID
#define PIOS_PPM_RECEIVER (pios_ppm_rcvr_id)
#define DEBUG_LEVEL 2
#if DEBUG_LEVEL > 0
@ -221,18 +224,14 @@ extern uint32_t pios_com_rfm22b_id;
//------------------------
#define PIOS_RCVR_MAX_DEVS 3
#define PIOS_RCVR_MAX_CHANNELS 12
#define PIOS_GCSRCVR_TIMEOUT_MS 100
//-------------------------
// Receiver PPM input
//-------------------------
#define PIOS_PPM_MAX_DEVS 1
#define PIOS_PPM_NUM_INPUTS 12
//-------------------------
// Receiver PWM input
//-------------------------
#define PIOS_PWM_MAX_DEVS 1
#define PIOS_PWM_NUM_INPUTS 1
#define PIOS_PPM_PACKET_UPDATE_PERIOD_MS 25
//-------------------------
// Servo outputs

View File

@ -152,10 +152,9 @@ static void PIOS_gcsrcvr_Supervisor(uint32_t gcsrcvr_id) {
}
/*
* RTC runs at 625Hz so divide down the base rate so
* that this loop runs at 25Hz.
* RTC runs at 625Hz.
*/
if(++(gcsrcvr_dev->supv_timer) < 25) {
if(++(gcsrcvr_dev->supv_timer) < (PIOS_GCSRCVR_TIMEOUT_MS * 1000 / 625)) {
return;
}
gcsrcvr_dev->supv_timer = 0;

View File

@ -44,7 +44,6 @@
/* Supported receiver interfaces */
#define PIOS_INCLUDE_PPM
#define PIOS_INCLUDE_PWM
/* Supported USART-based PIOS modules */
#define PIOS_INCLUDE_SPI

View File

@ -57,6 +57,7 @@ uint32_t pios_com_trans_com_id = 0;
uint32_t pios_com_debug_id = 0;
uint32_t pios_com_rfm22b_id = 0;
uint32_t pios_rfm22b_id = 0;
uint32_t pios_ppm_rcvr_id = 0;
/**
* PIOS_Board_Init()
@ -243,9 +244,6 @@ void PIOS_Board_Init(void) {
}
break;
}
case PIPXSETTINGS_TELEMETRYCONFIG_PPM_IN:
case PIPXSETTINGS_TELEMETRYCONFIG_PPM_OUT:
case PIPXSETTINGS_TELEMETRYCONFIG_RSSI:
case PIPXSETTINGS_TELEMETRYCONFIG_DISABLED:
break;
}
@ -285,6 +283,16 @@ void PIOS_Board_Init(void) {
break;
}
case PIPXSETTINGS_FLEXICONFIG_PPM_IN:
#if defined(PIOS_INCLUDE_PPM)
{
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);
}
}
#endif /* PIOS_INCLUDE_PPM */
case PIPXSETTINGS_FLEXICONFIG_PPM_OUT:
case PIPXSETTINGS_FLEXICONFIG_RSSI:
case PIPXSETTINGS_FLEXICONFIG_DISABLED:

View File

@ -236,6 +236,89 @@ void PIOS_ADC_handler() {
#endif /* PIOS_INCLUDE_ADC */
#if defined(PIOS_INCLUDE_TIM)
#include "pios_tim_priv.h"
static const TIM_TimeBaseInitTypeDef tim_1_2_3_4_time_base = {
.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1,
.TIM_ClockDivision = TIM_CKD_DIV1,
.TIM_CounterMode = TIM_CounterMode_Up,
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
.TIM_RepetitionCounter = 0x0000,
};
static const struct pios_tim_clock_cfg tim_1_cfg = {
.timer = TIM1,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM1_CC_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
};
static const struct pios_tim_clock_cfg tim_2_cfg = {
.timer = TIM2,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM2_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
};
static const struct pios_tim_clock_cfg tim_3_cfg = {
.timer = TIM3,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM3_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
};
static const struct pios_tim_clock_cfg tim_4_cfg = {
.timer = TIM4,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM4_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
};
static const struct pios_tim_channel pios_tim_ppm_flexi_port = {
//.timer = TIM2,
.timer = TIM4,
//.timer_chan = TIM_Channel_4,
.timer_chan = TIM_Channel_4,
.pin = {
.gpio = GPIOB,
.init = {
//.GPIO_Pin = GPIO_Pin_11,
.GPIO_Pin = GPIO_Pin_9,
.GPIO_Mode = GPIO_Mode_IPD,
.GPIO_Speed = GPIO_Speed_2MHz,
},
},
//.remap = GPIO_PartialRemap_TIM2,
};
#endif /* PIOS_INCLUDE_TIM */
#if defined(PIOS_INCLUDE_USART)
#include <pios_usart_priv.h>
@ -359,71 +442,29 @@ void PIOS_RTC_IRQ_Handler (void)
#endif
#if defined(PIOS_INCLUDE_TIM)
/*
* PPM Inputs
*/
#if defined(PIOS_INCLUDE_PPM)
#include <pios_ppm_priv.h>
#include "pios_tim_priv.h"
static const TIM_TimeBaseInitTypeDef tim_1_2_3_4_time_base = {
.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1,
.TIM_ClockDivision = TIM_CKD_DIV1,
.TIM_CounterMode = TIM_CounterMode_Up,
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
.TIM_RepetitionCounter = 0x0000,
};
static const struct pios_tim_clock_cfg tim_1_cfg = {
.timer = TIM1,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM1_CC_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
const struct pios_ppm_cfg pios_ppm_cfg = {
.tim_ic_init = {
.TIM_ICPolarity = TIM_ICPolarity_Rising,
.TIM_ICSelection = TIM_ICSelection_DirectTI,
.TIM_ICPrescaler = TIM_ICPSC_DIV1,
.TIM_ICFilter = 0x0,
},
.channels = &pios_tim_ppm_flexi_port,
.num_channels = 1,
};
static const struct pios_tim_clock_cfg tim_2_cfg = {
.timer = TIM2,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM2_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
};
#endif /* PIOS_INCLUDE_PPM */
static const struct pios_tim_clock_cfg tim_3_cfg = {
.timer = TIM3,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM3_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
};
#if defined(PIOS_INCLUDE_RCVR)
#include "pios_rcvr_priv.h"
static const struct pios_tim_clock_cfg tim_4_cfg = {
.timer = TIM4,
.time_base_init = &tim_1_2_3_4_time_base,
.irq = {
.init = {
.NVIC_IRQChannel = TIM4_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
};
#endif /* PIOS_INCLUDE_TIM */
#endif /* PIOS_INCLUDE_RCVR */
#if defined(PIOS_INCLUDE_USB)
#include "pios_usb_priv.h"

View File

@ -32,7 +32,7 @@
/**
* Constructor
*/
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);")
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL)
{
pm = ExtensionSystem::PluginManager::instance();
objManager = pm->getObject<UAVObjectManager>();
@ -176,6 +176,10 @@ ConfigTaskWidget::~ConfigTaskWidget()
if(oTw)
delete oTw;
}
if(timeOut)
{
delete timeOut;
}
}
void ConfigTaskWidget::saveObjectToSD(UAVObject *obj)
@ -781,7 +785,7 @@ void ConfigTaskWidget::reloadButtonClicked()
if(!list)
return;
ObjectPersistence* objper = dynamic_cast<ObjectPersistence*>( getObjectManager()->getObject(ObjectPersistence::NAME) );
QTimer * timeOut=new QTimer(this);
timeOut=new QTimer(this);
QEventLoop * eventLoop=new QEventLoop(this);
connect(timeOut, SIGNAL(timeout()),eventLoop,SLOT(quit()));
connect(objper, SIGNAL(objectUpdated(UAVObject*)), eventLoop, SLOT(quit()));
@ -800,13 +804,22 @@ void ConfigTaskWidget::reloadButtonClicked()
eventLoop->exec();
if(timeOut->isActive())
{
oTw->object->requestUpdate();
setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited);
}
timeOut->stop();
}
}
delete eventLoop;
delete timeOut;
if(eventLoop)
{
delete eventLoop;
eventLoop=NULL;
}
if(timeOut)
{
delete timeOut;
timeOut=NULL;
}
}
/**
@ -998,7 +1011,6 @@ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, dou
cb->setText(value.toString());
else
cb->setText(QString::number((value.toDouble()/scale)));
return true;
}
else
return false;

View File

@ -164,6 +164,7 @@ private:
void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function);
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale);
QString outOfLimitsStyle;
QTimer * timeOut;
protected slots:
virtual void disableObjUpdates();
virtual void enableObjUpdates();

View File

@ -4,7 +4,7 @@
<field name="Channel" units="us" type="uint16" elements="6"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="onchange" period="0"/>
<telemetryflight acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="onchange" period="0"/>
<logging updatemode="manual" period="0"/>
</object>
</xml>

View File

@ -2,7 +2,7 @@
<object name="PipXSettings" singleinstance="true" settings="true">
<description>PipXtreme configurations options.</description>
<field name="PairID" units="" type="uint32" elements="1" defaultvalue="0"/>
<field name="TelemetryConfig" units="function" type="enum" elements="1" options="Disabled,Serial,UAVTalk,PPM_In,PPM_Out,RSSI,Debug" defaultvalue="UAVTalk"/>
<field name="TelemetryConfig" units="function" type="enum" elements="1" options="Disabled,Serial,UAVTalk,Debug" defaultvalue="UAVTalk"/>
<field name="TelemetrySpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200" defaultvalue="57600"/>
<field name="FlexiConfig" units="function" type="enum" elements="1" options="Disabled,Serial,UAVTalk,PPM_In,PPM_Out,RSSI,Debug" defaultvalue="Disabled"/>
<field name="FlexiSpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200" defaultvalue="57600"/>