Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
trig_ext_hw.c
Go to the documentation of this file.
1 
2 #include "std.h"
3 #include "mcu_periph/sys_time.h"
4 #include "LPC21xx.h"
5 #include "trig_ext_hw.h"
6 #include BOARD_CONFIG
7 
10 volatile bool trig_ext_valid;
11 
12 
13 void TRIG_ISR()
14 {
15  static uint32_t last;
16  uint32_t delta_t0_temp;
18  delta_t0_temp = trigger_t0 - last;
19  if (msec_of_cpu_ticks(delta_t0_temp) > 10) {
20  delta_t0 = delta_t0_temp;
21  last = trigger_t0;
22  trig_ext_valid = true;
23  }
24 }
25 
26 void trig_ext_init(void)
27 {
28  /* select pin for capture */
30  /* enable capture 0.2 on falling or rising edge + trigger interrupt */
31 #if defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_RISING
33 #elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING
35 #else
36 #error "trig_ext_hw.h: Unknown PULSE_TYPE"
37 #endif
38  trig_ext_valid = false;
39 }
40 
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
PPM_PINSEL_VAL
#define PPM_PINSEL_VAL
Definition: booz_1.0.h:51
uint32_t
unsigned long uint32_t
Definition: types.h:18
delta_t0
uint32_t delta_t0
Definition: trig_ext_hw.c:9
PPM_CR
#define PPM_CR
Definition: booz_1.0.h:57
trig_ext_hw.h
std.h
TRIG_ISR
void TRIG_ISR()
Definition: trig_ext_hw.c:13
trig_ext_valid
volatile bool trig_ext_valid
Definition: trig_ext_hw.c:10
sys_time.h
Architecture independent timing functions.
PPM_PINSEL_BIT
#define PPM_PINSEL_BIT
Definition: booz_1.0.h:52
msec_of_cpu_ticks
static uint32_t msec_of_cpu_ticks(uint32_t cpu_ticks)
Definition: sys_time.h:193
PPM_CCR_CRR
#define PPM_CCR_CRR
Definition: booz_1.0.h:55
PPM_PINSEL
#define PPM_PINSEL
Definition: booz_1.0.h:50
trig_ext_init
void trig_ext_init(void)
Definition: trig_ext_hw.c:26
PPM_CCR_CRI
#define PPM_CCR_CRI
Definition: booz_1.0.h:56
PPM_CCR_CRF
#define PPM_CCR_CRF
Definition: booz_1.0.h:54