paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [6233] add a generic trigger on external event


From: Gautier Hattenberger
Subject: [paparazzi-commits] [6233] add a generic trigger on external event
Date: Mon, 25 Oct 2010 15:01:42 +0000

Revision: 6233
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6233
Author:   gautier
Date:     2010-10-25 15:01:42 +0000 (Mon, 25 Oct 2010)
Log Message:
-----------
add a generic trigger on external event

Added Paths:
-----------
    paparazzi3/trunk/conf/modules/trig_test.xml
    paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/
    paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.c
    paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.h
    paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.c
    paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.h

Added: paparazzi3/trunk/conf/modules/trig_test.xml
===================================================================
--- paparazzi3/trunk/conf/modules/trig_test.xml                         (rev 0)
+++ paparazzi3/trunk/conf/modules/trig_test.xml 2010-10-25 15:01:42 UTC (rev 
6233)
@@ -0,0 +1,15 @@
+<!DOCTYPE module SYSTEM "module.dtd">
+
+<module name="trigger_ext" dir="core">
+  <header>
+    <file name="trigger_ext.h"/>
+  </header>
+  <init fun="trigger_ext_init()"/>
+  <makefile target="ap">
+    <file_hw name="trigger_ext_hw.c"/>
+    <file name="trigger_ext.c"/>
+    <flag name="TRIGGER_EXT"/>
+    <flag name="TRIG_EXT_PULSE_TYPE" value="TRIG_EXT_EDGE_FALLING"/>
+  </makefile>
+</module>
+

Copied: paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.c 
(from rev 6200, 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/trig_ext_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.c       
                        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.c       
2010-10-25 15:01:42 UTC (rev 6233)
@@ -0,0 +1,57 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2010 Martin Mueller
+ *
+ * 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 "core/trigger_ext_hw.h"
+#include "std.h"
+#include "sys_time_hw.h"
+#include "LPC21xx.h"
+#include BOARD_CONFIG
+
+void TRIG_ISR() {
+  static uint32_t last;
+  uint32_t delta_t0_temp;
+  trigger_t0 = TRIGGER_CR;
+  delta_t0_temp = trigger_t0 - last;
+  if (MSEC_OF_SYS_TICS(delta_t0_temp) > 10) {
+    delta_t0 = delta_t0_temp;
+    last = trigger_t0;
+    trig_ext_valid = TRUE;
+  }
+}
+
+void trigger_ext_init ( void ) {
+  /* select pin for capture */
+  TRIG_EXT_PINSEL |= TRIG_EXT_PINSEL_VAL << TRIG_EXT_PINSEL_BIT;
+  /* enable capture 0.2 on falling or rising edge + trigger interrupt */
+#if defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == 
TRIG_EXT_PULSE_TYPE_RISING
+  T0CCR = TRIGGER_CRR | TRIGGER_CRI;
+#elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == 
TRIG_EXT_PULSE_TYPE_FALLING
+  T0CCR = TRIGGER_CRF | TRIGGER_CRI;
+#else
+#error "trig_ext_hw.h: Unknown PULSE_TYPE"
+#endif
+  trig_ext_valid = FALSE;
+}
+

Copied: paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.h 
(from rev 6200, 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/trig_ext_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.h       
                        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/lpc21/modules/core/trigger_ext_hw.h       
2010-10-25 15:01:42 UTC (rev 6233)
@@ -0,0 +1,74 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2010 Martin Mueller
+ *
+ * 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 TRIGGER_EXT_HW_H
+#define TRIGGER_EXT_HW_H
+
+#include "core/trigger_ext.h"
+
+// Default trigger Pin is PPM pin (Tiny2/Twog)
+// To use a custom trigger, you must set the flag USE_CUSTOM_TRIGGER
+// and define:
+// - PINSEL
+// - PINSEL_VAL
+// - PINSEL_BIT
+// - input capture CHANNEL
+#ifndef USE_CUSTOM_TRIGGER
+#define TRIG_EXT_PINSEL     PPM_PINSEL
+#define TRIG_EXT_PINSEL_VAL PPM_PINSEL_VAL
+#define TRIG_EXT_PINSEL_BIT PPM_PINSEL_BIT
+#define TRIG_EXT_CHANNEL    2
+#endif
+
+#define __SelectCapReg(_c) T0CR ## _c
+#define _SelectCapReg(_c) __SelectCapReg(_c)
+#define SelectCapReg(_c) _SelectCapReg(_c)
+
+#define __SetIntFlag(_c) TIR_CR ## _c ## I
+#define _SetIntFlag(_c) __SetIntFlag(_c)
+#define SetIntFlag(_c) _SetIntFlag(_c)
+
+#define __EnableRise(_c) TCCR_CR ## _c ## _R
+#define _EnableRise(_c) __EnableRise(_c)
+#define EnableRise(_c) _EnableRise(_c)
+
+#define __EnableFall(_c) TCCR_CR ## _c ## _F
+#define _EnableFall(_c) __EnableFall(_c)
+#define EnableFall(_c) _EnableFall(_c)
+
+#define __EnableInt(_c) TCCR_CR ## _c ## _I
+#define _EnableInt(_c) __EnableInt(_c)
+#define EnableInt(_c) _EnableInt(_c)
+
+#define TRIGGER_CR SelectCapReg(TRIG_EXT_CHANNEL)
+#define TRIGGER_IT SetIntFlag(TRIG_EXT_CHANNEL)
+#define TRIGGER_CRR EnableRise(TRIG_EXT_CHANNEL)
+#define TRIGGER_CRF EnableFall(TRIG_EXT_CHANNEL)
+#define TRIGGER_CRI EnableInt(TRIG_EXT_CHANNEL)
+
+/* Interrupt function called by sys_time_hw.c */
+void TRIG_ISR(void);
+
+#endif /* TRIGGER_EXT_HW_H */
+

Copied: paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.c (from rev 6200, 
paparazzi3/trunk/sw/airborne/modules/sensors/trigger_ext.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.c                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.c     2010-10-25 
15:01:42 UTC (rev 6233)
@@ -0,0 +1,37 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2010 Martin Mueller
+ *
+ * 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. 
+ *
+ */
+
+/** \file trigger_ext.c
+ *  \brief Measure external trigger pulse at PPM input (default)
+ *
+ *   This measures a trigger pulse length
+ */
+
+
+#include "core/trigger_ext.h"
+
+uint32_t trigger_t0;
+uint32_t delta_t0;
+volatile bool_t trig_ext_valid;
+

Copied: paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.h (from rev 6200, 
paparazzi3/trunk/sw/airborne/modules/sensors/trigger_ext.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.h                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/core/trigger_ext.h     2010-10-25 
15:01:42 UTC (rev 6233)
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2010 Martin Mueller
+ *
+ * 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. 
+ *
+ */
+
+/** \file trigger_ext.h
+ *  \brief Measure external trigger pulse at PPM input (default)
+ *
+ *   This measures a trigger pulse length
+ */
+
+#ifndef TRIGGER_EXT_H
+#define TRIGGER_EXT_H
+
+#include "std.h"
+
+/**
+ *  falling/rising edge
+ */
+#define TRIG_EXT_EDGE_RISING 1
+#define TRIG_EXT_EDGE_FALLING 0
+
+extern uint32_t trigger_t0;
+extern uint32_t delta_t0;
+extern volatile bool_t trig_ext_valid;
+
+void trigger_ext_init ( void );
+
+#endif
+
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]