mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-932 Replaces the RFM22B PPM/receiver code with an OPLinkReceiver UAVObject. This object is generated on a coordinator OPLink, and is used by both the OPLink to generate PPM output, and the OPLinkReceiver on the Revo.
This commit is contained in:
parent
8c370df319
commit
774a74884a
@ -35,7 +35,9 @@
|
||||
#include <oplinkstatus.h>
|
||||
#include <objectpersistence.h>
|
||||
#include <oplinksettings.h>
|
||||
#include <oplinkreceiver.h>
|
||||
#include <uavtalk_priv.h>
|
||||
#include <pios_ppm_out.h>
|
||||
#include <pios_rfm22b.h>
|
||||
#include <ecc.h>
|
||||
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
|
||||
@ -65,6 +67,7 @@ typedef struct {
|
||||
xTaskHandle telemetryRxTaskHandle;
|
||||
xTaskHandle radioTxTaskHandle;
|
||||
xTaskHandle radioRxTaskHandle;
|
||||
xTaskHandle PPMInputTaskHandle;
|
||||
|
||||
// The UAVTalk connection on the com side.
|
||||
UAVTalkConnection telemUAVTalkCon;
|
||||
@ -94,11 +97,13 @@ static void telemetryTxTask(void *parameters);
|
||||
static void telemetryRxTask(void *parameters);
|
||||
static void radioTxTask(void *parameters);
|
||||
static void radioRxTask(void *parameters);
|
||||
static void PPMInputTask(void *parameters);
|
||||
static int32_t UAVTalkSendHandler(uint8_t *buf, int32_t length);
|
||||
static int32_t RadioSendHandler(uint8_t *buf, int32_t length);
|
||||
static void ProcessTelemetryStream(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle, uint8_t rxbyte);
|
||||
static void ProcessRadioStream(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle, uint8_t rxbyte);
|
||||
static void objectPersistenceUpdatedCb(UAVObjEvent *objEv);
|
||||
static void oplinkReceiverUpdatedCb(UAVObjEvent *objEv);
|
||||
|
||||
// ****************
|
||||
// Private variables
|
||||
@ -116,6 +121,7 @@ static int32_t RadioComBridgeStart(void)
|
||||
// Get the settings.
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
OPLinkSettingsGet(&oplinkSettings);
|
||||
bool is_coordinator = (oplinkSettings.Coordinator == OPLINKSETTINGS_COORDINATOR_TRUE);
|
||||
|
||||
// We will not parse/send UAVTalk if any ports are configured as Serial (except for over the USB HID port).
|
||||
data->parseUAVTalk = ((oplinkSettings.MainPort != OPLINKSETTINGS_MAINPORT_SERIAL) &&
|
||||
@ -156,12 +162,29 @@ static int32_t RadioComBridgeStart(void)
|
||||
// Configure our UAVObjects for updates.
|
||||
UAVObjConnectQueue(UAVObjGetByID(OPLINKSTATUS_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
|
||||
UAVObjConnectQueue(UAVObjGetByID(OBJECTPERSISTENCE_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL);
|
||||
if (is_coordinator) {
|
||||
UAVObjConnectQueue(UAVObjGetByID(OPLINKRECEIVER_OBJID), data->radioEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
|
||||
} else {
|
||||
UAVObjConnectQueue(UAVObjGetByID(OPLINKRECEIVER_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
|
||||
}
|
||||
|
||||
// Configure the UAVObject callbacks
|
||||
ObjectPersistenceConnectCallback(&objectPersistenceUpdatedCb);
|
||||
if (!is_coordinator) {
|
||||
OPLinkReceiverConnectCallback(&oplinkReceiverUpdatedCb);
|
||||
}
|
||||
|
||||
// Start the primary tasks for receiving/sending UAVTalk packets from the GCS.
|
||||
xTaskCreate(telemetryTxTask, (signed char *)"telemetryTxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->telemetryTxTaskHandle));
|
||||
xTaskCreate(telemetryRxTask, (signed char *)"telemetryRxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->telemetryRxTaskHandle));
|
||||
xTaskCreate(radioTxTask, (signed char *)"radioTxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioTxTaskHandle));
|
||||
xTaskCreate(radioRxTask, (signed char *)"radioRxTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->radioRxTaskHandle));
|
||||
if (PIOS_PPM_RECEIVER != 0) {
|
||||
xTaskCreate(PPMInputTask, (signed char *)"PPMInputTask", STACK_SIZE_BYTES, NULL, TASK_PRIORITY, &(data->PPMInputTaskHandle));
|
||||
#ifdef PIOS_INCLUDE_WDG
|
||||
PIOS_WDG_RegisterFlag(PIOS_WDG_PPMINPUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Register the watchdog timers.
|
||||
#ifdef PIOS_INCLUDE_WDG
|
||||
@ -192,9 +215,7 @@ static int32_t RadioComBridgeInitialize(void)
|
||||
// Initialize the UAVObjects that we use
|
||||
OPLinkStatusInitialize();
|
||||
ObjectPersistenceInitialize();
|
||||
|
||||
// Configure the UAVObject callbacks
|
||||
ObjectPersistenceConnectCallback(&objectPersistenceUpdatedCb);
|
||||
OPLinkReceiverInitialize();
|
||||
|
||||
// Initialise UAVTalk
|
||||
data->telemUAVTalkCon = UAVTalkInitialize(&UAVTalkSendHandler);
|
||||
@ -204,13 +225,6 @@ static int32_t RadioComBridgeInitialize(void)
|
||||
data->uavtalkEventQueue = xQueueCreate(EVENT_QUEUE_SIZE, sizeof(UAVObjEvent));
|
||||
data->radioEventQueue = xQueueCreate(EVENT_QUEUE_SIZE, sizeof(UAVObjEvent));
|
||||
|
||||
// Configure our UAVObjects for updates.
|
||||
UAVObjConnectQueue(UAVObjGetByID(OPLINKSTATUS_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
|
||||
UAVObjConnectQueue(UAVObjGetByID(OBJECTPERSISTENCE_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL);
|
||||
#if defined(PIOS_INCLUDE_RFM22B_GCSRECEIVER)
|
||||
UAVObjConnectQueue(UAVObjGetByID(GCSRECEIVER_OBJID), data->uavtalkEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ);
|
||||
#endif
|
||||
|
||||
// Initialize the statistics.
|
||||
data->comTxErrors = 0;
|
||||
data->comTxRetries = 0;
|
||||
@ -389,6 +403,42 @@ static void telemetryRxTask(__attribute__((unused)) void *parameters)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads the PPM input device and sends out OPLinkReceiver objects.
|
||||
*
|
||||
* @param[in] parameters The task parameters (unused)
|
||||
*/
|
||||
static void PPMInputTask(__attribute__((unused)) void *parameters)
|
||||
{
|
||||
xSemaphoreHandle sem = PIOS_RCVR_GetSemaphore(PIOS_PPM_RECEIVER, 1);
|
||||
OPLinkReceiverData opl_rcvr;
|
||||
|
||||
// Task loop
|
||||
while (1) {
|
||||
#ifdef PIOS_INCLUDE_WDG
|
||||
PIOS_WDG_UpdateFlag(PIOS_WDG_PPMINPUT);
|
||||
#endif
|
||||
|
||||
// Wait for the receiver semaphore.
|
||||
bool valid_input_detected = false;
|
||||
if (xSemaphoreTake(sem, MAX_PORT_DELAY) == pdTRUE) {
|
||||
// Read the receiver inputs.
|
||||
for (uint8_t i = 0; i < OPLINKRECEIVER_CHANNEL_NUMELEM; ++i) {
|
||||
opl_rcvr.Channel[i] = PIOS_RCVR_Read(PIOS_PPM_RECEIVER, i + 1);
|
||||
if ((opl_rcvr.Channel[i] != PIOS_RCVR_INVALID) && (opl_rcvr.Channel[i] != PIOS_RCVR_TIMEOUT)) {
|
||||
valid_input_detected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the receiver UAVO if we detected valid input.
|
||||
if (valid_input_detected) {
|
||||
OPLinkReceiverSet(&opl_rcvr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transmit data buffer to the com port.
|
||||
*
|
||||
@ -471,8 +521,15 @@ static void ProcessRadioStream(UAVTalkConnection inConnectionHandle, UAVTalkConn
|
||||
} else if (state == UAVTALK_STATE_COMPLETE) {
|
||||
// We only want to unpack certain objects from the remote modem.
|
||||
uint32_t objId = UAVTalkGetPacketObjId(inConnectionHandle);
|
||||
if (objId != OPLINKSTATUS_OBJID) {
|
||||
switch (objId) {
|
||||
case OPLINKSTATUS_OBJID:
|
||||
break;
|
||||
case OPLINKRECEIVER_OBJID:
|
||||
UAVTalkReceiveObject(inConnectionHandle);
|
||||
break;
|
||||
default:
|
||||
UAVTalkRelayPacket(inConnectionHandle, outConnectionHandle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -491,7 +548,7 @@ static void objectPersistenceUpdatedCb(__attribute__((unused)) UAVObjEvent *objE
|
||||
// Is this concerning or setting object?
|
||||
if (obj_per.ObjectID == OPLINKSETTINGS_OBJID) {
|
||||
// Is this a save, load, or delete?
|
||||
bool success = true;
|
||||
bool success = false;
|
||||
switch (obj_per.Operation) {
|
||||
case OBJECTPERSISTENCE_OPERATION_LOAD:
|
||||
{
|
||||
@ -542,3 +599,19 @@ static void objectPersistenceUpdatedCb(__attribute__((unused)) UAVObjEvent *objE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Callback that is called when the OPLinkReceiver UAVObject is changed.
|
||||
* @param[in] objEv The event that precipitated the callback.
|
||||
*/
|
||||
static void oplinkReceiverUpdatedCb(__attribute__((unused)) UAVObjEvent *objEv)
|
||||
{
|
||||
// Get the OPLinkReceiver object.
|
||||
OPLinkReceiverData opl_rcvr;
|
||||
|
||||
OPLinkReceiverGet(&opl_rcvr);
|
||||
|
||||
for (uint8_t i = 0; i < OPLINKRECEIVER_CHANNEL_NUMELEM; ++i) {
|
||||
PIOS_PPM_OUT_Set(PIOS_PPM_OUTPUT, i, opl_rcvr.Channel[i]);
|
||||
}
|
||||
}
|
||||
|
@ -482,22 +482,6 @@ static bool rfm22_isConnected(struct pios_rfm22b_dev *rfm22b_dev)
|
||||
return (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) || (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the modem is configured as a coordinator.
|
||||
*
|
||||
* @param[in] rfm22b_id The RFM22B device index.
|
||||
* @return True if the modem is configured as a coordinator.
|
||||
*/
|
||||
bool PIOS_RFM22B_IsCoordinator(uint32_t rfm22b_id)
|
||||
{
|
||||
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||
|
||||
if (PIOS_RFM22B_Validate(rfm22b_dev)) {
|
||||
return rfm22_isCoordinator(rfm22b_dev);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the modem is not actively sending or receiving a packet.
|
||||
*
|
||||
|
@ -1,130 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_RFM22B_RCVR RFM22B Receiver Input Functions
|
||||
* @brief Code to output the PPM signal from the RFM22B
|
||||
* @{
|
||||
*
|
||||
* @file pios_rfm22b_rcvr.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief Implements a receiver interface to the RFM22B device
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "pios.h"
|
||||
|
||||
#ifdef PIOS_INCLUDE_RFM22B_RCVR
|
||||
|
||||
#include "pios_rfm22b_priv.h"
|
||||
|
||||
#include <gcsreceiver.h>
|
||||
|
||||
/* Provide a RCVR driver */
|
||||
static int32_t PIOS_RFM22B_RCVR_Get(uint32_t rcvr_id, uint8_t channel);
|
||||
static void PIOS_RFM22B_RCVR_Supervisor(uint32_t rcvr_id);
|
||||
|
||||
const struct pios_rcvr_driver pios_rfm22b_rcvr_driver = {
|
||||
.read = PIOS_RFM22B_RCVR_Get,
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the receiver.
|
||||
*
|
||||
* @param[in] rfm22b_dev The receiver ID.
|
||||
* @return < 0 on failure.
|
||||
*/
|
||||
int32_t PIOS_RFM22B_RCVR_Init(uint32_t rcvr_id)
|
||||
{
|
||||
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rcvr_id;
|
||||
|
||||
if (!PIOS_RFM22B_Validate(rfm22b_dev)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
for (uint8_t i = 0; i < PIOS_RFM22B_RCVR_MAX_CHANNELS; ++i) {
|
||||
rfm22b_dev->ppm_channel[i] = PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
rfm22b_dev->ppm_supv_timer = 0;
|
||||
|
||||
// Register the failsafe timer callback.
|
||||
if (!PIOS_RTC_RegisterTickCallback(PIOS_RFM22B_RCVR_Supervisor, rcvr_id)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a channel from the receiver.
|
||||
*
|
||||
* @param[in] rcvr_id The receiver ID.
|
||||
* @return The channel value, or -1 on failure.
|
||||
*/
|
||||
static int32_t PIOS_RFM22B_RCVR_Get(uint32_t rcvr_id, uint8_t channel)
|
||||
{
|
||||
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rcvr_id;
|
||||
|
||||
if (!PIOS_RFM22B_Validate(rfm22b_dev)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (channel >= GCSRECEIVER_CHANNEL_NUMELEM) {
|
||||
/* channel is out of range */
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rfm22b_dev->ppm_channel[channel];
|
||||
}
|
||||
|
||||
/**
|
||||
* The supervisor function that ensures that the data is current.
|
||||
*
|
||||
* @param[in] rcvr_id The receiver ID.
|
||||
*/
|
||||
static void PIOS_RFM22B_RCVR_Supervisor(uint32_t rcvr_id)
|
||||
{
|
||||
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rcvr_id;
|
||||
|
||||
if (!PIOS_RFM22B_Validate(rfm22b_dev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// RTC runs at 625Hz.
|
||||
if (++(rfm22b_dev->ppm_supv_timer) < (PIOS_RFM22B_RCVR_TIMEOUT_MS * 625 / 1000)) {
|
||||
return;
|
||||
}
|
||||
rfm22b_dev->ppm_supv_timer = 0;
|
||||
|
||||
// Have we received fresh values since the last update?
|
||||
if (!rfm22b_dev->ppm_fresh) {
|
||||
for (uint8_t i = 0; i < PIOS_RFM22B_RCVR_MAX_CHANNELS; ++i) {
|
||||
rfm22b_dev->ppm_channel[i] = PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
rfm22b_dev->ppm_fresh = false;
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_RFM22B_RCVR */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -112,7 +112,6 @@ extern void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, uint8_t num_chan, u
|
||||
extern void PIOS_RFM22B_SetCoordinator(uint32_t rfm22b_id, bool coordinator);
|
||||
extern void PIOS_RFM22B_SetCoordinatorID(uint32_t rfm22b_id, uint32_t coord_id);
|
||||
extern uint32_t PIOS_RFM22B_DeviceID(uint32_t rfb22b_id);
|
||||
extern bool PIOS_RFM22B_IsCoordinator(uint32_t rfb22b_id);
|
||||
extern void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats);
|
||||
extern uint8_t PIOS_RFM2B_GetPairStats(uint32_t rfm22b_id, uint32_t *device_ids, int8_t *RSSIs, uint8_t max_pairs);
|
||||
extern bool PIOS_RFM22B_InRxWait(uint32_t rfb22b_id);
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <uavobjectmanager.h>
|
||||
#include <oplinkstatus.h>
|
||||
#include "pios_rfm22b.h"
|
||||
#include "pios_rfm22b_rcvr.h"
|
||||
|
||||
// ************************************
|
||||
|
||||
@ -770,13 +769,6 @@ struct pios_rfm22b_dev {
|
||||
portTickType tx_complete_ticks;
|
||||
portTickType time_delta;
|
||||
bool on_sync_channel;
|
||||
|
||||
#ifdef PIOS_INCLUDE_RFM22B_RCVR
|
||||
// The PPM channel values
|
||||
uint16_t ppm_channel[PIOS_RFM22B_RCVR_MAX_CHANNELS];
|
||||
uint32_t ppm_supv_timer;
|
||||
bool ppm_fresh;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS RFM22B Receiver Input Functions
|
||||
* @{
|
||||
*
|
||||
* @file pios_rfm22b_rcvr.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief RFM22B Receiver Input functions header.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PIOS_RFM22B_RCVR_H
|
||||
|
||||
#define PIOS_RFM22B_RCVR_MAX_CHANNELS 12
|
||||
|
||||
extern const struct pios_rcvr_driver pios_rfm22b_rcvr_driver;
|
||||
|
||||
extern int32_t PIOS_RFM22B_RCVR_Init(uint32_t rcvr_id);
|
||||
|
||||
#define PIOS_RFM22B_RCVR_H
|
||||
|
||||
#endif /* PIOS_RFM22B_RCVR_H */
|
@ -241,10 +241,6 @@
|
||||
#include <pios_sbus.h>
|
||||
#endif
|
||||
|
||||
#ifdef PIOS_INCLUDE_GCSRCVR
|
||||
/* only priv header */
|
||||
#endif
|
||||
|
||||
/* PIOS abstract receiver interface */
|
||||
#ifdef PIOS_INCLUDE_RCVR
|
||||
#include <pios_rcvr.h>
|
||||
|
@ -116,7 +116,6 @@
|
||||
/* PIOS radio modules */
|
||||
/* #define PIOS_INCLUDE_RFM22B */
|
||||
/* #define PIOS_INCLUDE_RFM22B_COM */
|
||||
/* #define PIOS_INCLUDE_RFM22B_RCVR */
|
||||
/* #define PIOS_INCLUDE_PPM_OUT */
|
||||
/* #define PIOS_RFM22B_DEBUG_ON_TELEM */
|
||||
|
||||
|
@ -49,10 +49,10 @@ ifndef TESTAPP
|
||||
SRC += $(OPUAVOBJ)/callbackscheduler.c
|
||||
|
||||
## UAVObjects
|
||||
SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c
|
||||
SRC += $(OPUAVSYNTHDIR)/oplinkstatus.c
|
||||
SRC += $(OPUAVSYNTHDIR)/oplinksettings.c
|
||||
SRC += $(OPUAVSYNTHDIR)/objectpersistence.c
|
||||
SRC += $(OPUAVSYNTHDIR)/oplinkreceiver.c
|
||||
else
|
||||
## Test Code
|
||||
SRC += $(OPTESTS)/test_common.c
|
||||
|
@ -116,9 +116,8 @@
|
||||
/* PIOS radio modules */
|
||||
#define PIOS_INCLUDE_RFM22B
|
||||
#define PIOS_INCLUDE_RFM22B_COM
|
||||
/* #define PIOS_INCLUDE_RFM22B_RCVR */
|
||||
#define PIOS_INCLUDE_PPM_OUT
|
||||
#define PIOS_RFM22B_DEBUG_ON_TELEM
|
||||
/* #define PIOS_RFM22B_DEBUG_ON_TELEM */
|
||||
|
||||
/* PIOS misc peripherals */
|
||||
/* #define PIOS_INCLUDE_VIDEO */
|
||||
|
@ -221,6 +221,7 @@ void PIOS_Board_Init(void)
|
||||
|
||||
/* Initalize the RFM22B radio COM device. */
|
||||
#if defined(PIOS_INCLUDE_RFM22B)
|
||||
bool is_coordinator = (oplinkSettings.Coordinator == OPLINKSETTINGS_COORDINATOR_TRUE);
|
||||
{
|
||||
// Configure the RFM22B device
|
||||
const struct pios_board_info *bdinfo = &pios_board_info_blob;
|
||||
@ -265,10 +266,41 @@ void PIOS_Board_Init(void)
|
||||
}
|
||||
PIOS_COM_ChangeBaud(pios_com_rfm22b_id, comBaud);
|
||||
|
||||
/* Set the modem Tx poer level */
|
||||
switch (oplinkSettings.MaxRFPower) {
|
||||
case OPLINKSETTINGS_MAXRFPOWER_125:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_0);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_16:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_1);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_316:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_2);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_63:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_3);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_126:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_4);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_25:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_5);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_50:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_6);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_100:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_7);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the radio configuration parameters.
|
||||
PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, oplinkSettings.NumChannels, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, oplinkSettings.ChannelSet,
|
||||
oplinkSettings.PacketTime, (oplinkSettings.OneWayLink == OPLINKSETTINGS_ONEWAYLINK_TRUE));
|
||||
PIOS_RFM22B_SetCoordinator(pios_rfm22b_id, (oplinkSettings.Coordinator == OPLINKSETTINGS_COORDINATOR_TRUE));
|
||||
PIOS_RFM22B_SetCoordinator(pios_rfm22b_id, is_coordinator);
|
||||
PIOS_RFM22B_SetCoordinatorID(pios_rfm22b_id, oplinkSettings.CoordID);
|
||||
|
||||
// Reinitilize the modem to affect te changes.
|
||||
@ -281,7 +313,6 @@ void PIOS_Board_Init(void)
|
||||
pios_uart_tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN);
|
||||
|
||||
// Configure the main port
|
||||
bool is_coordinator = PIOS_RFM22B_IsCoordinator(pios_rfm22b_id);
|
||||
switch (oplinkSettings.MainPort) {
|
||||
case OPLINKSETTINGS_MAINPORT_TELEMETRY:
|
||||
case OPLINKSETTINGS_MAINPORT_SERIAL:
|
||||
|
@ -75,7 +75,8 @@
|
||||
#define PIOS_WDG_TELEMETRYRX 0x0002
|
||||
#define PIOS_WDG_RADIOTX 0x0004
|
||||
#define PIOS_WDG_RADIORX 0x0008
|
||||
#define PIOS_WDG_RFM22B 0x0016
|
||||
#define PIOS_WDG_RFM22B 0x000f
|
||||
#define PIOS_WDG_PPMINPUT 0x0010
|
||||
|
||||
// ------------------------
|
||||
// TELEMETRY
|
||||
|
@ -117,7 +117,6 @@
|
||||
/* PIOS radio modules */
|
||||
/* #define PIOS_INCLUDE_RFM22B */
|
||||
/* #define PIOS_INCLUDE_RFM22B_COM */
|
||||
/* #define PIOS_INCLUDE_RFM22B_RCVR */
|
||||
/* #define PIOS_INCLUDE_PPM_OUT */
|
||||
/* #define PIOS_RFM22B_DEBUG_ON_TELEM */
|
||||
|
||||
|
@ -59,6 +59,7 @@ UAVOBJSRCFILENAMES += mixersettings
|
||||
UAVOBJSRCFILENAMES += mixerstatus
|
||||
UAVOBJSRCFILENAMES += nedaccel
|
||||
UAVOBJSRCFILENAMES += objectpersistence
|
||||
UAVOBJSRCFILENAMES += oplinkreceiver
|
||||
UAVOBJSRCFILENAMES += overosyncstats
|
||||
UAVOBJSRCFILENAMES += overosyncsettings
|
||||
UAVOBJSRCFILENAMES += pathaction
|
||||
|
@ -116,7 +116,6 @@
|
||||
/* PIOS radio modules */
|
||||
#define PIOS_INCLUDE_RFM22B
|
||||
#define PIOS_INCLUDE_RFM22B_COM
|
||||
#define PIOS_INCLUDE_RFM22B_RCVR
|
||||
/* #define PIOS_INCLUDE_PPM_OUT */
|
||||
#define PIOS_RFM22B_DEBUG_ON_TELEM
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <manualcontrolsettings.h>
|
||||
#include <oplinksettings.h>
|
||||
#include <oplinkstatus.h>
|
||||
#include <oplinkreceiver.h>
|
||||
#include <pios_oplinkrcvr_priv.h>
|
||||
#include <taskinfo.h>
|
||||
|
||||
/*
|
||||
@ -787,16 +789,6 @@ void PIOS_Board_Init(void)
|
||||
/* Reinitialize the modem. */
|
||||
PIOS_RFM22B_Reinit(pios_rfm22b_id);
|
||||
|
||||
#ifdef PIOS_INCLUDE_RFM22B_RCVR
|
||||
if (PIOS_RFM22B_RCVR_Init(pios_rfm22b_id) != 0) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
uint32_t pios_rfm22b_rcvr_id;
|
||||
if (PIOS_RCVR_Init(&pios_rfm22b_rcvr_id, &pios_rfm22b_rcvr_driver, pios_rfm22b_id)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_OPLINK] = pios_rfm22b_rcvr_id;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -858,6 +850,19 @@ void PIOS_Board_Init(void)
|
||||
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id;
|
||||
#endif /* PIOS_INCLUDE_GCSRCVR */
|
||||
|
||||
#if defined(PIOS_INCLUDE_OPLINKRCVR)
|
||||
{
|
||||
OPLinkReceiverInitialize();
|
||||
uint32_t pios_oplinkrcvr_id;
|
||||
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id);
|
||||
uint32_t pios_oplinkrcvr_rcvr_id;
|
||||
if (PIOS_RCVR_Init(&pios_oplinkrcvr_rcvr_id, &pios_oplinkrcvr_rcvr_driver, pios_oplinkrcvr_id)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_OPLINK] = pios_oplinkrcvr_rcvr_id;
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_OPLINKRCVR */
|
||||
|
||||
#ifndef PIOS_ENABLE_DEBUG_PINS
|
||||
// pios_servo_cfg points to the correct configuration based on input port settings
|
||||
PIOS_Servo_Init(pios_servo_cfg);
|
||||
|
@ -116,7 +116,6 @@
|
||||
/* PIOS radio modules */
|
||||
/* #define PIOS_INCLUDE_RFM22B */
|
||||
/* #define PIOS_INCLUDE_RFM22B_COM */
|
||||
/* #define PIOS_INCLUDE_RFM22B_RCVR */
|
||||
/* #define PIOS_INCLUDE_PPM_OUT */
|
||||
/* #define PIOS_RFM22B_DEBUG_ON_TELEM */
|
||||
|
||||
|
@ -84,7 +84,6 @@ SRC += $(PIOSCOMMON)/pios_flash_jedec.c
|
||||
SRC += $(PIOSCOMMON)/pios_rcvr.c
|
||||
SRC += $(PIOSCOMMON)/pios_rfm22b.c
|
||||
SRC += $(PIOSCOMMON)/pios_rfm22b_com.c
|
||||
SRC += $(PIOSCOMMON)/pios_rfm22b_rcvr.c
|
||||
SRC += $(PIOSCOMMON)/pios_sbus.c
|
||||
SRC += $(PIOSCOMMON)/pios_sdcard.c
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
<field name="MaxChannel" units="" type="uint8" elements="1" defaultvalue="250"/>
|
||||
<field name="NumChannels" units="" type="uint8" elements="1" defaultvalue="10"/>
|
||||
<field name="ChannelSet" units="" type="uint8" elements="1" defaultvalue="39"/>
|
||||
<field name="PacketTime" units="ms" type="uint8" elements="1" defaultvalue="39"/>
|
||||
<field name="PacketTime" units="ms" type="uint8" elements="1" defaultvalue="15"/>
|
||||
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user