Paparazzi UAS
v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
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
8
uint32_t
trigger_t0
;
9
uint32_t
delta_t0
;
10
volatile
bool_t
trig_ext_valid
;
11
12
13
void
TRIG_ISR
()
14
{
15
static
uint32_t
last;
16
uint32_t
delta_t0_temp;
17
trigger_t0
=
PPM_CR
;
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 */
29
PPM_PINSEL
|=
PPM_PINSEL_VAL
<<
PPM_PINSEL_BIT
;
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
32
T0CCR
|=
PPM_CCR_CRR
|
PPM_CCR_CRI
;
33
#elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING
34
T0CCR
|=
PPM_CCR_CRF
|
PPM_CCR_CRI
;
35
#else
36
#error "trig_ext_hw.h: Unknown PULSE_TYPE"
37
#endif
38
trig_ext_valid
=
FALSE
;
39
}
40
msec_of_cpu_ticks
static uint32_t msec_of_cpu_ticks(uint32_t cpu_ticks)
Definition:
sys_time.h:188
T0CCR
#define T0CCR
Definition:
LPC21xx.h:60
PPM_PINSEL_VAL
#define PPM_PINSEL_VAL
Definition:
booz_1.0.h:51
PPM_PINSEL
#define PPM_PINSEL
Definition:
booz_1.0.h:50
trig_ext_valid
volatile bool_t trig_ext_valid
Definition:
trig_ext_hw.c:10
PPM_CCR_CRI
#define PPM_CCR_CRI
Definition:
booz_1.0.h:56
FALSE
#define FALSE
Definition:
std.h:5
delta_t0
uint32_t delta_t0
Definition:
trig_ext_hw.c:9
TRUE
#define TRUE
Definition:
std.h:4
PPM_CR
#define PPM_CR
Definition:
booz_1.0.h:57
sys_time.h
Architecture independent timing functions.
PPM_PINSEL_BIT
#define PPM_PINSEL_BIT
Definition:
booz_1.0.h:52
uint32_t
unsigned long uint32_t
Definition:
types.h:18
std.h
TRIG_ISR
void TRIG_ISR()
Definition:
trig_ext_hw.c:13
PPM_CCR_CRR
#define PPM_CCR_CRR
Definition:
booz_1.0.h:55
trig_ext_init
void trig_ext_init(void)
Definition:
trig_ext_hw.c:26
LPC21xx.h
trigger_t0
uint32_t trigger_t0
Definition:
trig_ext_hw.c:8
trig_ext_hw.h
PPM_CCR_CRF
#define PPM_CCR_CRF
Definition:
booz_1.0.h:54
sw
airborne
arch
lpc21
modules
sensors
trig_ext_hw.c
Generated on Tue Jun 21 2016 14:01:10 for Paparazzi UAS by
1.8.8