[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [6069] start working on unified radio control
From: |
Gautier Hattenberger |
Subject: |
[paparazzi-commits] [6069] start working on unified radio control |
Date: |
Tue, 05 Oct 2010 18:29:57 +0000 |
Revision: 6069
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6069
Author: gautier
Date: 2010-10-05 18:29:56 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
start working on unified radio control
Added Paths:
-----------
paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/
paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.c
paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.h
paparazzi3/trunk/sw/airborne/radio_control/
paparazzi3/trunk/sw/airborne/radio_control/ppm.c
paparazzi3/trunk/sw/airborne/radio_control/ppm.h
Added: paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.c
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.c
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.c
2010-10-05 18:29:56 UTC (rev 6069)
@@ -0,0 +1,43 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 The Paparazzi Team
+ *
+ * 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 "radio_control.h"
+
+uint8_t ppm_cur_pulse;
+uint32_t ppm_last_pulse_time;
+
+void ppm_arch_init ( void ) {
+ /* select pin for capture */
+ PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT;
+ /* enable capture 0.2 on falling or rising edge + trigger interrupt */
+#if defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_POSITIVE
+ T0CCR = PPM_CCR_CRR | PPM_CCR_CRI;
+#elif defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_NEGATIVE
+ T0CCR = PPM_CCR_CRF | PPM_CCR_CRI;
+#else
+#error "ppm_hw.h: Unknown PM_PULSE_TYPE"
+#endif
+ ppm_last_pulse_time = 0;
+ ppm_cur_pulse = RADIO_CONTROL_NB_CHANNEL;
+ ppm_frame_available = FALSE;
+}
Added: paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.h
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.h
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/lpc21/radio_control/ppm_arch.h
2010-10-05 18:29:56 UTC (rev 6069)
@@ -0,0 +1,89 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 The Paparazzi Team
+ *
+ * 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 PPM_ARCH_H
+#define PPM_ARCH_H
+
+
+#include "LPC21xx.h"
+#include BOARD_CONFIG
+
+/**
+ * On tiny (and booz) the ppm counter is running at the same speed as
+ * the systic counter. There is no reason for this to be true.
+ * Let's add a pair of macros to make it possible for them to be different.
+ *
+ */
+#define RC_PPM_TICS_OF_USEC SYS_TICS_OF_USEC
+#define RC_PPM_SIGNED_TICS_OF_USEC SIGNED_SYS_TICS_OF_USEC
+
+#define PPM_NB_CHANNEL RADIO_CONTROL_NB_CHANNEL
+
+extern uint8_t ppm_cur_pulse;
+extern uint32_t ppm_last_pulse_time;
+
+/**
+ * A valid ppm frame:
+ * - synchro blank
+ * - correct number of channels
+ * - synchro blank
+ */
+#define PPM_IT PPM_CRI
+#define PPM_ISR() { \
+ static uint8_t ppm_data_valid = FALSE; \
+ \
+ uint32_t now = PPM_CR; \
+ uint32_t length = now - ppm_last_pulse_time;
\
+ ppm_last_pulse_time = now;
\
+ \
+ if (ppm_cur_pulse == PPM_NB_CHANNEL) { \
+ if (length > SYS_TICS_OF_USEC(PPM_SYNC_MIN_LEN) && \
+ length < SYS_TICS_OF_USEC(PPM_SYNC_MAX_LEN)) { \
+ if (ppm_data_valid) { \
+ ppm_frame_available = TRUE; \
+ ppm_data_valid = FALSE; \
+ } \
+ ppm_cur_pulse = 0; \
+ } \
+ else { \
+ ppm_data_valid = FALSE; \
+ } \
+ } \
+ else { \
+ if (length > SYS_TICS_OF_USEC(PPM_DATA_MIN_LEN) && \
+ length < SYS_TICS_OF_USEC(PPM_DATA_MAX_LEN)) { \
+ ppm_pulses[ppm_cur_pulse] = length; \
+ ppm_cur_pulse++; \
+ if (ppm_cur_pulse == PPM_NB_CHANNEL) { \
+ ppm_data_valid = TRUE; \
+ } \
+ } \
+ else { \
+ ppm_cur_pulse = PPM_NB_CHANNEL;
\
+ ppm_data_valid = FALSE; \
+ } \
+ } \
+}
+
+
+#endif /* PPM_ARCH_H */
Added: paparazzi3/trunk/sw/airborne/radio_control/ppm.c
===================================================================
--- paparazzi3/trunk/sw/airborne/radio_control/ppm.c
(rev 0)
+++ paparazzi3/trunk/sw/airborne/radio_control/ppm.c 2010-10-05 18:29:56 UTC
(rev 6069)
@@ -0,0 +1,34 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 The Paparazzi Team
+ *
+ * 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 "radio_control.h"
+
+
+uint16_t ppm_pulses[ RADIO_CONTROL_NB_CHANNEL ];
+volatile bool_t ppm_frame_available;
+
+void radio_control_impl_init(void) {
+ ppm_frame_available = FALSE;
+ ppm_arch_init();
+}
+
Added: paparazzi3/trunk/sw/airborne/radio_control/ppm.h
===================================================================
--- paparazzi3/trunk/sw/airborne/radio_control/ppm.h
(rev 0)
+++ paparazzi3/trunk/sw/airborne/radio_control/ppm.h 2010-10-05 18:29:56 UTC
(rev 6069)
@@ -0,0 +1,64 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 The Paparazzi Team
+ *
+ * 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 PPM_H
+#define PPM_H
+
+/**
+ * Architecture dependant code
+ */
+#include "radio_control/ppm_arch.h"
+/* must be implemented by arch dependant code */
+extern void ppm_arch_init ( void );
+
+/**
+ * Generated code holding the description of a given
+ * transmitter
+ */
+#include "radio.h"
+
+/**
+ * ppm pulse type : futaba is falling edge clocked whereas JR is rising edge
+ */
+#define PPM_PULSE_TYPE_POSITIVE 0
+#define PPM_PULSE_TYPE_NEGATIVE 1
+
+extern uint16_t ppm_pulses[ RADIO_CONTROL_NB_CHANNEL ];
+extern volatile bool_t ppm_frame_available;
+
+
+#define RadioControlEvent(_received_frame_handler) { \
+ if (ppm_frame_available) { \
+ radio_control.frame_cpt++; \
+ radio_control.time_since_last_frame = 0; \
+ if (radio_control.radio_ok_cpt > 0) radio_control.radio_ok_cpt--; \
+ else { \
+ radio_control.status = RADIO_CONTROL_OK; \
+ NormalizePpm();
\
+ _received_frame_handler(); \
+ }
\
+ ppm_frame_available = FALSE; \
+ } \
+ }
+
+#endif /* PPM_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [6069] start working on unified radio control,
Gautier Hattenberger <=