Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
servos_4015_MAT_hw.h
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 #ifndef SERVOS_4015_HW_H
29 #define SERVOS_4015_HW_H
30 
31 
32 #include "std.h"
33 #include "LPC21xx.h"
34 #include "mcu_periph/sys_time.h"
35 
36 #include BOARD_CONFIG
37 
38 #define SERVOS_TICS_OF_USEC(s) cpu_ticks_of_usec(s)
39 #define ChopServo(x,a,b) Chop(x, a, b)
40 
41 #define _4015_NB_CHANNELS 8
43 #define Actuator4015Set(_i, _v) { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
44 
45 extern void actuators_4015_init(void);
46 #define Actuators4015Commit() {}
47 #define Actuators4015Init() actuators_4015_init()
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
void actuators_4015_init(void)
uint32_t servos_delay
uint16_t servos_values[_4015_NB_CHANNELS]
Architecture independent timing functions.
unsigned long uint32_t
Definition: types.h:18
unsigned char uint8_t
Definition: types.h:14
uint8_t servos_4015_idx