Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
servos_4015_MAT_hw.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2006 Antoine Drouin
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
28
#include "
subsystems/actuators.h
"
29
#include "
paparazzi.h
"
30
#include "generated/airframe.h"
31
32
uint8_t
servos_4015_idx
;
33
uint32_t
servos_delay
;
34
35
#define START_TIMEOUT 0xFFFF;
36
37
void
actuators_4015_init
(
void
)
38
{
39
/* select clock pin as MAT0.1 output */
40
IO0DIR
|= _BV(
SERVO_CLOCK_PIN
);
41
SERVO_CLOCK_PINSEL
|=
SERVO_CLOCK_PINSEL_VAL
<<
SERVO_CLOCK_PINSEL_BIT
;
42
43
/* select reset pin as GPIO output */
44
IO1DIR
|= _BV(
SERVO_RESET_PIN
);
45
PINSEL2
&= ~(_BV(3));
/* P1.25-16 are used as GPIO */
46
/* assert RESET */
47
IO1SET
= _BV(
SERVO_RESET_PIN
);
48
49
/* DATA pin output */
50
IO1DIR
|= _BV(
SERVO_DATA_PIN
);
51
52
/* enable match 1 interrupt */
53
T0MCR
|=
TMCR_MR1_I
;
54
55
/* lower clock */
56
T0EMR
&= ~
TEMR_EM1
;
57
/* set high on match 1 */
58
T0EMR
|=
TEMR_EMC1_2
;
59
60
/* set first pulse in a while */
61
T0MR1
=
START_TIMEOUT
;
62
servos_4015_idx
=
_4015_NB_CHANNELS
;
63
/* Set all servos at their midpoints */
64
/* compulsory for unaffected servos */
65
uint8_t
i;
66
for
(i = 0 ; i <
_4015_NB_CHANNELS
; i++) {
67
servos_values
[i] =
SERVOS_TICS_OF_USEC
(1500);
68
}
69
70
servos_delay
=
SERVO_REFRESH_TICS
;
71
}
72
73
74
uint16_t
servos_values
[
_4015_NB_CHANNELS
];
75
uint16_t
unsigned short uint16_t
Definition:
types.h:16
SERVO_DATA_PIN
#define SERVO_DATA_PIN
Definition:
tiny_0.99.h:50
servos_delay
uint32_t servos_delay
Definition:
servos_4015_MAT_hw.c:33
T0MCR
#define T0MCR
Definition:
LPC21xx.h:55
START_TIMEOUT
#define START_TIMEOUT
Definition:
servos_4015_MAT_hw.c:35
uint32_t
unsigned long uint32_t
Definition:
types.h:18
_4015_NB_CHANNELS
#define _4015_NB_CHANNELS
Definition:
servos_4015_hw.h:36
servos_4015_idx
uint8_t servos_4015_idx
Definition:
servos_4015_MAT_hw.c:32
paparazzi.h
SERVO_RESET_PIN
#define SERVO_RESET_PIN
Definition:
hb_1.1.h:34
TEMR_EMC1_2
#define TEMR_EMC1_2
Definition:
lpcTMR.h:159
TMCR_MR1_I
#define TMCR_MR1_I
Definition:
lpcTMR.h:62
T0MR1
#define T0MR1
Definition:
LPC21xx.h:57
SERVO_CLOCK_PINSEL
#define SERVO_CLOCK_PINSEL
Definition:
hb_1.1.h:30
actuators_4015_init
void actuators_4015_init(void)
Definition:
servos_4015_MAT_hw.c:37
SERVOS_TICS_OF_USEC
#define SERVOS_TICS_OF_USEC(s)
Definition:
actuators_pwm_arch.h:41
SERVO_CLOCK_PINSEL_VAL
#define SERVO_CLOCK_PINSEL_VAL
Definition:
hb_1.1.h:31
TEMR_EM1
#define TEMR_EM1
Definition:
lpcTMR.h:150
SERVO_CLOCK_PINSEL_BIT
#define SERVO_CLOCK_PINSEL_BIT
Definition:
hb_1.1.h:32
uint8_t
unsigned char uint8_t
Definition:
types.h:14
SERVO_CLOCK_PIN
#define SERVO_CLOCK_PIN
Definition:
hb_1.1.h:29
IO0DIR
#define IO0DIR
Definition:
LPC21xx.h:335
T0EMR
#define T0EMR
Definition:
LPC21xx.h:65
servos_values
uint16_t servos_values[_4015_NB_CHANNELS]
Definition:
servos_4015_MAT_hw.c:74
PINSEL2
#define PINSEL2
Definition:
LPC21xx.h:349
IO1SET
#define IO1SET
Definition:
LPC21xx.h:338
SERVO_REFRESH_TICS
#define SERVO_REFRESH_TICS
Definition:
servos_4015_hw.c:98
IO1DIR
#define IO1DIR
Definition:
LPC21xx.h:339
actuators.h
sw
airborne
arch
lpc21
subsystems
actuators
servos_4015_MAT_hw.c
Generated on Tue Feb 1 2022 13:51:13 for Paparazzi UAS by
1.8.17