mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
Try and get pios_gcsrcvr working on simulation and revo for testing RTH. Had
to include uavobjectmanager.h manually which was weird
This commit is contained in:
parent
10aa31a57f
commit
dc7fe1bdd8
47
flight/PiOS.osx/inc/pios_gcsrcvr_priv.h
Normal file
47
flight/PiOS.osx/inc/pios_gcsrcvr_priv.h
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_GCSRCVR GCS Receiver Functions
|
||||
* @brief PIOS interface to read from GCS receiver port
|
||||
* @{
|
||||
*
|
||||
* @file pios_gcsrcvr_priv.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief GCS receiver private functions
|
||||
* @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_GCSRCVR_PRIV_H
|
||||
#define PIOS_GCSRCVR_PRIV_H
|
||||
|
||||
#include <pios.h>
|
||||
|
||||
#include "gcsreceiver.h"
|
||||
|
||||
extern const struct pios_rcvr_driver pios_gcsrcvr_rcvr_driver;
|
||||
|
||||
extern int32_t PIOS_GCSRCVR_Init(uint32_t *gcsrcvr_id);
|
||||
|
||||
#endif /* PIOS_GCSRCVR_PRIV_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
139
flight/PiOS.osx/osx/pios_gcsrcvr.c
Normal file
139
flight/PiOS.osx/osx/pios_gcsrcvr.c
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_GCSRCVR GCS Receiver Input Functions
|
||||
* @brief Code to read the channels within the GCS Receiver UAVObject
|
||||
* @{
|
||||
*
|
||||
* @file pios_gcsrcvr.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief GCS Input functions (STM32 dependent)
|
||||
* @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
|
||||
*/
|
||||
|
||||
/* Project Includes */
|
||||
#include "pios.h"
|
||||
|
||||
#if defined(PIOS_INCLUDE_GCSRCVR)
|
||||
#include "openpilot.h"
|
||||
#include "pios_gcsrcvr_priv.h"
|
||||
|
||||
static GCSReceiverData gcsreceiverdata;
|
||||
|
||||
/* Provide a RCVR driver */
|
||||
static int32_t PIOS_GCSRCVR_Get(uint32_t rcvr_id, uint8_t channel);
|
||||
|
||||
const struct pios_rcvr_driver pios_gcsrcvr_rcvr_driver = {
|
||||
.read = PIOS_GCSRCVR_Get,
|
||||
};
|
||||
|
||||
/* Local Variables */
|
||||
enum pios_gcsrcvr_dev_magic {
|
||||
PIOS_GCSRCVR_DEV_MAGIC = 0xe9da5c56,
|
||||
};
|
||||
|
||||
struct pios_gcsrcvr_dev {
|
||||
enum pios_gcsrcvr_dev_magic magic;
|
||||
|
||||
uint8_t supv_timer;
|
||||
bool Fresh;
|
||||
};
|
||||
|
||||
static struct pios_gcsrcvr_dev *global_gcsrcvr_dev;
|
||||
|
||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||
static struct pios_gcsrcvr_dev *PIOS_gcsrcvr_alloc(void)
|
||||
{
|
||||
struct pios_gcsrcvr_dev * gcsrcvr_dev;
|
||||
|
||||
gcsrcvr_dev = (struct pios_gcsrcvr_dev *)pvPortMalloc(sizeof(*gcsrcvr_dev));
|
||||
if (!gcsrcvr_dev) return(NULL);
|
||||
|
||||
gcsrcvr_dev->magic = PIOS_GCSRCVR_DEV_MAGIC;
|
||||
gcsrcvr_dev->Fresh = FALSE;
|
||||
gcsrcvr_dev->supv_timer = 0;
|
||||
|
||||
/* The update callback cannot receive the device pointer, so set it in a global */
|
||||
global_gcsrcvr_dev = gcsrcvr_dev;
|
||||
|
||||
return(gcsrcvr_dev);
|
||||
}
|
||||
#else
|
||||
static struct pios_gcsrcvr_dev pios_gcsrcvr_devs[PIOS_GCSRCVR_MAX_DEVS];
|
||||
static uint8_t pios_gcsrcvr_num_devs;
|
||||
static struct pios_gcsrcvr_dev *PIOS_gcsrcvr_alloc(void)
|
||||
{
|
||||
struct pios_gcsrcvr_dev *gcsrcvr_dev;
|
||||
|
||||
if (pios_gcsrcvr_num_devs >= PIOS_GCSRCVR_MAX_DEVS) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
gcsrcvr_dev = &pios_gcsrcvr_devs[pios_gcsrcvr_num_devs++];
|
||||
gcsrcvr_dev->magic = PIOS_GCSRCVR_DEV_MAGIC;
|
||||
gcsrcvr_dev->Fresh = FALSE;
|
||||
gcsrcvr_dev->supv_timer = 0;
|
||||
|
||||
global_gcsrcvr_dev = gcsrcvr_dev;
|
||||
|
||||
return (gcsrcvr_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gcsreceiver_updated(UAVObjEvent * ev)
|
||||
{
|
||||
struct pios_gcsrcvr_dev *gcsrcvr_dev = global_gcsrcvr_dev;
|
||||
if (ev->obj == GCSReceiverHandle()) {
|
||||
GCSReceiverGet(&gcsreceiverdata);
|
||||
gcsrcvr_dev->Fresh = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
extern int32_t PIOS_GCSRCVR_Init(uint32_t *gcsrcvr_id)
|
||||
{
|
||||
struct pios_gcsrcvr_dev *gcsrcvr_dev;
|
||||
|
||||
/* Allocate the device structure */
|
||||
gcsrcvr_dev = (struct pios_gcsrcvr_dev *)PIOS_gcsrcvr_alloc();
|
||||
if (!gcsrcvr_dev)
|
||||
return -1;
|
||||
|
||||
/* Register uavobj callback */
|
||||
GCSReceiverConnectCallback (gcsreceiver_updated);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t PIOS_GCSRCVR_Get(uint32_t rcvr_id, uint8_t channel)
|
||||
{
|
||||
if (channel >= GCSRECEIVER_CHANNEL_NUMELEM) {
|
||||
/* channel is out of range */
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (gcsreceiverdata.Channel[channel]);
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_GCSRCVR */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -180,7 +180,7 @@ SRC += $(PIOSPOSIX)/pios_wdg.c
|
||||
SRC += $(PIOSPOSIX)/pios_debug.c
|
||||
|
||||
SRC += $(PIOSPOSIX)/pios_rcvr.c
|
||||
#SRC += $(PIOSPOSIX)/pios_sim.c
|
||||
SRC += $(PIOSPOSIX)/pios_gcsrcvr.c
|
||||
|
||||
## Libraries for flight calculations
|
||||
SRC += $(FLIGHTLIB)/fifo_buffer.c
|
||||
|
@ -63,6 +63,7 @@ extern uint32_t pios_com_spectrum_id;
|
||||
#define PIOS_COM_DEBUG (PIOS_COM_AUX
|
||||
#endif
|
||||
|
||||
#define PIOS_GCSRCVR_TIMEOUT_MS 200
|
||||
/**
|
||||
* glue macros for file IO
|
||||
* STM32 uses DOSFS for file IO
|
||||
|
@ -43,6 +43,7 @@
|
||||
#define PIOS_INCLUDE_UDP
|
||||
#define PIOS_INCLUDE_SERVO
|
||||
#define PIOS_INCLUDE_RCVR
|
||||
#define PIOS_INCLUDE_GCSRCVR
|
||||
|
||||
#define PIOS_RCVR_MAX_CHANNELS 12
|
||||
#define PIOS_RCVR_MAX_DEVS 3
|
||||
|
@ -39,9 +39,7 @@
|
||||
#include "manualcontrolsettings.h"
|
||||
|
||||
#include "pios_rcvr_priv.h"
|
||||
|
||||
struct pios_rcvr_channel_map pios_rcvr_channel_to_id_map[PIOS_RCVR_MAX_CHANNELS];
|
||||
uint32_t pios_rcvr_max_channel;
|
||||
#include "pios_gcsrcvr_priv.h"
|
||||
|
||||
void Stack_Change() {
|
||||
}
|
||||
@ -213,6 +211,17 @@ void PIOS_Board_Init(void) {
|
||||
#endif /* PIOS_INCLUDE_GPS */
|
||||
#endif
|
||||
|
||||
#if defined(PIOS_INCLUDE_GCSRCVR)
|
||||
GCSReceiverInitialize();
|
||||
uint32_t pios_gcsrcvr_id;
|
||||
PIOS_GCSRCVR_Init(&pios_gcsrcvr_id);
|
||||
uint32_t pios_gcsrcvr_rcvr_id;
|
||||
if (PIOS_RCVR_Init(&pios_gcsrcvr_rcvr_id, &pios_gcsrcvr_rcvr_driver, pios_gcsrcvr_id)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id;
|
||||
#endif /* PIOS_INCLUDE_GCSRCVR */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,7 @@ UAVOBJSRCFILENAMES += flightplansettings
|
||||
UAVOBJSRCFILENAMES += flightplanstatus
|
||||
UAVOBJSRCFILENAMES += flighttelemetrystats
|
||||
UAVOBJSRCFILENAMES += gcstelemetrystats
|
||||
UAVOBJSRCFILENAMES += gcsreceiver
|
||||
UAVOBJSRCFILENAMES += gpsposition
|
||||
UAVOBJSRCFILENAMES += gpssatellites
|
||||
UAVOBJSRCFILENAMES += gpstime
|
||||
|
@ -1754,10 +1754,13 @@ static const struct pios_ppm_cfg pios_ppm_cfg = {
|
||||
|
||||
#endif //PPM
|
||||
|
||||
#if defined(PIOS_INCLUDE_GCSRCVR)
|
||||
#include "pios_gcsrcvr_priv.h"
|
||||
#endif /* PIOS_INCLUDE_GCSRCVR */
|
||||
|
||||
#if defined(PIOS_INCLUDE_RCVR)
|
||||
#include "pios_rcvr_priv.h"
|
||||
|
||||
#endif
|
||||
#endif /* PIOS_INCLUDE_RCVR */
|
||||
|
||||
#if defined(PIOS_INCLUDE_USB)
|
||||
#include "pios_usb_priv.h"
|
||||
|
Loading…
Reference in New Issue
Block a user