diff --git a/conf/autopilot/csc_ap.makefile b/conf/autopilot/csc_ap.makefile
index e083223006..f62114cf6c 100644
--- a/conf/autopilot/csc_ap.makefile
+++ b/conf/autopilot/csc_ap.makefile
@@ -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
diff --git a/conf/settings/csc_ap.xml b/conf/settings/csc_ap.xml
new file mode 100644
index 0000000000..10eaa303e8
--- /dev/null
+++ b/conf/settings/csc_ap.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/telemetry/csc_ap.xml b/conf/telemetry/csc_ap.xml
new file mode 100644
index 0000000000..41e23c191b
--- /dev/null
+++ b/conf/telemetry/csc_ap.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sw/airborne/csc/csc_adc.c b/sw/airborne/csc/csc_adc.c
index 4466cbd278..0c9a02968c 100644
--- a/sw/airborne/csc/csc_adc.c
+++ b/sw/airborne/csc/csc_adc.c
@@ -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);
}
diff --git a/sw/airborne/csc/csc_ap_main.c b/sw/airborne/csc/csc_ap_main.c
new file mode 100644
index 0000000000..9ea1c9177d
--- /dev/null
+++ b/sw/airborne/csc/csc_ap_main.c
@@ -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
+
+#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
+}
diff --git a/sw/airborne/csc/csc_ap_main.h b/sw/airborne/csc/csc_ap_main.h
new file mode 100644
index 0000000000..927819452f
--- /dev/null
+++ b/sw/airborne/csc/csc_ap_main.h
@@ -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 */
diff --git a/sw/airborne/csc/csc_telemetry.c b/sw/airborne/csc/csc_telemetry.c
new file mode 100644
index 0000000000..71deedd94f
--- /dev/null
+++ b/sw/airborne/csc/csc_telemetry.c
@@ -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;
diff --git a/sw/airborne/csc/csc_telemetry.h b/sw/airborne/csc/csc_telemetry.h
new file mode 100644
index 0000000000..96c15a1f16
--- /dev/null
+++ b/sw/airborne/csc/csc_telemetry.h
@@ -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