Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
servos_4015_MAT_hw.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2006 Antoine Drouin
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
30 #include "actuators.h"
31 #include "paparazzi.h"
32 #include "generated/airframe.h"
33 
36 
37 #define START_TIMEOUT 0xFFFF;
38 
39 void actuators_init ( void ) {
40  /* select clock pin as MAT0.1 output */
41  IO0DIR |= _BV(SERVO_CLOCK_PIN);
43 
44  /* select reset pin as GPIO output */
45  IO1DIR |= _BV(SERVO_RESET_PIN);
46  PINSEL2 &= ~(_BV(3)); /* P1.25-16 are used as GPIO */
47  /* assert RESET */
48  IO1SET = _BV(SERVO_RESET_PIN);
49 
50  /* DATA pin output */
51  IO1DIR |= _BV(SERVO_DATA_PIN);
52 
53  /* enable match 1 interrupt */
54  T0MCR |= TMCR_MR1_I;
55 
56  /* lower clock */
57  T0EMR &= ~TEMR_EM1;
58  /* set high on match 1 */
59  T0EMR |= TEMR_EMC1_2;
60 
61  /* set first pulse in a while */
64  /* Set all servos at their midpoints */
65  /* compulsory for unaffected servos */
66  uint8_t i;
67  for( i=0 ; i < _4015_NB_CHANNELS ; i++ )
69 }
70 
71 
73 
unsigned short uint16_t
Definition: types.h:16
#define IO1SET
Definition: LPC21xx.h:306
#define SERVO_CLOCK_PINSEL
Definition: hb_1.1.h:56
#define SERVO_CLOCK_PINSEL_BIT
Definition: hb_1.1.h:58
#define T0MCR
Definition: LPC21xx.h:55
uint32_t servos_delay
#define TMCR_MR1_I
Definition: lpcTMR.h:62
#define SERVOS_TICS_OF_USEC(s)
#define SERVO_CLOCK_PIN
Definition: hb_1.1.h:55
#define _4015_NB_CHANNELS
#define SERVO_DATA_PIN
Definition: tiny_0.99.h:44
unsigned long uint32_t
Definition: types.h:18
#define T0EMR
Definition: LPC21xx.h:65
#define T0MR1
Definition: LPC21xx.h:57
#define IO0DIR
Definition: LPC21xx.h:303
void actuators_init(void)
uint8_t servos_4015_idx
#define SERVO_REFRESH_TICS
unsigned char uint8_t
Definition: types.h:14
uint16_t servos_values[_4015_NB_CHANNELS]
#define PINSEL2
Definition: LPC21xx.h:317
#define TEMR_EMC1_2
Definition: lpcTMR.h:159
#define TEMR_EM1
Definition: lpcTMR.h:150
#define SERVO_RESET_PIN
Definition: hb_1.1.h:60
#define SERVO_CLOCK_PINSEL_VAL
Definition: hb_1.1.h:57
#define START_TIMEOUT
#define IO1DIR
Definition: LPC21xx.h:307