2010-07-03 23:50:13 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file pios_board.c
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief Defines board specific static initializers for hardware for the OpenPilot board.
|
|
|
|
* @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>
|
|
|
|
#include <pios_udp_priv.h>
|
|
|
|
#include <pios_com_priv.h>
|
|
|
|
#include <openpilot.h>
|
|
|
|
#include <uavobjectsinit.h>
|
|
|
|
|
2011-08-19 16:52:05 +02:00
|
|
|
#include "attituderaw.h"
|
2011-08-19 18:36:30 +02:00
|
|
|
#include "attitudeactual.h"
|
2011-08-19 16:52:05 +02:00
|
|
|
#include "positionactual.h"
|
|
|
|
#include "velocityactual.h"
|
2011-10-11 18:07:04 +02:00
|
|
|
#include "manualcontrolsettings.h"
|
2011-08-19 16:52:05 +02:00
|
|
|
|
2011-10-11 18:07:04 +02:00
|
|
|
#if defined(PIOS_INCLUDE_RCVR)
|
2011-07-21 19:50:15 +02:00
|
|
|
#include "pios_rcvr_priv.h"
|
|
|
|
|
2011-10-11 18:07:04 +02:00
|
|
|
/* One slot per selectable receiver group.
|
|
|
|
* eg. PWM, PPM, GCS, SPEKTRUM1, SPEKTRUM2, SBUS
|
|
|
|
* NOTE: No slot in this map for NONE.
|
|
|
|
*/
|
|
|
|
uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE];
|
|
|
|
|
|
|
|
#endif /* PIOS_INCLUDE_RCVR */
|
|
|
|
|
2011-07-21 19:50:15 +02:00
|
|
|
|
|
|
|
void Stack_Change() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stack_Change_Weak() {
|
|
|
|
}
|
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
|
2011-08-14 12:49:07 +02:00
|
|
|
const struct pios_udp_cfg pios_udp_telem_cfg = {
|
2010-07-03 23:50:13 +02:00
|
|
|
.ip = "0.0.0.0",
|
|
|
|
.port = 9000,
|
|
|
|
};
|
2011-08-14 12:49:07 +02:00
|
|
|
const struct pios_udp_cfg pios_udp_gps_cfg = {
|
2010-07-03 23:50:13 +02:00
|
|
|
.ip = "0.0.0.0",
|
|
|
|
.port = 9001,
|
|
|
|
};
|
2011-08-14 12:49:07 +02:00
|
|
|
const struct pios_udp_cfg pios_udp_debug_cfg = {
|
2010-07-03 23:50:13 +02:00
|
|
|
.ip = "0.0.0.0",
|
|
|
|
.port = 9002,
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef PIOS_COM_AUX
|
|
|
|
/*
|
|
|
|
* AUX USART
|
|
|
|
*/
|
2011-08-14 12:49:07 +02:00
|
|
|
const struct pios_udp_cfg pios_udp_aux_cfg = {
|
2010-07-03 23:50:13 +02:00
|
|
|
.ip = "0.0.0.0",
|
|
|
|
.port = 9003,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2011-08-14 12:49:07 +02:00
|
|
|
#define PIOS_COM_TELEM_RF_RX_BUF_LEN 192
|
|
|
|
#define PIOS_COM_TELEM_RF_TX_BUF_LEN 192
|
2011-08-25 14:46:30 +02:00
|
|
|
#define PIOS_COM_GPS_RX_BUF_LEN 96
|
2011-08-14 12:49:07 +02:00
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
/*
|
|
|
|
* Board specific number of devices.
|
|
|
|
*/
|
2011-08-14 12:49:07 +02:00
|
|
|
/*
|
2010-07-03 23:50:13 +02:00
|
|
|
struct pios_udp_dev pios_udp_devs[] = {
|
|
|
|
#define PIOS_UDP_TELEM 0
|
|
|
|
{
|
|
|
|
.cfg = &pios_udp0_cfg,
|
|
|
|
},
|
|
|
|
#define PIOS_UDP_GPS 1
|
|
|
|
{
|
|
|
|
.cfg = &pios_udp1_cfg,
|
|
|
|
},
|
|
|
|
#define PIOS_UDP_LOCAL 2
|
|
|
|
{
|
|
|
|
.cfg = &pios_udp2_cfg,
|
|
|
|
},
|
|
|
|
#ifdef PIOS_COM_AUX
|
|
|
|
#define PIOS_UDP_AUX 3
|
|
|
|
{
|
|
|
|
.cfg = &pios_udp3_cfg,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
uint8_t pios_udp_num_devices = NELEMENTS(pios_udp_devs);
|
2011-08-14 12:49:07 +02:00
|
|
|
*/
|
2010-07-03 23:50:13 +02:00
|
|
|
/*
|
|
|
|
* COM devices
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Board specific number of devices.
|
|
|
|
*/
|
|
|
|
extern const struct pios_com_driver pios_serial_com_driver;
|
|
|
|
extern const struct pios_com_driver pios_udp_com_driver;
|
|
|
|
|
2011-08-14 12:49:07 +02:00
|
|
|
uint32_t pios_com_telem_rf_id;
|
|
|
|
uint32_t pios_com_telem_usb_id;
|
|
|
|
uint32_t pios_com_gps_id;
|
|
|
|
uint32_t pios_com_aux_id;
|
|
|
|
uint32_t pios_com_spectrum_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PIOS_Board_Init()
|
|
|
|
* initializes all the core systems on this specific hardware
|
|
|
|
* called from System/openpilot.c
|
|
|
|
*/
|
|
|
|
void PIOS_Board_Init(void) {
|
|
|
|
|
|
|
|
/* Delay system */
|
|
|
|
PIOS_DELAY_Init();
|
|
|
|
|
|
|
|
/* Initialize UAVObject libraries */
|
|
|
|
EventDispatcherInitialize();
|
|
|
|
UAVObjInitialize();
|
|
|
|
UAVObjectsInitializeAll();
|
|
|
|
|
|
|
|
/* Initialize the alarms library */
|
|
|
|
AlarmsInitialize();
|
|
|
|
|
|
|
|
/* Initialize the task monitor library */
|
|
|
|
TaskMonitorInitialize();
|
|
|
|
|
|
|
|
#if defined(PIOS_INCLUDE_COM)
|
|
|
|
#if defined(PIOS_INCLUDE_TELEMETRY_RF)
|
|
|
|
{
|
|
|
|
uint32_t pios_udp_telem_rf_id;
|
|
|
|
if (PIOS_UDP_Init(&pios_udp_telem_rf_id, &pios_udp_telem_cfg)) {
|
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
|
|
|
|
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
|
|
|
|
PIOS_Assert(rx_buffer);
|
|
|
|
PIOS_Assert(tx_buffer);
|
|
|
|
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_udp_com_driver, pios_udp_telem_rf_id,
|
|
|
|
rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN,
|
|
|
|
tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) {
|
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
|
|
|
|
|
|
|
|
#if defined(PIOS_INCLUDE_GPS)
|
|
|
|
{
|
|
|
|
uint32_t pios_udp_gps_id;
|
2011-08-19 13:20:40 +02:00
|
|
|
if (PIOS_UDP_Init(&pios_udp_gps_id, &pios_udp_gps_cfg)) {
|
2011-08-14 12:49:07 +02:00
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
|
|
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN);
|
|
|
|
PIOS_Assert(rx_buffer);
|
|
|
|
if (PIOS_COM_Init(&pios_com_gps_id, &pios_udp_com_driver, pios_udp_gps_id,
|
|
|
|
rx_buffer, PIOS_COM_GPS_RX_BUF_LEN,
|
2011-08-25 14:46:30 +02:00
|
|
|
NULL, 0)) {
|
2011-08-14 12:49:07 +02:00
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* PIOS_INCLUDE_GPS */
|
2010-07-03 23:50:13 +02:00
|
|
|
#endif
|
|
|
|
|
2011-08-19 16:52:05 +02:00
|
|
|
// Initialize these here as posix has no AHRSComms
|
|
|
|
AttitudeRawInitialize();
|
2011-08-19 18:36:30 +02:00
|
|
|
AttitudeActualInitialize();
|
2011-08-19 16:52:05 +02:00
|
|
|
VelocityActualInitialize();
|
|
|
|
PositionActualInitialize();
|
2011-08-14 12:49:07 +02:00
|
|
|
|
|
|
|
}
|
2010-07-03 23:50:13 +02:00
|
|
|
|
2010-07-28 09:28:21 +02:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|