Skip to content

Commit

Permalink
[modules] baro_board as module
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Sep 9, 2014
1 parent fb01f66 commit 1c8fa5a
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 80 deletions.
1 change: 1 addition & 0 deletions conf/airframes/ENAC/fixed-wing/apogee.xml
Expand Up @@ -33,6 +33,7 @@
<subsystem name="radio_control" type="sbus"/>
</target>

<define name="USE_BARO_BOARD" value="FALSE"/>

<!-- Communication -->
<subsystem name="telemetry" type="xbee_api"/>
Expand Down
1 change: 1 addition & 0 deletions conf/airframes/examples/microjet_lisa_m.xml
Expand Up @@ -47,6 +47,7 @@
<modules>
<load name="sys_mon.xml"/>
<load name="baro_sim.xml"/>
<load name="baro_board.xml"/>

<!-- extra navigation routines -->
<load name="nav_bungee_takeoff.xml"/>
Expand Down
1 change: 1 addition & 0 deletions conf/airframes/examples/quadrotor_lisa_mx.xml
Expand Up @@ -63,6 +63,7 @@
</load>
<load name="gps_ubx_ucenter.xml"/>
<load name="geo_mag.xml"/>
<load name="baro_board.xml"/>
</modules>

<servos driver="Pwm">
Expand Down
2 changes: 0 additions & 2 deletions conf/firmwares/rotorcraft.makefile
Expand Up @@ -141,8 +141,6 @@ ap.srcs += subsystems/actuators.c
#
ap.srcs += subsystems/air_data.c

include $(CFG_SHARED)/baro_board.makefile

#
# Analog Backend
#
Expand Down
3 changes: 0 additions & 3 deletions conf/firmwares/subsystems/fixedwing/autopilot.makefile
Expand Up @@ -161,9 +161,6 @@ ap_srcs += $(SRC_ARCH)/subsystems/settings_arch.c
# AIR DATA
ap_srcs += subsystems/air_data.c

# BARO
include $(CFG_SHARED)/baro_board.makefile


######################################################################
##
Expand Down
22 changes: 22 additions & 0 deletions conf/modules/baro_board.xml
@@ -0,0 +1,22 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="baro_board" dir="sensors">
<doc>
<description>
Baro board default.
Drivers for baros already on an autopilot board.
</description>
<configure name="USE_BARO_BOARD" value="TRUE" description="Set to FALSE to disable onboard baro"/>
</doc>
<header>
<file name="baro_board_module.h"/>
</header>
<init fun="baro_init()"/>
<periodic fun="baro_periodic()" freq="40"/>
<event fun="baro_event()"/>
<makefile target="ap">
<raw>
include $(CFG_SHARED)/baro_board.makefile
</raw>
</makefile>
</module>
2 changes: 1 addition & 1 deletion sw/airborne/boards/apogee/baro_board.c
Expand Up @@ -27,7 +27,7 @@
*/

#include "std.h"
#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "peripherals/mpl3115.h"

// to get MPU status
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/ardrone/baro_board.c
Expand Up @@ -26,7 +26,7 @@
* Based on BMP180 implementation by C. de Wagter.
*/

#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "subsystems/abi.h"
#include "baro_board.h"
#include "navdata.h"
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/baro_board_ms5611_i2c.c
Expand Up @@ -27,7 +27,7 @@
*
*/

#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "peripherals/ms5611_i2c.h"

#include "mcu_periph/sys_time.h"
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/baro_board_ms5611_spi.c
Expand Up @@ -27,7 +27,7 @@
*
*/

#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "peripherals/ms5611_spi.h"

#include "mcu_periph/sys_time.h"
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/booz/baro_board.c
Expand Up @@ -25,7 +25,7 @@
*/


#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"

#include "generated/airframe.h"
#include "subsystems/abi.h"
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/booz/baro_board.h
Expand Up @@ -30,7 +30,7 @@

#include "std.h"

#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "mcu_periph/adc.h"
#include "mcu_periph/dac.h"

Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/lisa_l/baro_board.c
Expand Up @@ -21,7 +21,7 @@
*/

#include "std.h"
#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "mcu_periph/i2c.h"
#include "subsystems/abi.h"
#include "led.h"
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/lisa_m/baro_board.c
Expand Up @@ -25,7 +25,7 @@

#include "std.h"

#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "peripherals/bmp085.h"
#include "peripherals/bmp085_regs.h"
#include <libopencm3/stm32/gpio.h>
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/navgo/baro_board.c
Expand Up @@ -27,7 +27,7 @@

#include "std.h"
#include "baro_board.h"
#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "peripherals/mcp355x.h"
#include "subsystems/abi.h"
#include "led.h"
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/navstik/baro_board.c
Expand Up @@ -25,7 +25,7 @@

#include "std.h"

#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "peripherals/bmp085.h"
#include "peripherals/bmp085_regs.h"
#include <libopencm3/stm32/gpio.h>
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/umarim/baro_board.c
Expand Up @@ -27,7 +27,7 @@

#include "std.h"
#include "baro_board.h"
#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "peripherals/ads1114.h"
#include "subsystems/abi.h"
#include "led.h"
Expand Down
38 changes: 8 additions & 30 deletions sw/airborne/firmwares/fixedwing/main_ap.c
Expand Up @@ -54,13 +54,8 @@
#include "subsystems/ahrs/ahrs_aligner.h"
#endif
#include "subsystems/air_data.h"
#if USE_BARO_BOARD
#include "subsystems/sensors/baro.h"
PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BOARD)
#endif
#include "subsystems/ins.h"


// autopilot & control
#include "state.h"
#include "firmwares/fixedwing/autopilot.h"
Expand Down Expand Up @@ -106,6 +101,14 @@ PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BO
#define COMMAND_YAW_TRIM 0
#endif

#if USE_BARO_BOARD
#if BARO_BOARD_MODULE_LOADED
PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BOARD)
#else
#warning "USE_BARO_BOARD is TRUE, but baro_board.xml module not loaded!"
#endif // BARO_BOARD_MODULE_LOADED
#endif // USE_BARO_BOARD

/* if PRINT_CONFIG is defined, print some config options */
PRINT_CONFIG_VAR(PERIODIC_FREQUENCY)
PRINT_CONFIG_VAR(NAVIGATION_FREQUENCY)
Expand All @@ -121,13 +124,6 @@ PRINT_CONFIG_VAR(TELEMETRY_FREQUENCY)
*/
PRINT_CONFIG_VAR(MODULES_FREQUENCY)

#if USE_BARO_BOARD
#ifndef BARO_PERIODIC_FREQUENCY
#define BARO_PERIODIC_FREQUENCY 50
#endif
PRINT_CONFIG_VAR(BARO_PERIODIC_FREQUENCY)
#endif

#if USE_AHRS && USE_IMU

#ifndef AHRS_PROPAGATE_FREQUENCY
Expand Down Expand Up @@ -178,9 +174,6 @@ tid_t sensors_tid; ///< id for sensors_task() timer
tid_t attitude_tid; ///< id for attitude_loop() timer
tid_t navigation_tid; ///< id for navigation_task() timer
tid_t monitor_tid; ///< id for monitor_task() timer
#if USE_BARO_BOARD
tid_t baro_tid; ///< id for baro_periodic() timer
#endif

void init_ap( void ) {
#ifndef SINGLE_MCU /** init done in main_fbw in single MCU */
Expand Down Expand Up @@ -213,9 +206,6 @@ void init_ap( void ) {
#endif

air_data_init();
#if USE_BARO_BOARD
baro_init();
#endif

ins_init();

Expand Down Expand Up @@ -244,9 +234,6 @@ void init_ap( void ) {
modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL);
telemetry_tid = sys_time_register_timer(1./TELEMETRY_FREQUENCY, NULL);
monitor_tid = sys_time_register_timer(1.0, NULL);
#if USE_BARO_BOARD
baro_tid = sys_time_register_timer(1./BARO_PERIODIC_FREQUENCY, NULL);
#endif

/** - start interrupt task */
mcu_int_enable();
Expand Down Expand Up @@ -285,11 +272,6 @@ void handle_periodic_tasks_ap(void) {
if (sys_time_check_and_ack_timer(sensors_tid))
sensors_task();

#if USE_BARO_BOARD
if (sys_time_check_and_ack_timer(baro_tid))
baro_periodic();
#endif

if (sys_time_check_and_ack_timer(navigation_tid))
navigation_task();

Expand Down Expand Up @@ -682,10 +664,6 @@ void event_task_ap( void ) {
GpsEvent(on_gps_solution);
#endif /* USE_GPS */

#if USE_BARO_BOARD
BaroEvent();
#endif

DatalinkEvent();


Expand Down
36 changes: 9 additions & 27 deletions sw/airborne/firmwares/rotorcraft/main.c
Expand Up @@ -54,11 +54,6 @@
#include "subsystems/gps.h"
#include "subsystems/air_data.h"

#if USE_BARO_BOARD
#include "subsystems/sensors/baro.h"
PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BOARD)
#endif

#include "subsystems/electrical.h"

#include "firmwares/rotorcraft/autopilot.h"
Expand All @@ -84,6 +79,14 @@ PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BO
#include "subsystems/abi.h"


#if USE_BARO_BOARD
#if BARO_BOARD_MODULE_LOADED
PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BOARD)
#else
#warning "USE_BARO_BOARD is TRUE, but baro_board.xml module not loaded!"
#endif // BARO_BOARD_MODULE_LOADED
#endif // USE_BARO_BOARD

/* if PRINT_CONFIG is defined, print some config options */
PRINT_CONFIG_VAR(PERIODIC_FREQUENCY)

Expand All @@ -97,11 +100,6 @@ PRINT_CONFIG_VAR(TELEMETRY_FREQUENCY)
*/
PRINT_CONFIG_VAR(MODULES_FREQUENCY)

#ifndef BARO_PERIODIC_FREQUENCY
#define BARO_PERIODIC_FREQUENCY 50
#endif
PRINT_CONFIG_VAR(BARO_PERIODIC_FREQUENCY)

#if USE_AHRS && USE_IMU && (defined AHRS_PROPAGATE_FREQUENCY)
#if (AHRS_PROPAGATE_FREQUENCY > PERIODIC_FREQUENCY)
#warning "PERIODIC_FREQUENCY should be least equal or greater than AHRS_PROPAGATE_FREQUENCY"
Expand All @@ -121,9 +119,6 @@ tid_t failsafe_tid; ///< id for failsafe_check() timer
tid_t radio_control_tid; ///< id for radio_control_periodic_task() timer
tid_t electrical_tid; ///< id for electrical_periodic() timer
tid_t telemetry_tid; ///< id for telemetry_periodic() timer
#if USE_BARO_BOARD
tid_t baro_tid; ///< id for baro_periodic() timer
#endif

#ifndef SITL
int main( void ) {
Expand Down Expand Up @@ -153,9 +148,7 @@ STATIC_INLINE void main_init( void ) {
radio_control_init();

air_data_init();
#if USE_BARO_BOARD
baro_init();
#endif

imu_init();
ahrs_aligner_init();
ahrs_init();
Expand Down Expand Up @@ -188,9 +181,6 @@ STATIC_INLINE void main_init( void ) {
failsafe_tid = sys_time_register_timer(0.05, NULL);
electrical_tid = sys_time_register_timer(0.1, NULL);
telemetry_tid = sys_time_register_timer((1./TELEMETRY_FREQUENCY), NULL);
#if USE_BARO_BOARD
baro_tid = sys_time_register_timer(1./BARO_PERIODIC_FREQUENCY, NULL);
#endif
}

STATIC_INLINE void handle_periodic_tasks( void ) {
Expand All @@ -206,10 +196,6 @@ STATIC_INLINE void handle_periodic_tasks( void ) {
electrical_periodic();
if (sys_time_check_and_ack_timer(telemetry_tid))
telemetry_periodic();
#if USE_BARO_BOARD
if (sys_time_check_and_ack_timer(baro_tid))
baro_periodic();
#endif
}

STATIC_INLINE void main_periodic( void ) {
Expand Down Expand Up @@ -290,10 +276,6 @@ STATIC_INLINE void main_event( void ) {

ImuEvent(on_gyro_event, on_accel_event, on_mag_event);

#if USE_BARO_BOARD
BaroEvent();
#endif

#if USE_GPS
GpsEvent(on_gps_event);
#endif
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/modules/sensors/airspeed_ads1114.c
Expand Up @@ -26,7 +26,7 @@
*/

#include "modules/sensors/airspeed_ads1114.h"
#include "subsystems/sensors/baro.h"
#include "modules/sensors/baro_board_module.h"
#include "baro_board.h"

void airspeed_periodic(void) {
Expand Down
Expand Up @@ -20,21 +20,22 @@
*/

/**
* @file subsystems/sensors/baro.h
* @file modules/sensors/baro_board_module.h
*
* Common barometric sensor implementation.
* Used with baro integrated to the autopilot board.
* Implementation is in boards/<board_name>/baro_board.[ch]
*
*/

#ifndef SUBSYSTEMS_SENSORS_BARO_H
#define SUBSYSTEMS_SENSORS_BARO_H
#ifndef MODULES_SENSORS_BARO_H
#define MODULES_SENSORS_BARO_H

#include BOARD_CONFIG

#if USE_BARO_BOARD
#include "baro_board.h"
#define BARO_BOARD_MODULE_LOADED 1
#ifndef BARO_BOARD
#define BARO_BOARD BARO_BOARD_DEFAULT
#endif
Expand All @@ -43,4 +44,4 @@
extern void baro_init(void);
extern void baro_periodic(void);

#endif /* SUBSYSTEMS_SENSORS_BARO_H */
#endif /* MODULES_SENSORS_BARO_H */

0 comments on commit 1c8fa5a

Please sign in to comment.