[actuators] start to rework actuators

- use multiple drivers at the same time
- all actuators firmware independant
- default actuators can still be defined for some boards
- only lpc part modified yet
- for now microjet example is compiling...
This commit is contained in:
Gautier Hattenberger
2012-10-08 18:43:39 +02:00
parent ef690a411b
commit 5705689bb3
46 changed files with 294 additions and 155 deletions
+6 -18
View File
@@ -1,21 +1,18 @@
<!-- Paparazzi airframe DTD -->
<!ELEMENT airframe (include|servos|commands|csc_boards|rc_commands|auto_rc_commands|ap_only_commands|command_laws|section|makefile|modules|firmware)*>
<!ELEMENT airframe (include|servos|commands|rc_commands|auto_rc_commands|ap_only_commands|command_laws|section|makefile|modules|firmware)*>
<!ELEMENT include EMPTY>
<!ELEMENT servos (servo)*>
<!ELEMENT commands (axis)*>
<!ELEMENT csc_boards (board)*>
<!ELEMENT board (msg)*>
<!ELEMENT msg (field_map)*>
<!ELEMENT field_map EMPTY>
<!ELEMENT rc_commands (set)*>
<!ELEMENT auto_rc_commands (set)*>
<!ELEMENT ap_only_commands (copy)*>
<!ELEMENT command_laws (let|set|ratelimit)*>
<!ELEMENT command_laws (let|set|call|ratelimit)*>
<!ELEMENT section (define|linear)*>
<!ELEMENT servo EMPTY>
<!ELEMENT axis EMPTY>
<!ELEMENT set EMPTY>
<!ELEMENT call EMPTY>
<!ELEMENT ratelimit EMPTY>
<!ELEMENT copy EMPTY>
<!ELEMENT let EMPTY>
@@ -54,7 +51,6 @@ driver CDATA #IMPLIED>
<!ATTLIST rc_commands>
<!ATTLIST ap_only_commands>
<!ATTLIST command_laws>
<!ATTLIST csc_boards>
<!ATTLIST section
name CDATA #IMPLIED
@@ -67,17 +63,6 @@ min CDATA #REQUIRED
neutral CDATA #REQUIRED
max CDATA #REQUIRED>
<!ATTLIST board
id CDATA #REQUIRED>
<!ATTLIST msg
id CDATA #REQUIRED
type CDATA #REQUIRED>
<!ATTLIST field_map
field CDATA #REQUIRED
servo_id CDATA #REQUIRED>
<!ATTLIST axis
name CDATA #REQUIRED
failsafe_value CDATA #REQUIRED>
@@ -87,6 +72,9 @@ value CDATA #REQUIRED
command CDATA #IMPLIED
servo CDATA #IMPLIED>
<!ATTLIST call
fun CDATA #REQUIRED>
<!ATTLIST copy
command CDATA #REQUIRED>
@@ -1,4 +1,4 @@
# for Tiny v1.1
$(TARGET).CFLAGS += -DACTUATORS=\"servos_4015_MAT_hw.h\" -DSERVOS_4015_MAT
$(TARGET).srcs += $(SRC_ARCH)/servos_4015_MAT_hw.c actuators.c
$(TARGET).CFLAGS += -DACTUATORS -DSERVOS_4015_MAT
$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/servos_4015_MAT_hw.c subsystems/actuators.c
@@ -1,4 +1,4 @@
# for Tiny v2 or Twog v1
$(TARGET).CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017
$(TARGET).srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c
$(TARGET).CFLAGS += -DACTUATORS -DSERVOS_4017
$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/servos_4017_hw.c subsystems/actuators.c
@@ -1,5 +1,5 @@
$(TARGET).CFLAGS += -DACTUATORS=\"subsystems/actuators/actuators_pwm.h\" -DSERVOS_DIRECT
$(TARGET).srcs += subsystems/actuators/actuators_pwm.c actuators.c
$(TARGET).CFLAGS += -DACTUATORS -DSERVOS_DIRECT
$(TARGET).srcs += subsystems/actuators/actuators_pwm.c subsystems/actuators.c
$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
@@ -5,6 +5,6 @@
# The PPM is output on the SERV_CLK pin. The PPM frame rate, pulse width, and number of channels
# can be adjusted in the "servos_ppm_hw.h" file to suit your particular receiver.
$(TARGET).CFLAGS += -DACTUATORS=\"servos_ppm_hw.h\" -DSERVOS_PPM_MAT
$(TARGET).srcs += $(SRC_ARCH)/servos_ppm_hw.c actuators.c
$(TARGET).CFLAGS += -DACTUATORS -DSERVOS_PPM_MAT
$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/servos_ppm_hw.c subsystems/actuators.c
@@ -37,7 +37,15 @@
#define SYS_TICK_IT TIR_MR0I
#if defined ACTUATORS && ( defined SERVOS_4017 || defined SERVOS_4015_MAT || defined SERVOS_PPM_MAT)
#include ACTUATORS
#ifdef SERVOS_4015_MAT
#include "subsystems/actuators/servos_4015_MAT_hw.h"
#endif
#ifdef SERVOS_4017
#include "subsystems/actuators/servos_4017_hw.h"
#endif
#ifdef SERVOS_PPM
#include "subsystems/actuators/servos_ppm_hw.h"
#endif
#else
#define ACTUATORS_IT 0x00
#endif /* ACTUATORS */
-20
View File
@@ -1,20 +0,0 @@
#ifndef SERVOS_CSC_H
#define SERVOS_CSC_H
#include "LPC21xx.h"
#include "generated/airframe.h"
#include "actuators.h"
#include "mcu_periph/sys_time.h"
#define SERVOS_TICS_OF_USEC(s) CPU_TICKS_OF_USEC(s)
#define ChopServo(x,a,b) Chop(x, a, b)
#define SERVO_COUNT 4
#define Actuator(i) actuators[i]
static inline void ActuatorsCommit(void)
{
}
#endif /* SERVOS_CSC_H */
@@ -28,7 +28,7 @@ const uint8_t pwm_latch_value = 0
#endif
;
void actuators_init ( void ) {
void actuators_pwm_init ( void ) {
/* configure pins for PWM */
#if defined PWM_SERVO_0
@@ -15,7 +15,7 @@
#define SERVO_REG_5 PWMMR2
#define COMMAND_(i) SERVO_REG_ ## i
#define Actuator(i) COMMAND_(i)
#define ActuatorPwm(i) COMMAND_(i)
/*
@@ -76,8 +76,11 @@ PWM6 PWM2 SSEL0 EINT2 P0.7
extern const uint8_t pwm_latch_value;
#define ActuatorsCommit() { \
#define ActuatorsPwmCommit() { \
PWMLER = pwm_latch_value; \
}
extern void actuators_pwm_init(void);
#define ActuatorsPwmInit() actuators_pwm_init()
#endif /* ACTUATORS_PWM_ARCH_H */
@@ -1,6 +1,4 @@
/*
* $Id$
*
* Copyright (C) 2006 Antoine Drouin
*
* This file is part of paparazzi.
@@ -27,7 +25,7 @@
*/
#include "actuators.h"
#include "subsystems/actuators.h"
#include "paparazzi.h"
#include "generated/airframe.h"
@@ -36,7 +34,7 @@ uint32_t servos_delay = SERVO_REFRESH_TICS;
#define START_TIMEOUT 0xFFFF;
void actuators_init ( void ) {
void actuators_4015_init ( void ) {
/* select clock pin as MAT0.1 output */
IO0DIR |= _BV(SERVO_CLOCK_PIN);
SERVO_CLOCK_PINSEL |= SERVO_CLOCK_PINSEL_VAL << SERVO_CLOCK_PINSEL_BIT;
@@ -42,9 +42,11 @@
#define _4015_NB_CHANNELS 8
extern uint16_t servos_values[_4015_NB_CHANNELS];
#define Actuator(i) servos_values[i]
#define Actuator4015(i) servos_values[i]
#define ActuatorsCommit() {}
extern void actuators_4015_init(void);
#define Actuators4015Commit() {}
#define Actuators4015Init() actuators_4015_init()
extern uint8_t servos_4015_idx;
extern uint32_t servos_delay;
@@ -1,4 +1,25 @@
#include "actuators.h"
/*
* Copyright (C) 2006 Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "subsystems/actuators.h"
#include "armVIC.h"
#include "generated/airframe.h"
@@ -19,7 +40,7 @@ uint16_t servos_values[_4015_NB_CHANNELS];
#define PWMIR_MRI_SERV1 PWMIR_MR2I
void actuators_init ( void ) {
void actuators_4015_init ( void ) {
/* PWM selected as IRQ */
VICIntSelect &= ~VIC_BIT(VIC_PWM);
/* PWM interrupt enabled */
@@ -35,9 +35,11 @@
#define _4015_NB_CHANNELS 8
extern uint16_t servos_values[_4015_NB_CHANNELS];
#define Actuator(i) servos_values[i]
#define Actuator4015(i) servos_values[i]
#define ActuatorsCommit() {}
extern void actuators_4015_init(void);
#define Actuators4015Commit() {}
#define Actuators4015Init() actuators_4015_init()
void PWM_ISR ( void ) __attribute__((naked));
@@ -1,4 +1,25 @@
#include "actuators.h"
/*
* Copyright (C) 2006 Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "subsystems/actuators.h"
#include "armVIC.h"
#include "generated/airframe.h"
@@ -19,7 +40,7 @@ uint16_t servos_values[_4015_NB_CHANNELS];
#define PWMIR_MRI_SERV1 PWMIR_MR2I
void actuators_init ( void ) {
void actuators_4015_init ( void ) {
/* PWM selected as IRQ */
VICIntSelect &= ~VIC_BIT(VIC_PWM);
/* PWM interrupt enabled */
@@ -1,4 +1,25 @@
#include "actuators.h"
/*
* Copyright (C) 2006 Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "subsystems/actuators.h"
#include "paparazzi.h"
#include "generated/airframe.h"
@@ -7,7 +28,7 @@ uint8_t servos_4017_idx;
#define START_TIMEOUT 0xFFFF;
void actuators_init ( void ) {
void actuators_4017_init ( void ) {
/* select clock pin as MAT0.1 output */
IO0DIR |= _BV(SERVO_CLOCK_PIN);
SERVO_CLOCK_PINSEL |= SERVO_CLOCK_PINSEL_VAL << SERVO_CLOCK_PINSEL_BIT;
@@ -19,9 +19,11 @@
#endif
extern uint16_t servos_values[_4017_NB_CHANNELS];
#define Actuator(i) servos_values[i]
#define Actuator4017(i) servos_values[i]
#define ActuatorsCommit() {}
extern void actuators_4017_init(void);
#define Actuators4017Commit() {}
#define Actuators4017Init() actuators_4017_init()
extern uint8_t servos_4017_idx;
@@ -26,7 +26,7 @@
* \ for a R/C receiver which has a microcontroller to drive the servos
* \(not a 4015 or 4017 decade counter chip).
*/
#include "actuators.h"
#include "subsystems/actuators.h"
#include "paparazzi.h"
#include "generated/airframe.h"
@@ -36,7 +36,7 @@ uint32_t servos_delay = SERVO_REFRESH_TICS;
#define START_TIMEOUT 0xFFFF;
void actuators_init ( void ) {
void actuators_ppm_init ( void ) {
/* select ppm output pin as MAT0.1 output */
SERVO_CLOCK_PINSEL |= SERVO_CLOCK_PINSEL_VAL << SERVO_CLOCK_PINSEL_BIT;
@@ -40,9 +40,11 @@
#define _PPM_NB_CHANNELS 8
extern uint16_t servos_values[_PPM_NB_CHANNELS];
#define Actuator(i) servos_values[i]
#define ActuatorPpm(i) servos_values[i]
#define ActuatorsCommit() {}
extern void actuators_ppm_init(void);
#define ActuatorsPpmCommit() {}
#define ActuatorsPpmInit() actuators_ppm_init()
extern uint8_t servos_PPM_idx;
extern uint32_t servos_delay;
extern uint8_t ppm_pulse; /* 1=start of pulse, 0=end of pulse */
+6
View File
@@ -35,6 +35,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 19
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4015.h"
#define ActuatorDefault(_x) Actuator4015(_x)
#define ActuatorsDefaultInit() Actuators4015Init()
#define ActuatorsDefaultCommit() Actuators4015Commit()
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
+6
View File
@@ -46,6 +46,12 @@
#define POWER_SWITCH_LED 3
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4015.h"
#define ActuatorDefault(_x) Actuator4015(_x)
#define ActuatorsDefaultInit() Actuators4015Init()
#define ActuatorsDefaultCommit() Actuators4015Commit()
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
+6
View File
@@ -49,6 +49,12 @@
#define POWER_SWITCH_LED 4
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
#define ActuatorDefault(_x) Actuator4017(_x)
#define ActuatorsDefaultInit() Actuators4017Init()
#define ActuatorsDefaultCommit() Actuators4017Commit()
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
+6
View File
@@ -86,6 +86,12 @@
#define Set_GPS_RESET_Pin_LOW() LED_ON(GPS_RESET)
#define Open_GPS_RESET_Pin() ClearBit(LED_DIR(GPS_RESET), LED_PIN(GPS_RESET))
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
#define ActuatorDefault(_x) Actuator4017(_x)
#define ActuatorsDefaultInit() Actuators4017Init()
#define ActuatorsDefaultCommit() Actuators4017Commit()
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
+6
View File
@@ -29,6 +29,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 19
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
#define ActuatorDefault(_x) Actuator4017(_x)
#define ActuatorsDefaultInit() Actuators4017Init()
#define ActuatorsDefaultCommit() Actuators4017Commit()
/* p0.21 aka PWM5 */
#define SERV0_CLOCK_PIN 21
#define SERV0_CLOCK_PINSEL PINSEL1
+6
View File
@@ -30,6 +30,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 24
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
#define ActuatorDefault(_x) Actuator4017(_x)
#define ActuatorsDefaultInit() Actuators4017Init()
#define ActuatorsDefaultCommit() Actuators4017Commit()
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
+6
View File
@@ -30,6 +30,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 24
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
#define ActuatorDefault(_x) Actuator4017(_x)
#define ActuatorsDefaultInit() Actuators4017Init()
#define ActuatorsDefaultCommit() Actuators4017Commit()
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
@@ -40,7 +40,7 @@
#include "generated/periodic_telemetry.h"
#include "generated/airframe.h"
#include "commands.h"
#include "actuators.h"
#include "subsystems/actuators.h"
#include "mcu_periph/uart.h"
#include "firmwares/fixedwing/main_fbw.h"
@@ -78,7 +78,7 @@
#endif // RADIO_CONTROL
#ifdef ACTUATORS
#define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, SERVOS_NB, actuators)
#define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, ACTUATORS_NB, actuators)
#else
#define PERIODIC_SEND_ACTUATORS(_trans, _dev) {}
#endif
+1 -1
View File
@@ -37,7 +37,7 @@
#include "mcu.h"
#include "mcu_periph/sys_time.h"
#include "commands.h"
#include "firmwares/fixedwing/actuators.h"
#include "subsystems/actuators.h"
#include "subsystems/electrical.h"
#include "subsystems/radio_control.h"
#include "firmwares/fixedwing/autopilot.h"
@@ -30,7 +30,7 @@ void dl_parse_msg( void ) {
uint8_t servo_no = DL_SET_ACTUATOR_no(dl_buffer);
uint16_t servo_value = DL_SET_ACTUATOR_value(dl_buffer);
LED_TOGGLE(2);
if (servo_no < SERVOS_NB)
if (servo_no < ACTUATORS_NB)
SetServo(servo_no, servo_value);
}
#ifdef DlSetting
@@ -58,7 +58,7 @@ void init_fbw( void ) {
actuators_init();
uint8_t i;
for(i = 0; i < SERVOS_NB; i++) {
for(i = 0; i < ACTUATORS_NB; i++) {
SetServo(i, 1500);
}
@@ -83,7 +83,7 @@ void periodic_task_fbw(void) {
/* SetServo(SERVO_THROTTLE, servo_value); */
RunOnceEvery(300, DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM));
RunOnceEvery(300, DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice, SERVOS_NB, actuators ));
RunOnceEvery(300, DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice, ACTUATORS_NB, actuators ));
}
void event_task_fbw(void) {
@@ -24,6 +24,13 @@
*
*/
#include "firmwares/fixedwing/actuators.h"
#include "subsystems/actuators.h"
uint16_t actuators[SERVOS_NB];
uint16_t actuators[ACTUATORS_NB];
void actuators_init(void) {
// Init macro from generated airframe.h
AllActuatorsInit();
}
@@ -1,5 +1,6 @@
/*
* (c) 2003-2005 Pascal Brisset, Antoine Drouin
* (c) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -26,32 +27,29 @@
#ifndef ACTUATORS_H
#define ACTUATORS_H
#if defined ACTUATORS
#include "paparazzi.h"
/** Defines SetActuatorsFromCommands() macro */
/** Defines SetActuatorsFromCommands() macro
* Defines ACTUATORS_NB to 0 if no servo
* Include servos drivers
*/
#include "generated/airframe.h"
/** Must be defined by specific hardware implementation */
#if ACTUATORS_NB
extern void actuators_init( void );
/** Temporary storage (for debugging purpose, downlinked via telemetry) */
extern uint16_t actuators[SERVOS_NB];
extern uint16_t actuators[ACTUATORS_NB];
#include ACTUATORS
#define SetServo(x, v) { actuators[x##_IDX] = v; }
#define SetServo(x, v) { \
Actuator(x) = SERVOS_TICS_OF_USEC(ChopServo(v,700,2400)); \
actuators[x] = v; \
}
#else /* ACTUATORS_NB */
#else /* ACTUATORS */
// define empty SetServo makro for sim
// define empty SetServo makro for sim (really needed ?)
#define SetServo(x, v) {}
#endif /* ACTUATORS */
#endif /* ACTUATORS_NB */
#endif /* ACTUATORS_H */
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of Paparazzi.
*
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef ACTUATORS_4015_H
#define ACTUATORS_4015_H
#include "subsystems/actuators/servos_4015_MAT_hw.h"
#endif /* ACTUATORS_4015_H */
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of Paparazzi.
*
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef ACTUATORS_4017_H
#define ACTUATORS_4017_H
#include "subsystems/actuators/servos_4017_hw.h"
#endif /* ACTUATORS_4017_H */
@@ -1,36 +1,30 @@
/*
* Copyright (C) 2010-2012 The Paparazzi Team
* Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
* This file is part of Paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/** @file actuators.h
* Generic Actuators API.
#ifndef ACTUATORS_DEFAULT_H
#define ACTUATORS_DEFAULT_H
/** Dummy include of default actuators header
*/
#include BOARD_CONFIG
#include DEFAULT_ACTUATORS
#ifndef ACTUATORS_H
#define ACTUATORS_H
//#include ACTUATORS
#include "std.h"
extern void actuators_init(void);
extern void actuators_set(bool_t motors_on);
#endif /* ACTUATORS_H */
#endif /* ACTUATORS_DEFAULT_H */
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of Paparazzi.
*
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef ACTUATORS_PPM_H
#define ACTUATORS_PPM_H
#include "subsystems/actuators/servos_ppm_hw.h"
#endif /* ACTUATORS_PPM_H */
+14 -45
View File
@@ -150,7 +150,10 @@ let preprocess_value = fun s v prefix ->
let s = Str.global_replace pprz_value (sprintf "%s[%s_\\1]" v prefix) s in
Str.global_replace var_value "_var_\\1" s
let print_actuators_idx = fun () ->
let nb = Hashtbl.fold (fun s _d i -> printf "#define SERVO_%s_IDX %d\n" s i; i+1) servos_drivers 0 in
define "ACTUATORS_NB" (string_of_int nb);
nl ()
let parse_command_laws = fun command ->
let a = fun s -> ExtXml.attrib command s in
@@ -162,15 +165,18 @@ let parse_command_laws = fun command ->
printf " command_value = %s;\\\n" v;
printf " command_value *= command_value>0 ? SERVO_%s_TRAVEL_UP : SERVO_%s_TRAVEL_DOWN;\\\n" servo servo;
printf " servo_value = SERVO_%s_NEUTRAL + (int32_t)(command_value);\\\n" servo;
printf " actuators[SERVO_%s] = ChopServo(servo_value, SERVO_%s_MIN, SERVO_%s_MAX);\\\n\\\n" servo servo servo;
printf " actuators[SERVO_%s_IDX] = ChopServo(servo_value, SERVO_%s_MIN, SERVO_%s_MAX);\\\n\\\n" servo servo servo;
let driver = get_servo_driver servo in
printf " Actuator%s(SERVO_%s) = SERVOS_TICS_OF_USEC(actuators[SERVO_%s]);\\\n\\\n" driver servo servo
printf " Actuator%s(SERVO_%s) = SERVOS_TICS_OF_USEC(actuators[SERVO_%s_IDX]);\\\n\\\n" driver servo servo
| "let" ->
let var = a "var"
and value = a "value" in
let v = preprocess_value value "values" "COMMAND" in
printf " int16_t _var_%s = %s;\\\n" var v
| "call" ->
let f = a "fun" in
printf " %s;\\\n" f
| "ratelimit" ->
let var = a "var"
and value = a "value"
@@ -182,40 +188,6 @@ let parse_command_laws = fun command ->
parse_element "" command
| _ -> xml_error "set|let"
let parse_csc_fields = fun csc_fields ->
let a = fun s -> ExtXml.attrib csc_fields s in
match Xml.tag csc_fields with
"field_map" ->
let servo_id = a "servo_id"
and field = a "field" in
printf " temp.%s = actuators[%s]; \\\n" field servo_id;
| _ -> xml_error "field_map"
let parse_csc_messages = (let msg_index_ref = ref 0 in fun csc_id csc_messages ->
let a = fun s -> ExtXml.attrib csc_messages s in
match Xml.tag csc_messages with
"msg" ->
let msg_id = a "id"
and msg_type = a "type"
and msg_index = msg_index_ref.contents in
msg_index_ref.contents <- msg_index + 1;
printf "{\\\n struct Csc%s temp; \\\n" msg_type;
List.iter parse_csc_fields (Xml.children csc_messages);
printf " can_write_csc(%s, CSC_%s, (uint8_t *)&temp, sizeof(struct Csc%s)); \\\n" csc_id msg_id msg_type;
printf "} \\\n"
| _ -> xml_error "msg"
)
let parse_csc_boards = fun csc_board ->
let a = fun s -> ExtXml.attrib csc_board s in
match Xml.tag csc_board with
"board" ->
let csc_id = a "id" in
List.iter (parse_csc_messages csc_id) (Xml.children csc_board);
| "define" ->
parse_element "" csc_board
| _ -> xml_error "board"
let parse_rc_commands = fun rc ->
let a = fun s -> ExtXml.attrib rc s in
match Xml.tag rc with
@@ -255,11 +227,12 @@ let rec parse_section = fun s ->
List.iter (parse_element prefix) (Xml.children s);
nl ()
| "servos" ->
let driver = ExtXml.attrib_or_default s "driver" "" in
let driver = ExtXml.attrib_or_default s "driver" "Default" in
let servos = Xml.children s in
let nb_servos = List.fold_right (fun s m -> Pervasives.max (int_of_string (ExtXml.attrib s "no")) m) servos min_int + 1 in
define "SERVOS_NB" (string_of_int nb_servos);
define (sprintf "SERVOS_%s_NB" (String.uppercase driver)) (string_of_int nb_servos);
printf "#include \"subsystems/actuators/actuators_%s.h\"\n" (String.lowercase driver);
nl ();
List.iter (parse_servo driver) servos;
nl ()
@@ -282,6 +255,8 @@ let rec parse_section = fun s ->
List.iter parse_ap_only_commands (Xml.children s);
printf "}\n\n"
| "command_laws" ->
print_actuators_idx ();
printf "#define SetActuatorsFromCommands(values) { \\\n";
printf " uint32_t servo_value;\\\n";
printf " float command_value;\\\n";
@@ -295,12 +270,6 @@ let rec parse_section = fun s ->
printf "#define AllActuatorsInit() { \\\n";
List.iter (fun d -> printf " Actuators%sInit();\\\n" d) drivers;
printf "}\n\n";
| "csc_boards" ->
let boards = Array.of_list (Xml.children s) in
define "CSC_BOARD_NB" (string_of_int (Array.length boards));
printf "#define SendCscFromActuators() { \\\n";
List.iter parse_csc_boards (Xml.children s);
printf "}\n"
| "include" ->
let filename = ExtXml.attrib s "href" in
let subxml = Xml.parse_file filename in