Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
servos_4015_MAT_hw.h
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 #ifndef SERVOS_4015_HW_H
31 #define SERVOS_4015_HW_H
32 
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 _4015_NB_CHANNELS 8
45 #define Actuator(i) servos_values[i]
46 
47 #define ActuatorsCommit() {}
49 extern uint32_t servos_delay;
50 
51 #define SERVO_REFRESH_TICS SERVOS_TICS_OF_USEC(20000)
52 
53 #define ACTUATORS_IT TIR_MR1I
54 #define Servos4015Mat_ISR() { \
55  if (servos_4015_idx == 0) { \
56  servos_delay = SERVO_REFRESH_TICS; \
57  SetBit(IO1CLR, SERVO_DATA_PIN); \
58  } \
59  if (servos_4015_idx < _4015_NB_CHANNELS ) { \
60  T0MR1 += servos_values[servos_4015_idx]; \
61  servos_delay -= servos_values[servos_4015_idx]; \
62  servos_4015_idx++; \
63  } else if (servos_4015_idx == _4015_NB_CHANNELS) { \
64  SetBit(IO1SET, SERVO_RESET_PIN); \
65  servos_4015_idx++; \
66  T0MR1 += servos_delay/2; \
67  } else { \
68  SetBit(IO1SET, SERVO_DATA_PIN); \
69  SetBit(IO1CLR, SERVO_RESET_PIN); \
70  servos_4015_idx = 0; \
71  T0MR1 += servos_delay/2; \
72  } \
73  /* lower clock pin */ \
74  T0EMR &= ~TEMR_EM1; \
75 }
76 
77 #endif /* SERVOS_4015_HW_H */
unsigned short uint16_t
Definition: types.h:16
#define _4015_NB_CHANNELS
uint32_t servos_delay
Architecture independent timing functions.
unsigned long uint32_t
Definition: types.h:18
uint8_t servos_4015_idx
unsigned char uint8_t
Definition: types.h:14
uint16_t servos_values[_4015_NB_CHANNELS]
Definition: servos_4015_hw.c:8