Paparazzi UAS  v5.15_devel-113-g1b57ff1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
static uint32_t msec_of_cpu_ticks(uint32_t cpu_ticks)
Definition: sys_time.h:193
#define T0CCR
Definition: LPC21xx.h:60
#define PPM_PINSEL_VAL
Definition: booz_1.0.h:51
#define PPM_PINSEL
Definition: booz_1.0.h:50
#define PPM_CCR_CRI
Definition: booz_1.0.h:56
volatile bool trig_ext_valid
Definition: trig_ext_hw.c:10
uint32_t delta_t0
Definition: trig_ext_hw.c:9
#define PPM_CR
Definition: booz_1.0.h:57
Architecture independent timing functions.
#define PPM_PINSEL_BIT
Definition: booz_1.0.h:52
unsigned long uint32_t
Definition: types.h:18
void TRIG_ISR()
Definition: trig_ext_hw.c:13
uint32_t last
Definition: rng_arch.c:31
#define PPM_CCR_CRR
Definition: booz_1.0.h:55
void trig_ext_init(void)
Definition: trig_ext_hw.c:26
uint32_t trigger_t0
Definition: trig_ext_hw.c:8
#define PPM_CCR_CRF
Definition: booz_1.0.h:54