2 ******************************************************************************
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @brief Defines board specific static initializers for hardware for the OpenPilot board.
7 * @see The GNU Public License (GPL) Version 3
9 *****************************************************************************/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "inc/openpilot.h"
27 #include <pios_com_priv.h>
28 #include <pios_tcp_priv.h>
29 #include <pios_udp_priv.h>
30 #include <pios_rcvr_priv.h>
31 #include <pios_gcsrcvr_priv.h>
32 #include <uavobjectsinit.h>
34 #include <accelssensor.h>
35 #include <barosensor.h>
36 #include <gpspositionsensor.h>
37 #include <gyrosensor.h>
38 #include <magsensor.h>
39 #include <manualcontrolsettings.h>
41 void Stack_Change() {}
43 void Stack_Change_Weak() {}
46 const struct pios_tcp_cfg pios_tcp_telem_cfg
= {
51 const struct pios_udp_cfg pios_udp_telem_cfg
= {
56 const struct pios_tcp_cfg pios_tcp_gps_cfg
= {
60 const struct pios_tcp_cfg pios_tcp_debug_cfg
= {
69 const struct pios_tcp_cfg pios_tcp_aux_cfg
= {
75 #define PIOS_COM_TELEM_RF_RX_BUF_LEN 192
76 #define PIOS_COM_TELEM_RF_TX_BUF_LEN 192
77 #define PIOS_COM_GPS_RX_BUF_LEN 96
80 * Board specific number of devices.
83 struct pios_udp_dev pios_udp_devs[] = {
84 #define PIOS_UDP_TELEM 0
86 .cfg = &pios_udp0_cfg,
88 #define PIOS_UDP_GPS 1
90 .cfg = &pios_udp1_cfg,
92 #define PIOS_UDP_LOCAL 2
94 .cfg = &pios_udp2_cfg,
97 #define PIOS_UDP_AUX 3
99 .cfg = &pios_udp3_cfg,
104 uint8_t pios_udp_num_devices = NELEMENTS(pios_udp_devs);
111 * Board specific number of devices.
113 extern const struct pios_com_driver pios_serial_com_driver
;
114 extern const struct pios_com_driver pios_udp_com_driver
;
115 extern const struct pios_com_driver pios_tcp_com_driver
;
117 uint32_t pios_com_telem_rf_id
;
118 uint32_t pios_com_telem_usb_id
;
119 uint32_t pios_com_gps_id
;
120 uint32_t pios_com_aux_id
;
121 uint32_t pios_com_spectrum_id
;
122 uint32_t pios_rcvr_group_map
[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE
];
126 * initializes all the core systems on this specific hardware
127 * called from System/openpilot.c
129 void PIOS_Board_Init(void)
134 /* Initialize the delayed callback library */
135 PIOS_CALLBACKSCHEDULER_Initialize();
137 /* Initialize UAVObject libraries */
138 EventDispatcherInitialize();
140 UAVObjectsInitializeAll();
142 AccelSensorInitialize();
143 BaroSensorInitialize();
144 MagSensorInitialize();
145 GPSPositionSensorInitialize();
146 GyroSensorInitialize();
148 /* Initialize the alarms library */
151 /* Initialize the task monitor */
152 if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM
)) {
156 #if defined(PIOS_INCLUDE_COM)
157 #if defined(PIOS_INCLUDE_TELEMETRY_RF) && 1
159 uint32_t pios_tcp_telem_rf_id
;
160 if (PIOS_TCP_Init(&pios_tcp_telem_rf_id
, &pios_tcp_telem_cfg
)) {
164 uint8_t *rx_buffer
= (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN
);
165 uint8_t *tx_buffer
= (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN
);
166 PIOS_Assert(rx_buffer
);
167 PIOS_Assert(tx_buffer
);
168 if (PIOS_COM_Init(&pios_com_telem_rf_id
, &pios_tcp_com_driver
, pios_tcp_telem_rf_id
,
169 rx_buffer
, PIOS_COM_TELEM_RF_RX_BUF_LEN
,
170 tx_buffer
, PIOS_COM_TELEM_RF_TX_BUF_LEN
)) {
174 #endif /* PIOS_INCLUDE_TELEMETRY_RF */
176 #if defined(PIOS_INCLUDE_TELEMETRY_RF) && 0
178 uint32_t pios_udp_telem_rf_id
;
179 if (PIOS_UDP_Init(&pios_udp_telem_rf_id
, &pios_udp_telem_cfg
)) {
183 uint8_t *rx_buffer
= (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN
);
184 uint8_t *tx_buffer
= (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN
);
185 PIOS_Assert(rx_buffer
);
186 PIOS_Assert(tx_buffer
);
187 if (PIOS_COM_Init(&pios_com_telem_rf_id
, &pios_udp_com_driver
, pios_udp_telem_rf_id
,
188 rx_buffer
, PIOS_COM_TELEM_RF_RX_BUF_LEN
,
189 tx_buffer
, PIOS_COM_TELEM_RF_TX_BUF_LEN
)) {
193 #endif /* PIOS_INCLUDE_TELEMETRY_RF */
196 #if defined(PIOS_INCLUDE_GPS)
198 uint32_t pios_tcp_gps_id
;
199 if (PIOS_TCP_Init(&pios_tcp_gps_id
, &pios_tcp_gps_cfg
)) {
202 uint8_t *rx_buffer
= (uint8_t *)pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN
);
203 PIOS_Assert(rx_buffer
);
204 if (PIOS_COM_Init(&pios_com_gps_id
, &pios_tcp_com_driver
, pios_tcp_gps_id
,
205 rx_buffer
, PIOS_COM_GPS_RX_BUF_LEN
,
210 #endif /* PIOS_INCLUDE_GPS */
211 #endif /* if defined(PIOS_INCLUDE_COM) */
213 #if defined(PIOS_INCLUDE_GCSRCVR)
214 GCSReceiverInitialize();
215 uint32_t pios_gcsrcvr_id
;
216 PIOS_GCSRCVR_Init(&pios_gcsrcvr_id
);
217 uint32_t pios_gcsrcvr_rcvr_id
;
218 if (PIOS_RCVR_Init(&pios_gcsrcvr_rcvr_id
, &pios_gcsrcvr_rcvr_driver
, pios_gcsrcvr_id
)) {
221 pios_rcvr_group_map
[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS
] = pios_gcsrcvr_rcvr_id
;
222 #endif /* PIOS_INCLUDE_GCSRCVR */