From a1ade09173427ca0ffccb9d3d4821d3a40cf78cd Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Tue, 9 Sep 2014 16:14:18 +0200 Subject: [PATCH] [fixedwing] if USE_BARO_BOARD: separate baro timer before baro_periodic was running at PERIODIC_FREQUENCY in sensors_task, which is too fast for ms5611 if periodic freq is > 100Hz --- sw/airborne/firmwares/fixedwing/main_ap.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c index 3af9b6d61ba..ca3aa4a00e5 100644 --- a/sw/airborne/firmwares/fixedwing/main_ap.c +++ b/sw/airborne/firmwares/fixedwing/main_ap.c @@ -121,6 +121,12 @@ 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 @@ -172,7 +178,9 @@ 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 */ @@ -239,6 +247,9 @@ 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(); @@ -277,6 +288,11 @@ 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(); @@ -595,10 +611,6 @@ void sensors_task( void ) { ahrs_propagate(); #endif -#if USE_BARO_BOARD - baro_periodic(); -#endif - #if USE_GPS gps_periodic_check(); #endif