Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
trigger_ext_hw.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2010 Martin Mueller
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
25 
26 #include "core/trigger_ext_hw.h"
27 #include "std.h"
28 #include "mcu_periph/sys_time.hw.h"
29 #include "LPC21xx.h"
30 #include BOARD_CONFIG
31 
32 void TRIG_ISR() {
33  static uint32_t last;
34  uint32_t delta_t0_temp;
36  delta_t0_temp = trigger_t0 - last;
37  if (MSEC_OF_CPU_TICKS(delta_t0_temp) > 10) {
38  trigger_delta_t0 = delta_t0_temp;
39  last = trigger_t0;
41  }
42 }
43 
44 void trigger_ext_init ( void ) {
45  /* select pin for capture */
47  /* enable capture 0.2 on falling or rising edge + trigger interrupt */
48 #if defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_RISING
50 #elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING
52 #else
53 #error "trig_ext_hw.h: Unknown PULSE_TYPE"
54 #endif
56 }
57 
#define T0CCR
Definition: LPC21xx.h:60
#define TRIG_EXT_PINSEL
#define TRIGGER_CR
volatile bool_t trigger_ext_valid
Definition: trigger_ext.c:36
#define FALSE
Definition: imu_chimu.h:141
unsigned long uint32_t
Definition: types.h:18
#define TRIGGER_CRR
#define TRIGGER_CRI
#define TRUE
Definition: imu_chimu.h:144
#define TRIG_EXT_PINSEL_VAL
void TRIG_ISR()
#define TRIGGER_CRF
void trigger_ext_init(void)
uint32_t trigger_delta_t0
Definition: trigger_ext.c:35
uint32_t trigger_t0
Definition: trig_ext_hw.c:8
#define MSEC_OF_CPU_TICKS(t)
Definition: sys_time_arch.h:65
#define TRIG_EXT_PINSEL_BIT