Add files for csc_ap (autopilot based on CSC board)

This commit is contained in:
Allen Ibara
2009-05-22 07:32:29 +00:00
parent 2ae0a7fb44
commit 14284ad488
8 changed files with 265 additions and 17 deletions
+17 -16
View File
@@ -48,7 +48,7 @@ ap.TARGETDIR = main
ap.CFLAGS += -I$(SRC_CSC)
ap.CFLAGS += -DCONFIG=$(BOARD_CFG)
ap.srcs += $(SRC_CSC)/csc_main.c
ap.srcs += $(SRC_CSC)/csc_ap_main.c
ap.CFLAGS += -DLED -DTIME_LED=1
ap.CFLAGS += -DCSC_BOARD_ID=$(CSC_ID)
@@ -61,32 +61,33 @@ ap.srcs += $(SRC_ARCH)/adc_hw.c
ap.CFLAGS += -DADC -DUSE_AD0 -DUSE_AD0_0 -DUSE_AD0_1
ap.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B57600 -DUART0_VIC_SLOT=5
#ap.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 -DUART1_VIC_SLOT=6
#ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport \
# -DDOWNLINK_DEVICE=Uart0
#ap.srcs += downlink.c pprz_transport.c
ap.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 -DUART1_VIC_SLOT=6
ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport \
-DDOWNLINK_DEVICE=Uart0
ap.srcs += downlink.c pprz_transport.c $(SRC_CSC)/csc_telemetry.c
ap.CFLAGS += -DAP_LINK_CAN -DCAN_LED=2
ap.CFLAGS += -DUSE_CAN1 -DCAN1_BTR=CANBitrate125k_2MHz
ap.CFLAGS += -DCAN1_VIC_SLOT=3 -DCAN1_ERR_VIC_SLOT=7
ap.srcs += $(SRC_CSC)/csc_can.c
#ap.CFLAGS += -DAP_LINK_CAN -DCAN_LED=2
#ap.CFLAGS += -DUSE_CAN1 -DCAN1_BTR=CANBitrate125k_2MHz
#ap.CFLAGS += -DCAN1_VIC_SLOT=3 -DCAN1_ERR_VIC_SLOT=7
#ap.srcs += $(SRC_CSC)/csc_can.c
#ap.CFLAGS += -DUSE_CAN2 -DCAN2_BTR=CANBitrate125k_2MHz -DCAN2_VIC_SLOT=4
#ap.CFLAGS += -DAP_LINK_UART -DPPRZ_UART=Uart1
#ap.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 -DUART1_VIC_SLOT=6
#ap.srcs += pprz_transport.c
ap.srcs += $(SRC_CSC)/csc_ap_link.c
#ap.srcs += $(SRC_CSC)/csc_ap_link.c
ap.srcs += $(SRC_CSC)/csc_servos.c
ap.CFLAGS += -DPWM_SERVO_3 -DPWM_SERVO_4 -DPWM_SERVO_5 -DPWM_SERVO_0
ap.srcs += $(SRC_ARCH)/servos_direct_hw.c
ap.srcs += $(SRC_CSC)/csc_adc.c
ap.CFLAGS += -DACTUATORS=\"servos_direct_hw.h\"
ap.srcs += commands.c actuators.c
ap.CFLAGS += -DTHROTTLE_LINK=Uart0 -DTHROTTLE_LED=3
ap.srcs += $(SRC_CSC)/csc_throttle.c
ap.CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_TYPE=RC_JR
ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c
#ap.CFLAGS += -DTHROTTLE_LINK=Uart0 -DTHROTTLE_LED=3
#ap.srcs += $(SRC_CSC)/csc_throttle.c
ap.CFLAGS += -DERROR_LED=4
+16
View File
@@ -0,0 +1,16 @@
<!DOCTYPE settings SYSTEM "settings.dtd">
<!-- A conf to use for standard operation (no tuning) -->
<settings>
<dl_settings>
<dl_settings NAME="flight params">
</dl_settings>
<dl_settings NAME="mode">
<dl_setting MAX="2" MIN="0" STEP="1" VAR="pprz_mode" module="estimator" values="MANUAL|AUTO1|AUTO2|HOME|NOGPS|FAILSAFE">
</dl_setting>
</dl_settings>
</dl_settings>
</settings>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!DOCTYPE telemetry SYSTEM "telemetry.dtd">
<telemetry>
<process name="Ap">
<mode name="default">
<message name="ALIVE" period="5"/>
<message name="ACTUATORS" period="0.5"/>
<message name="COMMANDS" period="0.5"/>
<message name="RC" period="0.5"/>
<message name="PPM" period="0.5"/>
<message name="QUAD_STATUS" period="1.1"/>
<message name="DL_VALUE" period="1.5"/>
</mode>
<mode name="debug">
<message name="QUAD_STATUS" period="1.1"/>
</mode>
</process>
</telemetry>
+1 -1
View File
@@ -25,6 +25,6 @@ void csc_adc_periodic(void)
{
float v1 = adc0.sum / adc0.av_nb_sample / ADC_FACTOR;
float v2 = adc1.sum / adc1.av_nb_sample / ADC_FACTOR;
csc_ap_link_send_adc(v1, v2);
//csc_ap_link_send_adc(v1, v2);
}
+121
View File
@@ -0,0 +1,121 @@
/*
* $Id: booz2_main.c 3049 2009-02-24 16:51:25Z poine $
*
* Copyright (C) 2008 Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi 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 2, or (at your option)
* any later version.
*
* paparazzi 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 paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include <inttypes.h>
#include "csc_main.h"
#include "std.h"
#include "init_hw.h"
#include "sys_time.h"
#include "led.h"
#include "interrupt_hw.h"
#include "uart.h"
#include "downlink.h"
#include "periodic.h"
#include "airframe.h"
#include "commands.h"
#include "csc_servos.h"
#include "csc_telemetry.h"
#include "csc_adc.h"
#define CSC_STATUS_TIMEOUT (SYS_TICS_OF_SEC(0.25) / PERIODIC_TASK_PERIOD)
#define PPRZ_MODE_MANUAL 0
#define PPRZ_MODE_AUTO1 1
#define TRESHOLD_MANUAL_PPRZ (MIN_PPRZ / 2)
#define PPRZ_MODE_OF_RC(mode) ((mode) < TRESHOLD_MANUAL_PPRZ ? PPRZ_MODE_MANUAL : PPRZ_MODE_AUTO1)
uint8_t pprz_mode = PPRZ_MODE_AUTO1;
static uint16_t cpu_time = 0;
uint8_t vsupply;
int main( void ) {
csc_main_init();
while(1) {
if (sys_time_periodic())
csc_main_periodic();
csc_main_event();
}
return 0;
}
STATIC_INLINE void csc_main_init( void ) {
hw_init();
sys_time_init();
led_init();
Uart0Init();
Uart1Init();
csc_adc_init();
ppm_init();
csc_servos_init();
int_enable();
}
STATIC_INLINE void csc_main_periodic( void )
{
static uint32_t csc_loops = 0;
PeriodicSendAp();
radio_control_periodic_task();
if (rc_status == RC_REALLY_LOST) {
pprz_mode = PPRZ_MODE_AUTO1;
}
cpu_time++;
if ((++csc_loops % CSC_STATUS_TIMEOUT) == 0) {
csc_adc_periodic();
}
#ifdef ACTUATORS
SetActuatorsFromCommands(commands);
#endif
}
STATIC_INLINE void csc_main_event( void )
{
DatalinkEvent();
#ifdef RADIO_CONTROL
if (ppm_valid) {
ppm_valid = FALSE;
radio_control_event_task();
pprz_mode = PPRZ_MODE_OF_RC(rc_values[RADIO_MODE]);
if (pprz_mode == PPRZ_MODE_MANUAL)
SetCommandsFromRC(commands);
}
#endif
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef CSC_MAIN_H
#define CSC_MAIN_H
#ifdef SITL
#define STATIC_INLINE extern
#else
#define STATIC_INLINE static inline
#endif
STATIC_INLINE void csc_main_init( void );
STATIC_INLINE void csc_main_periodic( void );
STATIC_INLINE void csc_main_event( void );
#endif /* CSC_MAIN_H */
+28
View File
@@ -0,0 +1,28 @@
/*
* $Id: booz2_telemetry.c 3002 2009-02-10 11:36:07Z poine $
*
* Copyright (C) 2008 Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi 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 2, or (at your option)
* any later version.
*
* paparazzi 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 paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "csc_telemetry.h"
uint8_t telemetry_mode_Ap;
+50
View File
@@ -0,0 +1,50 @@
/*
* $Id: booz2_telemetry.c 3002 2009-02-10 11:36:07Z poine $
*
* Copyright (C) 2008 Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi 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 2, or (at your option)
* any later version.
*
* paparazzi 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 paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef CSC_TELEMETRY_H
#define CSC_TELEMETRY_H
#include "actuators.h"
#include "commands.h"
#include "settings.h"
#include "radio_control.h"
#define PERIODIC_SEND_DL_VALUE() PeriodicSendDlValue()
#define PERIODIC_SEND_ALIVE() DOWNLINK_SEND_ALIVE(16, MD5SUM)
#ifdef RADIO_CONTROL
#define PERIODIC_SEND_PPM() DOWNLINK_SEND_PPM(&last_ppm_cpt, PPM_NB_PULSES, ppm_pulses)
#define PERIODIC_SEND_RC() DOWNLINK_SEND_RC(PPM_NB_PULSES, rc_values)
#endif
#define PERIODIC_SEND_COMMANDS() DOWNLINK_SEND_COMMANDS(COMMANDS_NB, commands)
#define PERIODIC_SEND_ACTUATORS() DOWNLINK_SEND_ACTUATORS(SERVOS_NB, actuators)
#define PERIODIC_SEND_QUAD_STATUS() DOWNLINK_SEND_QUAD_STATUS(&rc_status, &pprz_mode, &vsupply, &cpu_time)
extern uint8_t telemetry_mode_Ap;
#endif