Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
actuators_pwm_arch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 The Paparazzi Team
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 #ifndef ACTUATORS_PWM_ARCH_H
23 #define ACTUATORS_PWM_ARCH_H
24 
25 #include "LPC21xx.h"
26 #include "mcu_periph/sys_time.h"
27 
28 
29 /*
30  wiring on classix PWM connector
31 connector LPC shared port
32 PWM1 PWM5 AD1_6 CAP1_3 P0.21
33 PWM2 PWM3 RXD0 EINT0 P0.1
34 PWM3 PWM1 TXD0 P0.0
35 PWM4 PWM6 RXD1 EINT3 P0.9
36 PWM5 PWM4 TXD1 AD1_1 P0.8
37 PWM6 PWM2 SSEL0 EINT2 P0.7
38 
39 */
40 
41 #define SERVOS_TICS_OF_USEC(s) cpu_ticks_of_usec(s)
42 
43 /* default definition of servo (from classix order) */
44 #ifndef SERVO_REG_0
45 #define SERVO_REG_0 PWMMR5
46 #endif
47 #ifndef SERVO_REG_1
48 #define SERVO_REG_1 PWMMR3
49 #endif
50 #ifndef SERVO_REG_2
51 #define SERVO_REG_2 PWMMR1
52 #endif
53 #ifndef SERVO_REG_3
54 #define SERVO_REG_3 PWMMR6
55 #endif
56 #ifndef SERVO_REG_4
57 #define SERVO_REG_4 PWMMR4
58 #endif
59 #ifndef SERVO_REG_5
60 #define SERVO_REG_5 PWMMR2
61 #endif
62 
63 #define COMMAND_(i) SERVO_REG_ ## i
64 
65 #define ActuatorPwmSet(_i, _v) { COMMAND_(_i) = SERVOS_TICS_OF_USEC(_v); }
66 
67 #define PWM_PINSEL_MASK_VAL 3
68 
69 #define PWM_SERVO_1_PINSEL PINSEL0
70 #define PWM_SERVO_1_PINSEL_VAL 2
71 #define PWM_SERVO_1_PINSEL_BIT 0
72 #define PWM_SERVO_1_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_1_PINSEL_BIT)
73 #define PWM_SERVO_1_ENA PWMPCR_ENA1
74 #define PWM_SERVO_1_LATCH PWMLER_LATCH1
75 
76 #define PWM_SERVO_2_PINSEL PINSEL0
77 #define PWM_SERVO_2_PINSEL_VAL 2
78 #define PWM_SERVO_2_PINSEL_BIT 14
79 #define PWM_SERVO_2_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_2_PINSEL_BIT)
80 #define PWM_SERVO_2_ENA PWMPCR_ENA2
81 #define PWM_SERVO_2_LATCH PWMLER_LATCH2
82 
83 #define PWM_SERVO_3_PINSEL PINSEL0
84 #define PWM_SERVO_3_PINSEL_VAL 2
85 #define PWM_SERVO_3_PINSEL_BIT 2
86 #define PWM_SERVO_3_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_3_PINSEL_BIT)
87 #define PWM_SERVO_3_ENA PWMPCR_ENA3
88 #define PWM_SERVO_3_LATCH PWMLER_LATCH3
89 
90 #define PWM_SERVO_4_PINSEL PINSEL0
91 #define PWM_SERVO_4_PINSEL_VAL 2
92 #define PWM_SERVO_4_PINSEL_BIT 16
93 #define PWM_SERVO_4_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_4_PINSEL_BIT)
94 #define PWM_SERVO_4_ENA PWMPCR_ENA4
95 #define PWM_SERVO_4_LATCH PWMLER_LATCH4
96 
97 #define PWM_SERVO_5_PINSEL PINSEL1
98 #define PWM_SERVO_5_PINSEL_VAL 1
99 #define PWM_SERVO_5_PINSEL_BIT 10
100 #define PWM_SERVO_5_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_5_PINSEL_BIT)
101 #define PWM_SERVO_5_ENA PWMPCR_ENA5
102 #define PWM_SERVO_5_LATCH PWMLER_LATCH5
103 
104 #define PWM_SERVO_6_PINSEL PINSEL0
105 #define PWM_SERVO_6_PINSEL_VAL 2
106 #define PWM_SERVO_6_PINSEL_BIT 18
107 #define PWM_SERVO_6_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_6_PINSEL_BIT)
108 #define PWM_SERVO_6_ENA PWMPCR_ENA6
109 #define PWM_SERVO_6_LATCH PWMLER_LATCH6
110 
111 extern const uint8_t pwm_latch_value;
112 
114 #define ActuatorsPwmCommit() { \
115  PWMLER = pwm_latch_value; \
116  }
117 
118 #endif /* ACTUATORS_PWM_ARCH_H */
const uint8_t pwm_latch_value
Architecture independent timing functions.
unsigned char uint8_t
Definition: types.h:14