mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
Merge branch 'next' of ssh://git.openpilot.org/OpenPilot into abeck/OP-1863-rate-maxpitch
This commit is contained in:
commit
b4d727db98
@ -317,6 +317,7 @@ static bool okToArm(void)
|
||||
return false;
|
||||
|
||||
case FLIGHTSTATUS_FLIGHTMODE_AUTOTAKEOFF:
|
||||
case FLIGHTSTATUS_FLIGHTMODE_PATHPLANNER:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -101,33 +101,12 @@ void VtolAutoTakeoffController::ObjectiveUpdated(void)
|
||||
{
|
||||
// Set the objective's target velocity
|
||||
|
||||
if (flightStatus->ControlChain.PathPlanner != FLIGHTSTATUS_CONTROLCHAIN_TRUE) {
|
||||
controlDown.UpdateVelocitySetpoint(pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_DOWN]);
|
||||
controlNE.UpdateVelocitySetpoint(pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_NORTH],
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_EAST]);
|
||||
controlNE.UpdatePositionSetpoint(pathDesired->End.North, pathDesired->End.East);
|
||||
controlDown.UpdatePositionSetpoint(pathDesired->End.Down);
|
||||
fsm->setControlState((StatusVtolAutoTakeoffControlStateOptions)pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_CONTROLSTATE]);
|
||||
} else {
|
||||
float velocity_down;
|
||||
FlightModeSettingsAutoTakeOffVelocityGet(&velocity_down);
|
||||
controlDown.UpdateVelocitySetpoint(-velocity_down);
|
||||
controlNE.UpdateVelocitySetpoint(0.0f, 0.0f);
|
||||
// pathplanner mode the waypoint provides the final destination including altitude. Takeoff would
|
||||
// often be waypoint 0, in which case the starting location is the current location, and the end location
|
||||
// is the waypoint location which really needs to be the same as the end in north and east. If it is not,
|
||||
// it will fly to that location the during ascent.
|
||||
// Note in pathplanner mode we use the start location which is the current initial location as the
|
||||
// target NE to control. Takeoff only ascends vertically.
|
||||
controlNE.UpdatePositionSetpoint(pathDesired->Start.North, pathDesired->Start.East);
|
||||
// Sanity check that the end location is at least a reasonable height above the start location in the down direction
|
||||
float autotakeoff_height = pathDesired->Start.Down - pathDesired->End.Down;
|
||||
if (autotakeoff_height < 2.0f) {
|
||||
pathDesired->End.Down = pathDesired->Start.Down - 2.0f;
|
||||
}
|
||||
controlDown.UpdatePositionSetpoint(pathDesired->End.Down); // the altitude is set by the end location.
|
||||
fsm->setControlState(STATUSVTOLAUTOTAKEOFF_CONTROLSTATE_INITIATE);
|
||||
}
|
||||
controlDown.UpdateVelocitySetpoint(pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_DOWN]);
|
||||
controlNE.UpdateVelocitySetpoint(pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_NORTH],
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_EAST]);
|
||||
controlNE.UpdatePositionSetpoint(pathDesired->End.North, pathDesired->End.East);
|
||||
controlDown.UpdatePositionSetpoint(pathDesired->End.Down);
|
||||
fsm->setControlState((StatusVtolAutoTakeoffControlStateOptions)pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_CONTROLSTATE]);
|
||||
}
|
||||
void VtolAutoTakeoffController::Deactivate(void)
|
||||
{
|
||||
|
@ -48,6 +48,9 @@
|
||||
#include "plans.h"
|
||||
#include <sanitycheck.h>
|
||||
#include <vtolpathfollowersettings.h>
|
||||
#include <statusvtolautotakeoff.h>
|
||||
#include <statusvtolland.h>
|
||||
#include <manualcontrolcommand.h>
|
||||
|
||||
// Private constants
|
||||
#define STACK_SIZE_BYTES 1024
|
||||
@ -77,6 +80,9 @@ static uint8_t conditionPointingTowardsNext();
|
||||
static uint8_t conditionPythonScript();
|
||||
static uint8_t conditionImmediate();
|
||||
static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev);
|
||||
static void planner_setup_pathdesired_land(PathDesiredData *pathDesired);
|
||||
static void planner_setup_pathdesired_takeoff(PathDesiredData *pathDesired);
|
||||
static void planner_setup_pathdesired(PathDesiredData *pathDesired);
|
||||
|
||||
|
||||
// Private variables
|
||||
@ -126,6 +132,8 @@ int32_t PathPlannerInitialize()
|
||||
VelocityStateInitialize();
|
||||
WaypointInitialize();
|
||||
WaypointActiveInitialize();
|
||||
StatusVtolAutoTakeoffInitialize();
|
||||
StatusVtolLandInitialize();
|
||||
|
||||
pathPlannerHandle = PIOS_CALLBACKSCHEDULER_Create(&pathPlannerTask, CALLBACK_PRIORITY_REGULAR, TASK_PRIORITY, CALLBACKINFO_RUNNING_PATHPLANNER0, STACK_SIZE_BYTES);
|
||||
pathDesiredUpdaterHandle = PIOS_CALLBACKSCHEDULER_Create(&updatePathDesired, CALLBACK_PRIORITY_CRITICAL, TASK_PRIORITY, CALLBACKINFO_RUNNING_PATHPLANNER1, STACK_SIZE_BYTES);
|
||||
@ -167,6 +175,7 @@ static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
||||
}
|
||||
}
|
||||
|
||||
#define AUTOTAKEOFF_THROTTLE_LIMIT_TO_ALLOW_TAKEOFF_START 0.3f
|
||||
|
||||
/**
|
||||
* Module task
|
||||
@ -219,6 +228,17 @@ static void pathPlannerTask()
|
||||
|
||||
WaypointActiveGet(&waypointActive);
|
||||
|
||||
// with the introduction of takeoff, we allow for arming
|
||||
// whilst in pathplanner mode. Previously it was just an assumption that
|
||||
// a user never armed in pathplanner mode. This check allows a user to select
|
||||
// pathplanner, to upload waypoints, and then arm in pathplanner.
|
||||
if (!flightStatus.Armed) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// the transition from pathplanner to another flightmode back to pathplanner
|
||||
// triggers a reset back to 0 index in the waypoint list
|
||||
if (pathplanner_active == false) {
|
||||
pathplanner_active = true;
|
||||
|
||||
@ -245,6 +265,22 @@ static void pathPlannerTask()
|
||||
return;
|
||||
}
|
||||
|
||||
// check start conditions
|
||||
// autotakeoff requires midpoint thrust if we are in a pending takeoff situation
|
||||
if (pathAction.Mode == PATHACTION_MODE_AUTOTAKEOFF) {
|
||||
pathAction.EndCondition = PATHACTION_ENDCONDITION_LEGREMAINING;
|
||||
if ((uint8_t)pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_CONTROLSTATE] == STATUSVTOLAUTOTAKEOFF_CONTROLSTATE_WAITFORMIDTHROTTLE) {
|
||||
ManualControlCommandData cmd;
|
||||
ManualControlCommandGet(&cmd);
|
||||
if (cmd.Throttle > AUTOTAKEOFF_THROTTLE_LIMIT_TO_ALLOW_TAKEOFF_START) {
|
||||
pathDesired.ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_CONTROLSTATE] = (float)STATUSVTOLAUTOTAKEOFF_CONTROLSTATE_INITIATE;
|
||||
PathDesiredSet(&pathDesired);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check if condition has been met
|
||||
endCondition = pathConditionCheck();
|
||||
// decide what to do
|
||||
@ -283,6 +319,38 @@ static void pathPlannerTask()
|
||||
}
|
||||
}
|
||||
|
||||
// callback function when waypoints changed in any way, update pathDesired
|
||||
void updatePathDesired()
|
||||
{
|
||||
// only ever touch pathDesired if pathplanner is enabled
|
||||
if (!pathplanner_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
PathDesiredData pathDesired;
|
||||
|
||||
// find out current waypoint
|
||||
WaypointActiveGet(&waypointActive);
|
||||
|
||||
WaypointInstGet(waypointActive.Index, &waypoint);
|
||||
PathActionInstGet(waypoint.Action, &pathAction);
|
||||
|
||||
switch (pathAction.Mode) {
|
||||
case PATHACTION_MODE_AUTOTAKEOFF:
|
||||
planner_setup_pathdesired_takeoff(&pathDesired);
|
||||
break;
|
||||
case PATHACTION_MODE_LAND:
|
||||
planner_setup_pathdesired_land(&pathDesired);
|
||||
break;
|
||||
default:
|
||||
planner_setup_pathdesired(&pathDesired);
|
||||
break;
|
||||
}
|
||||
|
||||
PathDesiredSet(&pathDesired);
|
||||
}
|
||||
|
||||
|
||||
// safety checks for path plan integrity
|
||||
static uint8_t checkPathPlan()
|
||||
{
|
||||
@ -367,33 +435,20 @@ void statusUpdated(__attribute__((unused)) UAVObjEvent *ev)
|
||||
PIOS_CALLBACKSCHEDULER_Dispatch(pathPlannerHandle);
|
||||
}
|
||||
|
||||
|
||||
// callback function when waypoints changed in any way, update pathDesired
|
||||
void updatePathDesired()
|
||||
// Standard setup of a pathDesired command from the waypoint path plan
|
||||
static void planner_setup_pathdesired(PathDesiredData *pathDesired)
|
||||
{
|
||||
// only ever touch pathDesired if pathplanner is enabled
|
||||
if (!pathplanner_active) {
|
||||
return;
|
||||
}
|
||||
pathDesired->End.North = waypoint.Position.North;
|
||||
pathDesired->End.East = waypoint.Position.East;
|
||||
pathDesired->End.Down = waypoint.Position.Down;
|
||||
pathDesired->EndingVelocity = waypoint.Velocity;
|
||||
pathDesired->Mode = pathAction.Mode;
|
||||
pathDesired->ModeParameters[0] = pathAction.ModeParameters[0];
|
||||
pathDesired->ModeParameters[1] = pathAction.ModeParameters[1];
|
||||
pathDesired->ModeParameters[2] = pathAction.ModeParameters[2];
|
||||
pathDesired->ModeParameters[3] = pathAction.ModeParameters[3];
|
||||
pathDesired->UID = waypointActive.Index;
|
||||
|
||||
PathDesiredData pathDesired;
|
||||
|
||||
// find out current waypoint
|
||||
WaypointActiveGet(&waypointActive);
|
||||
|
||||
WaypointInstGet(waypointActive.Index, &waypoint);
|
||||
PathActionInstGet(waypoint.Action, &pathAction);
|
||||
|
||||
pathDesired.End.North = waypoint.Position.North;
|
||||
pathDesired.End.East = waypoint.Position.East;
|
||||
pathDesired.End.Down = waypoint.Position.Down;
|
||||
pathDesired.EndingVelocity = waypoint.Velocity;
|
||||
pathDesired.Mode = pathAction.Mode;
|
||||
pathDesired.ModeParameters[0] = pathAction.ModeParameters[0];
|
||||
pathDesired.ModeParameters[1] = pathAction.ModeParameters[1];
|
||||
pathDesired.ModeParameters[2] = pathAction.ModeParameters[2];
|
||||
pathDesired.ModeParameters[3] = pathAction.ModeParameters[3];
|
||||
pathDesired.UID = waypointActive.Index;
|
||||
|
||||
if (waypointActive.Index == 0) {
|
||||
PositionStateData positionState;
|
||||
@ -405,23 +460,88 @@ void updatePathDesired()
|
||||
pathDesired.Start[PATHDESIRED_START_DOWN] = waypoint.Position[WAYPOINT_POSITION_DOWN];*/
|
||||
// note takeoff relies on the start being the current location as it merely ascends and using
|
||||
// the start as assumption current NE location
|
||||
pathDesired.Start.North = positionState.North;
|
||||
pathDesired.Start.East = positionState.East;
|
||||
pathDesired.Start.Down = positionState.Down;
|
||||
pathDesired.StartingVelocity = pathDesired.EndingVelocity;
|
||||
pathDesired->Start.North = positionState.North;
|
||||
pathDesired->Start.East = positionState.East;
|
||||
pathDesired->Start.Down = positionState.Down;
|
||||
pathDesired->StartingVelocity = pathDesired->EndingVelocity;
|
||||
} else {
|
||||
// Get previous waypoint as start point
|
||||
WaypointData waypointPrev;
|
||||
WaypointInstGet(waypointActive.Index - 1, &waypointPrev);
|
||||
|
||||
pathDesired.Start.North = waypointPrev.Position.North;
|
||||
pathDesired.Start.East = waypointPrev.Position.East;
|
||||
pathDesired.Start.Down = waypointPrev.Position.Down;
|
||||
pathDesired.StartingVelocity = waypointPrev.Velocity;
|
||||
pathDesired->Start.North = waypointPrev.Position.North;
|
||||
pathDesired->Start.East = waypointPrev.Position.East;
|
||||
pathDesired->Start.Down = waypointPrev.Position.Down;
|
||||
pathDesired->StartingVelocity = waypointPrev.Velocity;
|
||||
}
|
||||
PathDesiredSet(&pathDesired);
|
||||
}
|
||||
|
||||
#define AUTOTAKEOFF_TO_INCREMENTAL_HEIGHT_MIN 2.0f
|
||||
#define AUTOTAKEOFF_TO_INCREMENTAL_HEIGHT_MAX 50.0f
|
||||
static void planner_setup_pathdesired_takeoff(PathDesiredData *pathDesired)
|
||||
{
|
||||
PositionStateData positionState;
|
||||
|
||||
PositionStateGet(&positionState);
|
||||
float velocity_down;
|
||||
float autotakeoff_height;
|
||||
FlightModeSettingsAutoTakeOffVelocityGet(&velocity_down);
|
||||
FlightModeSettingsAutoTakeOffHeightGet(&autotakeoff_height);
|
||||
autotakeoff_height = fabsf(autotakeoff_height);
|
||||
if (autotakeoff_height < AUTOTAKEOFF_TO_INCREMENTAL_HEIGHT_MIN) {
|
||||
autotakeoff_height = AUTOTAKEOFF_TO_INCREMENTAL_HEIGHT_MIN;
|
||||
} else if (autotakeoff_height > AUTOTAKEOFF_TO_INCREMENTAL_HEIGHT_MAX) {
|
||||
autotakeoff_height = AUTOTAKEOFF_TO_INCREMENTAL_HEIGHT_MAX;
|
||||
}
|
||||
|
||||
|
||||
pathDesired->Start.North = positionState.North;
|
||||
pathDesired->Start.East = positionState.East;
|
||||
pathDesired->Start.Down = positionState.Down;
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_NORTH] = 0.0f;
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_EAST] = 0.0f;
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_DOWN] = -velocity_down;
|
||||
// initially halt takeoff.
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_AUTOTAKEOFF_CONTROLSTATE] = (float)STATUSVTOLAUTOTAKEOFF_CONTROLSTATE_WAITFORMIDTHROTTLE;
|
||||
|
||||
pathDesired->End.North = positionState.North;
|
||||
pathDesired->End.East = positionState.East;
|
||||
pathDesired->End.Down = positionState.Down - autotakeoff_height;
|
||||
|
||||
pathDesired->StartingVelocity = 0.0f;
|
||||
pathDesired->EndingVelocity = 0.0f;
|
||||
pathDesired->Mode = PATHDESIRED_MODE_AUTOTAKEOFF;
|
||||
|
||||
pathDesired->UID = waypointActive.Index;
|
||||
}
|
||||
|
||||
static void planner_setup_pathdesired_land(PathDesiredData *pathDesired)
|
||||
{
|
||||
PositionStateData positionState;
|
||||
|
||||
PositionStateGet(&positionState);
|
||||
float velocity_down;
|
||||
|
||||
FlightModeSettingsLandingVelocityGet(&velocity_down);
|
||||
|
||||
pathDesired->Start.North = positionState.North;
|
||||
pathDesired->Start.East = positionState.East;
|
||||
pathDesired->Start.Down = positionState.Down;
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_LAND_VELOCITYVECTOR_NORTH] = 0.0f;
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_LAND_VELOCITYVECTOR_EAST] = 0.0f;
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_LAND_VELOCITYVECTOR_DOWN] = velocity_down;
|
||||
|
||||
pathDesired->End.North = positionState.North;
|
||||
pathDesired->End.East = positionState.East;
|
||||
pathDesired->End.Down = positionState.Down;
|
||||
|
||||
pathDesired->StartingVelocity = 0.0f;
|
||||
pathDesired->EndingVelocity = 0.0f;
|
||||
pathDesired->Mode = PATHDESIRED_MODE_LAND;
|
||||
pathDesired->ModeParameters[PATHDESIRED_MODEPARAMETER_LAND_OPTIONS] = (float)PATHDESIRED_MODEPARAMETER_LAND_OPTION_HORIZONTAL_PH;
|
||||
}
|
||||
|
||||
|
||||
// helper function to go to a specific waypoint
|
||||
static void setWaypoint(uint16_t num)
|
||||
{
|
||||
|
@ -612,6 +612,9 @@ static bool updateRcvrActivityCompare(uint32_t rcvr_id, struct rcvr_activity_fsm
|
||||
case MANUALCONTROLSETTINGS_CHANNELGROUPS_SBUS:
|
||||
group = RECEIVERACTIVITY_ACTIVEGROUP_SBUS;
|
||||
break;
|
||||
case MANUALCONTROLSETTINGS_CHANNELGROUPS_SRXL:
|
||||
group = RECEIVERACTIVITY_ACTIVEGROUP_SRXL;
|
||||
break;
|
||||
case MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS:
|
||||
group = RECEIVERACTIVITY_ACTIVEGROUP_GCS;
|
||||
break;
|
||||
|
365
flight/pios/common/pios_srxl.c
Normal file
365
flight/pios/common/pios_srxl.c
Normal file
@ -0,0 +1,365 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_SRXL Multiplex SRXL receiver functions
|
||||
* @brief Code to read Multiplex SRXL receiver serial stream
|
||||
* @{
|
||||
*
|
||||
* @file pios_srxl.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
|
||||
* @brief Code to read Multiplex SRXL receiver serial stream
|
||||
* @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_SRXL
|
||||
|
||||
#include "pios_srxl_priv.h"
|
||||
|
||||
// #define PIOS_INSTRUMENT_MODULE
|
||||
#include <pios_instrumentation_helper.h>
|
||||
|
||||
PERF_DEFINE_COUNTER(crcFailureCount);
|
||||
PERF_DEFINE_COUNTER(failsafeCount);
|
||||
PERF_DEFINE_COUNTER(successfulCount);
|
||||
PERF_DEFINE_COUNTER(messageUnrollTimer);
|
||||
PERF_DEFINE_COUNTER(messageReceiveRate);
|
||||
PERF_DEFINE_COUNTER(receivedBytesCount);
|
||||
PERF_DEFINE_COUNTER(frameStartCount);
|
||||
PERF_DEFINE_COUNTER(frameAbortCount);
|
||||
PERF_DEFINE_COUNTER(completeMessageCount);
|
||||
|
||||
/* Forward Declarations */
|
||||
static int32_t PIOS_SRXL_Get(uint32_t rcvr_id, uint8_t channel);
|
||||
static uint16_t PIOS_SRXL_RxInCallback(uint32_t context,
|
||||
uint8_t *buf,
|
||||
uint16_t buf_len,
|
||||
uint16_t *headroom,
|
||||
bool *need_yield);
|
||||
static void PIOS_SRXL_Supervisor(uint32_t srxl_id);
|
||||
|
||||
|
||||
/* Local Variables */
|
||||
const struct pios_rcvr_driver pios_srxl_rcvr_driver = {
|
||||
.read = PIOS_SRXL_Get,
|
||||
};
|
||||
|
||||
enum pios_srxl_dev_magic {
|
||||
PIOS_SRXL_DEV_MAGIC = 0x55545970,
|
||||
};
|
||||
|
||||
struct pios_srxl_state {
|
||||
uint16_t channel_data[PIOS_SRXL_NUM_INPUTS];
|
||||
uint8_t received_data[SRXL_FRAME_LENGTH];
|
||||
uint8_t receive_timer;
|
||||
uint8_t failsafe_timer;
|
||||
uint8_t frame_found;
|
||||
uint8_t byte_count;
|
||||
uint8_t data_bytes;
|
||||
};
|
||||
|
||||
struct pios_srxl_dev {
|
||||
enum pios_srxl_dev_magic magic;
|
||||
struct pios_srxl_state state;
|
||||
};
|
||||
|
||||
/* Allocate S.Bus device descriptor */
|
||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||
static struct pios_srxl_dev *PIOS_SRXL_Alloc(void)
|
||||
{
|
||||
struct pios_srxl_dev *srxl_dev;
|
||||
|
||||
srxl_dev = (struct pios_srxl_dev *)pios_malloc(sizeof(*srxl_dev));
|
||||
if (!srxl_dev) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srxl_dev->magic = PIOS_SRXL_DEV_MAGIC;
|
||||
return srxl_dev;
|
||||
}
|
||||
#else
|
||||
static struct pios_srxl_dev pios_srxl_devs[PIOS_SRXL_MAX_DEVS];
|
||||
static uint8_t pios_srxl_num_devs;
|
||||
static struct pios_srxl_dev *PIOS_SRXL_Alloc(void)
|
||||
{
|
||||
struct pios_srxl_dev *srxl_dev;
|
||||
|
||||
if (pios_srxl_num_devs >= PIOS_SRXL_MAX_DEVS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srxl_dev = &pios_srxl_devs[pios_srxl_num_devs++];
|
||||
srxl_dev->magic = PIOS_SRXL_DEV_MAGIC;
|
||||
|
||||
return srxl_dev;
|
||||
}
|
||||
#endif /* if defined(PIOS_INCLUDE_FREERTOS) */
|
||||
|
||||
/* Validate SRXL device descriptor */
|
||||
static bool PIOS_SRXL_Validate(struct pios_srxl_dev *srxl_dev)
|
||||
{
|
||||
return srxl_dev->magic == PIOS_SRXL_DEV_MAGIC;
|
||||
}
|
||||
|
||||
/* Reset channels in case of lost signal or explicit failsafe receiver flag */
|
||||
static void PIOS_SRXL_ResetChannels(struct pios_srxl_state *state)
|
||||
{
|
||||
for (int i = 0; i < PIOS_SRXL_NUM_INPUTS; i++) {
|
||||
state->channel_data[i] = PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset SRXL receiver state */
|
||||
static void PIOS_SRXL_ResetState(struct pios_srxl_state *state)
|
||||
{
|
||||
state->receive_timer = 0;
|
||||
state->failsafe_timer = 0;
|
||||
state->frame_found = 0;
|
||||
state->data_bytes = 0;
|
||||
PIOS_SRXL_ResetChannels(state);
|
||||
}
|
||||
|
||||
/* Initialize SRXL receiver interface */
|
||||
int32_t PIOS_SRXL_Init(uint32_t *srxl_id,
|
||||
const struct pios_com_driver *driver,
|
||||
uint32_t lower_id)
|
||||
{
|
||||
PIOS_DEBUG_Assert(srxl_id);
|
||||
PIOS_DEBUG_Assert(driver);
|
||||
|
||||
struct pios_srxl_dev *srxl_dev;
|
||||
|
||||
srxl_dev = (struct pios_srxl_dev *)PIOS_SRXL_Alloc();
|
||||
if (!srxl_dev) {
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
PIOS_SRXL_ResetState(&(srxl_dev->state));
|
||||
|
||||
*srxl_id = (uint32_t)srxl_dev;
|
||||
|
||||
/* Set comm driver callback */
|
||||
(driver->bind_rx_cb)(lower_id, PIOS_SRXL_RxInCallback, *srxl_id);
|
||||
|
||||
if (!PIOS_RTC_RegisterTickCallback(PIOS_SRXL_Supervisor, *srxl_id)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
|
||||
PERF_INIT_COUNTER(crcFailureCount, 0x5551);
|
||||
PERF_INIT_COUNTER(failsafeCount, 0x5552);
|
||||
PERF_INIT_COUNTER(successfulCount, 0x5553);
|
||||
PERF_INIT_COUNTER(messageUnrollTimer, 0x5554);
|
||||
PERF_INIT_COUNTER(messageReceiveRate, 0x5555);
|
||||
PERF_INIT_COUNTER(receivedBytesCount, 0x5556);
|
||||
PERF_INIT_COUNTER(frameStartCount, 0x5557);
|
||||
PERF_INIT_COUNTER(frameAbortCount, 0x5558);
|
||||
PERF_INIT_COUNTER(completeMessageCount, 0x5559);
|
||||
|
||||
return 0;
|
||||
|
||||
out_fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of an input channel
|
||||
* \param[in] channel Number of the channel desired (zero based)
|
||||
* \output PIOS_RCVR_INVALID channel not available
|
||||
* \output PIOS_RCVR_TIMEOUT failsafe condition or missing receiver
|
||||
* \output >=0 channel value
|
||||
*/
|
||||
static int32_t PIOS_SRXL_Get(uint32_t rcvr_id, uint8_t channel)
|
||||
{
|
||||
struct pios_srxl_dev *srxl_dev = (struct pios_srxl_dev *)rcvr_id;
|
||||
|
||||
if (!PIOS_SRXL_Validate(srxl_dev)) {
|
||||
return PIOS_RCVR_INVALID;
|
||||
}
|
||||
|
||||
/* return error if channel is not available */
|
||||
if (channel >= PIOS_SRXL_NUM_INPUTS) {
|
||||
return PIOS_RCVR_INVALID;
|
||||
}
|
||||
|
||||
return srxl_dev->state.channel_data[channel];
|
||||
}
|
||||
|
||||
static void PIOS_SRXL_UnrollChannels(struct pios_srxl_state *state)
|
||||
{
|
||||
PERF_TIMED_SECTION_START(messageUnrollTimer);
|
||||
uint8_t *received_data = state->received_data;
|
||||
uint8_t channel;
|
||||
uint16_t channel_value;
|
||||
for (channel = 0; channel < (state->data_bytes / 2); channel++) {
|
||||
channel_value = ((uint16_t)received_data[SRXL_HEADER_LENGTH + (channel * 2)]) << 8;
|
||||
channel_value = channel_value + ((uint16_t)received_data[SRXL_HEADER_LENGTH + (channel * 2) + 1]);
|
||||
state->channel_data[channel] = (800 + ((channel_value * 1400) >> 12));
|
||||
}
|
||||
PERF_TIMED_SECTION_END(messageUnrollTimer);
|
||||
}
|
||||
|
||||
static bool PIOS_SRXL_Validate_Checksum(struct pios_srxl_state *state)
|
||||
{
|
||||
// Check the CRC16 checksum. The provided checksum is immediately after the channel data.
|
||||
// All data including start byte and version byte is included in crc calculation.
|
||||
uint8_t i = 0;
|
||||
uint16_t crc = 0;
|
||||
|
||||
for (i = 0; i < SRXL_HEADER_LENGTH + state->data_bytes; i++) {
|
||||
crc = crc ^ (int16_t)state->received_data[i] << 8;
|
||||
uint8_t j = 0;
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (crc & 0x8000) {
|
||||
crc = crc << 1 ^ 0x1021;
|
||||
} else {
|
||||
crc = crc << 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint16_t checksum = (((uint16_t)(state->received_data[i] << 8) |
|
||||
(uint16_t)state->received_data[i + 1]));
|
||||
return crc == checksum;
|
||||
}
|
||||
|
||||
/* Update decoder state processing input byte from the SRXL stream */
|
||||
static void PIOS_SRXL_UpdateState(struct pios_srxl_state *state, uint8_t b)
|
||||
{
|
||||
/* should not process any data until new frame is found */
|
||||
if (!state->frame_found) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state->byte_count < (SRXL_HEADER_LENGTH + state->data_bytes + SRXL_CHECKSUM_LENGTH)) {
|
||||
if (state->byte_count == 0) {
|
||||
// Set up the length of the channel data according to version received
|
||||
PERF_INCREMENT_VALUE(frameStartCount);
|
||||
if (b == SRXL_V1_HEADER) {
|
||||
state->data_bytes = SRXL_V1_CHANNEL_DATA_BYTES;
|
||||
} else if (b == SRXL_V2_HEADER) {
|
||||
state->data_bytes = SRXL_V2_CHANNEL_DATA_BYTES;
|
||||
} else {
|
||||
/* discard the whole frame if the 1st byte is not correct */
|
||||
state->frame_found = 0;
|
||||
PERF_INCREMENT_VALUE(frameAbortCount);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* store next byte */
|
||||
state->received_data[state->byte_count] = b;
|
||||
state->byte_count++;
|
||||
if (state->byte_count == (SRXL_HEADER_LENGTH + state->data_bytes + SRXL_CHECKSUM_LENGTH)) {
|
||||
PERF_INCREMENT_VALUE(completeMessageCount);
|
||||
// We have a complete message, lets decode it
|
||||
if (PIOS_SRXL_Validate_Checksum(state)) {
|
||||
/* data looking good */
|
||||
PIOS_SRXL_UnrollChannels(state);
|
||||
state->failsafe_timer = 0;
|
||||
PERF_INCREMENT_VALUE(successfulCount);
|
||||
} else {
|
||||
/* discard whole frame */
|
||||
PERF_INCREMENT_VALUE(crcFailureCount);
|
||||
}
|
||||
/* prepare for the next frame */
|
||||
state->frame_found = 0;
|
||||
PERF_MEASURE_PERIOD(messageReceiveRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comm byte received callback */
|
||||
static uint16_t PIOS_SRXL_RxInCallback(uint32_t context,
|
||||
uint8_t *buf,
|
||||
uint16_t buf_len,
|
||||
uint16_t *headroom,
|
||||
bool *need_yield)
|
||||
{
|
||||
struct pios_srxl_dev *srxl_dev = (struct pios_srxl_dev *)context;
|
||||
|
||||
bool valid = PIOS_SRXL_Validate(srxl_dev);
|
||||
|
||||
PIOS_Assert(valid);
|
||||
|
||||
struct pios_srxl_state *state = &(srxl_dev->state);
|
||||
|
||||
/* process byte(s) and clear receive timer */
|
||||
for (uint8_t i = 0; i < buf_len; i++) {
|
||||
PIOS_SRXL_UpdateState(state, buf[i]);
|
||||
state->receive_timer = 0;
|
||||
PERF_INCREMENT_VALUE(receivedBytesCount);
|
||||
}
|
||||
|
||||
/* Always signal that we can accept another byte */
|
||||
if (headroom) {
|
||||
*headroom = SRXL_FRAME_LENGTH;
|
||||
}
|
||||
|
||||
/* We never need a yield */
|
||||
*need_yield = false;
|
||||
|
||||
/* Always indicate that all bytes were consumed */
|
||||
return buf_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input data supervisor is called periodically and provides
|
||||
* two functions: frame syncing and failsafe triggering.
|
||||
*
|
||||
* Multiplex SRXL frames come at 14ms (FastResponse ON) or 21ms (FastResponse OFF)
|
||||
* rate at 115200bps.
|
||||
* RTC timer is running at 625Hz (1.6ms). So with divider 2 it gives
|
||||
* 3.2ms pause between frames which is good for both SRXL frame rates.
|
||||
*
|
||||
* Data receive function must clear the receive_timer to confirm new
|
||||
* data reception. If no new data received in 100ms, we must call the
|
||||
* failsafe function which clears all channels.
|
||||
*/
|
||||
static void PIOS_SRXL_Supervisor(uint32_t srxl_id)
|
||||
{
|
||||
struct pios_srxl_dev *srxl_dev = (struct pios_srxl_dev *)srxl_id;
|
||||
|
||||
bool valid = PIOS_SRXL_Validate(srxl_dev);
|
||||
|
||||
PIOS_Assert(valid);
|
||||
|
||||
struct pios_srxl_state *state = &(srxl_dev->state);
|
||||
|
||||
/* waiting for new frame if no bytes were received in 6.4ms */
|
||||
|
||||
if (++state->receive_timer > 4) {
|
||||
state->frame_found = 1;
|
||||
state->byte_count = 0;
|
||||
state->receive_timer = 0;
|
||||
}
|
||||
|
||||
/* activate failsafe if no frames have arrived in 102.4ms */
|
||||
if (++state->failsafe_timer > 64) {
|
||||
PIOS_SRXL_ResetChannels(state);
|
||||
state->failsafe_timer = 0;
|
||||
PERF_INCREMENT_VALUE(failsafeCount);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_SRXL */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -127,6 +127,29 @@ static inline void PIOS_Instrumentation_TrackPeriod(pios_counter_t counter_handl
|
||||
counter->lastUpdateTS = PIOS_DELAY_GetRaw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment a counter with a value
|
||||
* @param counter_handle handle of the counter to update @see PIOS_Instrumentation_SearchCounter @see PIOS_Instrumentation_CreateCounter
|
||||
* @param increment the value to increment counter with.
|
||||
*/
|
||||
static inline void PIOS_Instrumentation_incrementCounter(pios_counter_t counter_handle, int32_t increment)
|
||||
{
|
||||
PIOS_Assert(pios_instrumentation_perf_counters && counter_handle);
|
||||
vPortEnterCritical();
|
||||
pios_perf_counter_t *counter = (pios_perf_counter_t *)counter_handle;
|
||||
counter->value += increment;
|
||||
counter->max--;
|
||||
if (counter->value > counter->max) {
|
||||
counter->max = counter->value;
|
||||
}
|
||||
counter->min++;
|
||||
if (counter->value < counter->min) {
|
||||
counter->min = counter->value;
|
||||
}
|
||||
counter->lastUpdateTS = PIOS_DELAY_GetRaw();
|
||||
vPortExitCritical();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the Instrumentation infrastructure
|
||||
* @param maxCounters maximum number of allowed counters
|
||||
|
@ -98,6 +98,8 @@
|
||||
#define PERF_TIMED_SECTION_END(x) PIOS_Instrumentation_TimeEnd(x)
|
||||
#define PERF_MEASURE_PERIOD(x) PIOS_Instrumentation_TrackPeriod(x)
|
||||
#define PERF_TRACK_VALUE(x, y) PIOS_Instrumentation_updateCounter(x, y)
|
||||
#define PERF_INCREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, 1)
|
||||
#define PERF_DECREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, -1)
|
||||
|
||||
#else
|
||||
|
||||
@ -107,5 +109,7 @@
|
||||
#define PERF_TIMED_SECTION_END(x)
|
||||
#define PERF_MEASURE_PERIOD(x)
|
||||
#define PERF_TRACK_VALUE(x, y)
|
||||
#define PERF_INCREMENT_VALUE(x)
|
||||
#define PERF_DECREMENT_VALUE(x)
|
||||
#endif /* PIOS_INCLUDE_INSTRUMENTATION */
|
||||
#endif /* PIOS_INSTRUMENTATION_HELPER_H */
|
||||
|
43
flight/pios/inc/pios_srxl.h
Normal file
43
flight/pios/inc/pios_srxl.h
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_SRXL Multiplex SRXL receiver functions
|
||||
* @brief Code to read Multiplex SRXL receiver serial stream
|
||||
* @{
|
||||
*
|
||||
* @file pios_srxl.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
|
||||
* @brief Code to read Multiplex SRXL receiver serial stream
|
||||
* @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_SRXL_H
|
||||
#define PIOS_SRXL_H
|
||||
|
||||
/* Global Types */
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
#endif /* PIOS_SRXL_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
95
flight/pios/inc/pios_srxl_priv.h
Normal file
95
flight/pios/inc/pios_srxl_priv.h
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_SRXL Multiplex SRXL receiver functions
|
||||
* @brief Code to read Multiplex SRXL receiver serial stream
|
||||
* @{
|
||||
*
|
||||
* @file pios_srxl_priv.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
|
||||
* @brief Code to read Multiplex SRXL receiver serial stream
|
||||
* @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_SRXL_PRIV_H
|
||||
#define PIOS_SRXL_PRIV_H
|
||||
|
||||
#include <pios.h>
|
||||
#include <pios_stm32.h>
|
||||
#include <pios_usart_priv.h>
|
||||
|
||||
/*
|
||||
* Multiplex SRXL serial port settings:
|
||||
* 115200bps inverted serial stream, 8 bits, no parity, 1 stop bits
|
||||
* frame period is 14ms (FastResponse ON) or 21ms (FastResponse OFF)
|
||||
*
|
||||
* Frame structure:
|
||||
* 1 byte - start and version
|
||||
* 0xa1 (v1 12-channels)
|
||||
* 0xa2 (v2 16-channels)
|
||||
* 24/32 bytes - channel data (4 + 12 bit/channel, 12/16 channels, MSB first)
|
||||
* 16 bits per channel. 4 first reserved/not used. 12 bits channel data in
|
||||
* 4095 steps, 0x000(800µs) - 0x800(1500µs) - 0xfff(2200µs)
|
||||
* 2 bytes checksum (calculated over all bytes including start and version)
|
||||
*
|
||||
* Checksum calculation:
|
||||
* u16 CRC16(u16 crc, u8 value) {
|
||||
* u8 i;
|
||||
* crc = crc ^ (s16)value << 8;
|
||||
* for(i = 0; i < 8; i++) {
|
||||
* if(crc & 0x8000) {
|
||||
* crc = crc << 1 ^ 0x1021;
|
||||
* } else {
|
||||
* crc = crc << 1;
|
||||
* }
|
||||
* }
|
||||
* return crc;
|
||||
* }
|
||||
*/
|
||||
|
||||
#define SRXL_V1_HEADER 0xa1
|
||||
#define SRXL_V2_HEADER 0xa2
|
||||
|
||||
#define SRXL_HEADER_LENGTH 1
|
||||
#define SRXL_CHECKSUM_LENGTH 2
|
||||
#define SRXL_V1_CHANNEL_DATA_BYTES (12 * 2)
|
||||
#define SRXL_V2_CHANNEL_DATA_BYTES (16 * 2)
|
||||
#define SRXL_FRAME_LENGTH (SRXL_HEADER_LENGTH + SRXL_V2_CHANNEL_DATA_BYTES + SRXL_CHECKSUM_LENGTH)
|
||||
|
||||
/*
|
||||
* Multiplex SRXL protocol provides 16 proportional channels.
|
||||
* Do not change unless driver code is updated accordingly.
|
||||
*/
|
||||
#if (PIOS_SRXL_NUM_INPUTS != 16)
|
||||
#error "Multiplex SRXL protocol provides 16 proportional channels."
|
||||
#endif
|
||||
|
||||
extern const struct pios_rcvr_driver pios_srxl_rcvr_driver;
|
||||
|
||||
extern int32_t PIOS_SRXL_Init(uint32_t *srxl_id,
|
||||
const struct pios_com_driver *driver,
|
||||
uint32_t lower_id);
|
||||
|
||||
#endif /* PIOS_SRXL_PRIV_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -228,6 +228,10 @@ extern "C" {
|
||||
#include <pios_sbus.h>
|
||||
#endif
|
||||
|
||||
#ifdef PIOS_INCLUDE_SRXL
|
||||
#include <pios_srxl.h>
|
||||
#endif
|
||||
|
||||
/* PIOS abstract receiver interface */
|
||||
#ifdef PIOS_INCLUDE_RCVR
|
||||
#include <pios_rcvr.h>
|
||||
|
@ -20,6 +20,7 @@
|
||||
# (all architectures)
|
||||
UAVOBJSRCFILENAMES =
|
||||
UAVOBJSRCFILENAMES += statusvtolland
|
||||
UAVOBJSRCFILENAMES += statusvtolautotakeoff
|
||||
UAVOBJSRCFILENAMES += vtolselftuningstats
|
||||
UAVOBJSRCFILENAMES += accelgyrosettings
|
||||
UAVOBJSRCFILENAMES += accessorydesired
|
||||
|
@ -899,7 +899,6 @@ static const struct pios_sbus_cfg pios_sbus_cfg = {
|
||||
.gpio_clk_periph = RCC_AHB1Periph_GPIOC,
|
||||
};
|
||||
|
||||
|
||||
#ifdef PIOS_INCLUDE_COM_FLEXI
|
||||
/*
|
||||
* FLEXI PORT
|
||||
@ -1007,6 +1006,54 @@ static const struct pios_dsm_cfg pios_dsm_flexi_cfg = {
|
||||
|
||||
#endif /* PIOS_INCLUDE_DSM */
|
||||
|
||||
#if defined(PIOS_INCLUDE_SRXL)
|
||||
/*
|
||||
* SRXL USART
|
||||
*/
|
||||
#include <pios_srxl_priv.h>
|
||||
|
||||
static const struct pios_usart_cfg pios_usart_srxl_flexi_cfg = {
|
||||
.regs = USART3,
|
||||
.remap = GPIO_AF_USART3,
|
||||
.init = {
|
||||
.USART_BaudRate = 115200,
|
||||
.USART_WordLength = USART_WordLength_8b,
|
||||
.USART_Parity = USART_Parity_No,
|
||||
.USART_StopBits = USART_StopBits_1,
|
||||
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
|
||||
.USART_Mode = USART_Mode_Rx,
|
||||
},
|
||||
.irq = {
|
||||
.init = {
|
||||
.NVIC_IRQChannel = USART3_IRQn,
|
||||
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||
.NVIC_IRQChannelSubPriority = 0,
|
||||
.NVIC_IRQChannelCmd = ENABLE,
|
||||
},
|
||||
},
|
||||
.rx = {
|
||||
.gpio = GPIOB,
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_11,
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Mode = GPIO_Mode_AF,
|
||||
.GPIO_OType = GPIO_OType_PP,
|
||||
.GPIO_PuPd = GPIO_PuPd_UP
|
||||
},
|
||||
},
|
||||
.tx = {
|
||||
.gpio = GPIOB,
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_10,
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Mode = GPIO_Mode_OUT,
|
||||
.GPIO_OType = GPIO_OType_PP,
|
||||
.GPIO_PuPd = GPIO_PuPd_UP
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
#endif /* PIOS_INCLUDE_SRXL */
|
||||
/*
|
||||
* HK OSD
|
||||
*/
|
||||
|
@ -103,6 +103,7 @@
|
||||
/* #define PIOS_INCLUDE_PPM_FLEXI */
|
||||
#define PIOS_INCLUDE_DSM
|
||||
#define PIOS_INCLUDE_SBUS
|
||||
#define PIOS_INCLUDE_SRXL
|
||||
#define PIOS_INCLUDE_GCSRCVR
|
||||
#define PIOS_INCLUDE_OPLINKRCVR
|
||||
|
||||
|
@ -499,6 +499,27 @@ void PIOS_Board_Init(void)
|
||||
case HWSETTINGS_RM_FLEXIPORT_OSDHK:
|
||||
PIOS_Board_configure_com(&pios_usart_hkosd_flexi_cfg, PIOS_COM_HKOSD_RX_BUF_LEN, PIOS_COM_HKOSD_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_hkosd_id);
|
||||
break;
|
||||
case HWSETTINGS_RM_FLEXIPORT_SRXL:
|
||||
#if defined(PIOS_INCLUDE_SRXL)
|
||||
{
|
||||
uint32_t pios_usart_srxl_id;
|
||||
if (PIOS_USART_Init(&pios_usart_srxl_id, &pios_usart_srxl_flexi_cfg)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
|
||||
uint32_t pios_srxl_id;
|
||||
if (PIOS_SRXL_Init(&pios_srxl_id, &pios_usart_com_driver, pios_usart_srxl_id)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
|
||||
uint32_t pios_srxl_rcvr_id;
|
||||
if (PIOS_RCVR_Init(&pios_srxl_rcvr_id, &pios_srxl_rcvr_driver, pios_srxl_id)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_SRXL] = pios_srxl_rcvr_id;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
} /* hwsettings_rm_flexiport */
|
||||
|
||||
/* Moved this here to allow binding on flexiport */
|
||||
@ -868,7 +889,6 @@ void PIOS_Board_Init(void)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#if defined(PIOS_INCLUDE_GCSRCVR)
|
||||
GCSReceiverInitialize();
|
||||
uint32_t pios_gcsrcvr_id;
|
||||
|
@ -257,6 +257,12 @@ extern uint32_t pios_packet_handler;
|
||||
#define PIOS_SBUS_MAX_DEVS 1
|
||||
#define PIOS_SBUS_NUM_INPUTS (16 + 2)
|
||||
|
||||
// -------------------------
|
||||
// Receiver Multiplex SRXL input
|
||||
// -------------------------
|
||||
#define PIOS_SRXL_MAX_DEVS 1
|
||||
#define PIOS_SRXL_NUM_INPUTS 16
|
||||
|
||||
// -------------------------
|
||||
// Receiver DSM input
|
||||
// -------------------------
|
||||
|
@ -376,49 +376,48 @@ UAVTalkRxState UAVTalkProcessInputStreamQuiet(UAVTalkConnection connectionHandle
|
||||
}
|
||||
|
||||
uint8_t processedBytes = (*position);
|
||||
uint8_t count = 0;
|
||||
|
||||
// stop processing as soon as a complete packet is received, error is encountered or buffer is processed entirely
|
||||
while ((count = length - (*position)) > 0
|
||||
while ((length > (*position))
|
||||
&& iproc->state != UAVTALK_STATE_COMPLETE
|
||||
&& iproc->state != UAVTALK_STATE_ERROR) {
|
||||
// Receive state machine
|
||||
if (iproc->state == UAVTALK_STATE_SYNC &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_SYNC &&
|
||||
!UAVTalkProcess_SYNC(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (iproc->state == UAVTALK_STATE_TYPE &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_TYPE &&
|
||||
!UAVTalkProcess_TYPE(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (iproc->state == UAVTALK_STATE_SIZE &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_SIZE &&
|
||||
!UAVTalkProcess_SIZE(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (iproc->state == UAVTALK_STATE_OBJID &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_OBJID &&
|
||||
!UAVTalkProcess_OBJID(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (iproc->state == UAVTALK_STATE_INSTID &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_INSTID &&
|
||||
!UAVTalkProcess_INSTID(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (iproc->state == UAVTALK_STATE_TIMESTAMP &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_TIMESTAMP &&
|
||||
!UAVTalkProcess_TIMESTAMP(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (iproc->state == UAVTALK_STATE_DATA &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_DATA &&
|
||||
!UAVTalkProcess_DATA(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (iproc->state == UAVTALK_STATE_CS &&
|
||||
if ((length > (*position)) && iproc->state == UAVTALK_STATE_CS &&
|
||||
!UAVTalkProcess_CS(connection, iproc, rxbuffer, length, position)) {
|
||||
break;
|
||||
}
|
||||
|
@ -115,6 +115,17 @@ $(INITFIELDS)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of this UAVDataObject with default field
|
||||
* values. This is intended to be used by 'reset to default' functionality.
|
||||
*
|
||||
* @return new instance of this class with default values.
|
||||
*/
|
||||
@Override
|
||||
public UAVDataObject getDefaultInstance(){
|
||||
return new $(NAME)();
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function to retrieve an instance of the object.
|
||||
*/
|
||||
|
@ -158,6 +158,9 @@ void InputChannelForm::groupUpdated()
|
||||
case ManualControlSettings::CHANNELGROUPS_SBUS:
|
||||
count = 18;
|
||||
break;
|
||||
case ManualControlSettings::CHANNELGROUPS_SRXL:
|
||||
count = 16;
|
||||
break;
|
||||
case ManualControlSettings::CHANNELGROUPS_GCS:
|
||||
count = GCSReceiver::CHANNEL_NUMELEM;
|
||||
break;
|
||||
|
@ -80,6 +80,7 @@ SRC += $(PIOSCOMMON)/pios_rfm22b.c
|
||||
SRC += $(PIOSCOMMON)/pios_rfm22b_com.c
|
||||
SRC += $(PIOSCOMMON)/pios_rcvr.c
|
||||
SRC += $(PIOSCOMMON)/pios_sbus.c
|
||||
SRC += $(PIOSCOMMON)/pios_srxl.c
|
||||
SRC += $(PIOSCOMMON)/pios_sdcard.c
|
||||
SRC += $(PIOSCOMMON)/pios_sensors.c
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
<field name="RM_RcvrPort" units="function" type="enum" elements="1" options="Disabled,PWM,PPM,PPM+PWM,PPM+Telemetry,PPM+Outputs,Outputs,Telemetry" defaultvalue="PWM"/>
|
||||
<field name="RM_MainPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,S.Bus,DSM,DebugConsole,ComBridge,OsdHk" defaultvalue="Disabled"/>
|
||||
<field name="RM_FlexiPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,I2C,DSM,DebugConsole,ComBridge,OsdHk" defaultvalue="Disabled"/>
|
||||
<field name="RM_FlexiPort" units="function" type="enum" elements="1" options="Disabled,Telemetry,GPS,I2C,DSM,SRXL,DebugConsole,ComBridge,OsdHk" defaultvalue="Disabled"/>
|
||||
|
||||
<field name="TelemetrySpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200" defaultvalue="57600"/>
|
||||
<field name="GPSSpeed" units="bps" type="enum" elements="1" options="2400,4800,9600,19200,38400,57600,115200,230400" defaultvalue="57600"/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<description>Settings to indicate how to decode receiver input by @ref ManualControlModule.</description>
|
||||
<field name="ChannelGroups" units="Channel Group" type="enum"
|
||||
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"
|
||||
options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),S.Bus,GCS,OPLink,None" defaultvalue="None"/>
|
||||
options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),S.Bus,SRXL,GCS,OPLink,None" defaultvalue="None"/>
|
||||
<field name="ChannelNumber" units="channel" type="uint8" defaultvalue="0"
|
||||
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"/>
|
||||
<field name="ChannelMin" units="us" type="int16" defaultvalue="1000"
|
||||
|
@ -2,7 +2,7 @@
|
||||
<object name="ReceiverActivity" singleinstance="true" settings="false" category="System">
|
||||
<description>Monitors which receiver channels have been active within the last second.</description>
|
||||
<field name="ActiveGroup" units="Channel Group" type="enum" elements="1"
|
||||
options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),S.Bus,GCS,OPLink,None"
|
||||
options="PWM,PPM,DSM (MainPort),DSM (FlexiPort),S.Bus,SRXL,GCS,OPLink,None"
|
||||
defaultvalue="None"/>
|
||||
<field name="ActiveChannel" units="channel" type="uint8" elements="1"
|
||||
defaultvalue="255"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user