Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
trigger_ext_hw.c
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 
24 #include "core/trigger_ext_hw.h"
25 #include "std.h"
26 #include "mcu_periph/sys_time.h"
27 #include "LPC21xx.h"
28 #include BOARD_CONFIG
29 
30 void TRIG_ISR()
31 {
32  static uint32_t last;
33  uint32_t delta_t0_temp;
35  delta_t0_temp = trigger_t0 - last;
36  if (msec_of_cpu_ticks(delta_t0_temp) > 10) {
37  trigger_delta_t0 = delta_t0_temp;
38  last = trigger_t0;
39  trigger_ext_valid = true;
40  }
41 }
42 
43 void trigger_ext_init(void)
44 {
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
55  trigger_ext_valid = false;
56 }
57 
last
uint32_t last
Definition: rng_arch.c:31
T0CCR
#define T0CCR
Definition: LPC21xx.h:60
trigger_t0
uint32_t trigger_t0
Definition: trig_ext_hw.c:8
LPC21xx.h
TRIGGER_CRR
#define TRIGGER_CRR
Definition: trigger_ext_hw.h:64
TRIGGER_CRF
#define TRIGGER_CRF
Definition: trigger_ext_hw.h:65
uint32_t
unsigned long uint32_t
Definition: types.h:18
TRIG_EXT_PINSEL_VAL
#define TRIG_EXT_PINSEL_VAL
Definition: trigger_ext_hw.h:37
trigger_ext_valid
volatile bool trigger_ext_valid
Definition: trigger_ext.c:35
TRIG_EXT_PINSEL_BIT
#define TRIG_EXT_PINSEL_BIT
Definition: trigger_ext_hw.h:38
std.h
TRIG_ISR
void TRIG_ISR()
Definition: trigger_ext_hw.c:30
TRIGGER_CRI
#define TRIGGER_CRI
Definition: trigger_ext_hw.h:66
TRIG_EXT_PINSEL
#define TRIG_EXT_PINSEL
Definition: trigger_ext_hw.h:36
TRIGGER_CR
#define TRIGGER_CR
Definition: trigger_ext_hw.h:62
sys_time.h
Architecture independent timing functions.
trigger_delta_t0
uint32_t trigger_delta_t0
Definition: trigger_ext.c:34
trigger_ext_init
void trigger_ext_init(void)
Definition: trigger_ext_hw.c:43
msec_of_cpu_ticks
static uint32_t msec_of_cpu_ticks(uint32_t cpu_ticks)
Definition: sys_time.h:193