Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
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
servos_ppm_hw.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2008 Mark Griffin
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
31
#ifndef SERVOS_PPM_HW_H
32
#define SERVOS_PPM_HW_H
33
34
#include "
std.h
"
35
#include "
LPC21xx.h
"
36
#include "
mcu_periph/sys_time.h
"
37
38
#include BOARD_CONFIG
39
40
#define SERVOS_TICS_OF_USEC(s) cpu_ticks_of_usec(s)
41
#define ChopServo(x,a,b) Chop(x, a, b)
42
43
#define _PPM_NB_CHANNELS 8
44
extern
uint16_t
servos_values
[
_PPM_NB_CHANNELS
];
45
#define ActuatorPpmSet(_i, _v) { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
46
47
extern
void
actuators_ppm_init
(
void
);
48
#define ActuatorsPpmCommit() {}
49
#define ActuatorsPpmInit() actuators_ppm_init()
50
extern
uint8_t
servos_PPM_idx
;
51
extern
uint32_t
servos_delay
;
52
extern
uint8_t
ppm_pulse
;
/* 1=start of pulse, 0=end of pulse */
53
54
/* define the ppm frame rate. 22msec is typical for JR/Graupner */
55
#define SERVO_REFRESH_TICS SERVOS_TICS_OF_USEC(22000)
56
/* define the ppm pulse width. 550usec is typical for JR/Graupner */
57
#define PPM_WIDTH SERVOS_TICS_OF_USEC(550)
58
59
#define ACTUATORS_IT TIR_MR1I
60
#define ServosPPMMat_ISR() { \
61
if (servos_PPM_idx == 0) { \
62
servos_delay = SERVO_REFRESH_TICS; \
63
} \
64
if (servos_PPM_idx < _PPM_NB_CHANNELS ) { \
65
if (ppm_pulse) { \
66
T0MR1 += PPM_WIDTH; \
67
servos_delay -= PPM_WIDTH; \
68
} else { \
69
T0MR1 += servos_values[servos_PPM_idx] - PPM_WIDTH; \
70
servos_delay -= servos_values[servos_PPM_idx] - PPM_WIDTH; \
71
servos_PPM_idx++; \
72
} \
73
} else {
/* servos_PPM_idx=_PPM_NB_CHANNELS */
\
74
if (ppm_pulse) { \
75
T0MR1 += PPM_WIDTH; \
76
servos_delay -= PPM_WIDTH; \
77
} else { \
78
servos_PPM_idx = 0; \
79
T0MR1 += servos_delay - PPM_WIDTH; \
80
} \
81
} \
82
if (!ppm_pulse) { \
83
/* lower clock pin */
\
84
T0EMR &= ~TEMR_EM1; \
85
} \
86
/* toggle ppm_pulse flag */
\
87
ppm_pulse ^= 1; \
88
}
89
#endif
/* SERVOS_PPM_HW_H */
uint16_t
unsigned short uint16_t
Definition:
types.h:16
servos_delay
uint32_t servos_delay
Definition:
servos_4015_MAT_hw.c:33
sys_time.h
Architecture independent timing functions.
servos_PPM_idx
uint8_t servos_PPM_idx
Definition:
servos_ppm_hw.c:35
uint32_t
unsigned long uint32_t
Definition:
types.h:18
servos_values
uint16_t servos_values[_PPM_NB_CHANNELS]
Definition:
servos_4015_hw.c:29
std.h
uint8_t
unsigned char uint8_t
Definition:
types.h:14
LPC21xx.h
_PPM_NB_CHANNELS
#define _PPM_NB_CHANNELS
Definition:
servos_ppm_hw.h:43
actuators_ppm_init
void actuators_ppm_init(void)
Definition:
servos_ppm_hw.c:41
ppm_pulse
uint8_t ppm_pulse
Definition:
servos_ppm_hw.c:36
sw
airborne
arch
lpc21
subsystems
actuators
servos_ppm_hw.h
Generated on Wed Aug 28 2019 16:28:54 for Paparazzi UAS by
1.8.8