Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
trigger_ext_hw.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Martin Mueller
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
23 #ifndef TRIGGER_EXT_HW_H
24 #define TRIGGER_EXT_HW_H
25 
26 #include "core/trigger_ext.h"
27 
28 // Default trigger Pin is PPM pin (Tiny2/Twog)
29 // To use a custom trigger, you must set the flag USE_CUSTOM_TRIGGER
30 // and define:
31 // - PINSEL
32 // - PINSEL_VAL
33 // - PINSEL_BIT
34 // - input capture CHANNEL
35 #ifndef USE_CUSTOM_TRIGGER
36 #define TRIG_EXT_PINSEL PPM_PINSEL
37 #define TRIG_EXT_PINSEL_VAL PPM_PINSEL_VAL
38 #define TRIG_EXT_PINSEL_BIT PPM_PINSEL_BIT
39 #define TRIG_EXT_CHANNEL 2
40 #endif
41 
42 #define __SelectCapReg(_c) T0CR ## _c
43 #define _SelectCapReg(_c) __SelectCapReg(_c)
44 #define SelectCapReg(_c) _SelectCapReg(_c)
45 
46 #define __SetIntFlag(_c) TIR_CR ## _c ## I
47 #define _SetIntFlag(_c) __SetIntFlag(_c)
48 #define SetIntFlag(_c) _SetIntFlag(_c)
49 
50 #define __EnableRise(_c) TCCR_CR ## _c ## _R
51 #define _EnableRise(_c) __EnableRise(_c)
52 #define EnableRise(_c) _EnableRise(_c)
53 
54 #define __EnableFall(_c) TCCR_CR ## _c ## _F
55 #define _EnableFall(_c) __EnableFall(_c)
56 #define EnableFall(_c) _EnableFall(_c)
57 
58 #define __EnableInt(_c) TCCR_CR ## _c ## _I
59 #define _EnableInt(_c) __EnableInt(_c)
60 #define EnableInt(_c) _EnableInt(_c)
61 
62 #define TRIGGER_CR SelectCapReg(TRIG_EXT_CHANNEL)
63 #define TRIGGER_IT SetIntFlag(TRIG_EXT_CHANNEL)
64 #define TRIGGER_CRR EnableRise(TRIG_EXT_CHANNEL)
65 #define TRIGGER_CRF EnableFall(TRIG_EXT_CHANNEL)
66 #define TRIGGER_CRI EnableInt(TRIG_EXT_CHANNEL)
67 
68 /* Interrupt function called by sys_time_hw.c */
69 void TRIG_ISR(void);
70 
71 #endif /* TRIGGER_EXT_HW_H */
72 
void TRIG_ISR(void)
Measure external trigger pulse at PPM input (default).