From 3676530d2c47309f2fed2f0fc687a74bfc664d90 Mon Sep 17 00:00:00 2001 From: Pascal Brisset Date: Sun, 6 Jan 2008 20:46:22 +0000 Subject: [PATCH] #ifdef added to be able to compile an A/C without RC --- sw/airborne/fbw_downlink.h | 12 ++++++++++-- sw/airborne/inter_mcu.h | 13 ++++++++++--- sw/airborne/main_ap.c | 17 +++++++++++++---- sw/airborne/sim/ppm_hw.c | 11 +++++++++++ 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/sw/airborne/fbw_downlink.h b/sw/airborne/fbw_downlink.h index b91e3b919a..ab26b34cb1 100644 --- a/sw/airborne/fbw_downlink.h +++ b/sw/airborne/fbw_downlink.h @@ -50,10 +50,18 @@ #define DOWNLINK_DEVICE DOWNLINK_FBW_DEVICE #include "downlink.h" +#define PERIODIC_SEND_COMMANDS() DOWNLINK_SEND_COMMANDS(COMMANDS_NB, commands) + +#ifdef RADIO_CONTROL +#define PERIODIC_SEND_FBW_STATUS() DOWNLINK_SEND_FBW_STATUS(&rc_status, &fbw_mode, &fbw_vsupply_decivolt) #define PERIODIC_SEND_PPM() DOWNLINK_SEND_PPM(PPM_NB_PULSES, ppm_pulses) #define PERIODIC_SEND_RC() DOWNLINK_SEND_RC(PPM_NB_PULSES, rc_values) -#define PERIODIC_SEND_COMMANDS() DOWNLINK_SEND_COMMANDS(COMMANDS_NB, commands) -#define PERIODIC_SEND_FBW_STATUS() DOWNLINK_SEND_FBW_STATUS(&rc_status, &fbw_mode, &fbw_vsupply_decivolt) +#else // RADIO_CONTROL +#define PERIODIC_SEND_FBW_STATUS() { uint8_t dummy = 0; DOWNLINK_SEND_FBW_STATUS(&dummy, &fbw_mode, &fbw_vsupply_decivolt); } +#define PERIODIC_SEND_PPM() {} +#define PERIODIC_SEND_RC() {} +#endif // RADIO_CONTROL + #ifdef ACTUATORS #define PERIODIC_SEND_ACTUATORS() DOWNLINK_SEND_ACTUATORS(SERVOS_NB, actuators) #else diff --git a/sw/airborne/inter_mcu.h b/sw/airborne/inter_mcu.h index 9d8d790d5e..a3a04bddfb 100644 --- a/sw/airborne/inter_mcu.h +++ b/sw/airborne/inter_mcu.h @@ -59,7 +59,7 @@ struct ap_state { // Status bits from FBW to AUTOPILOT #define STATUS_RADIO_OK 0 -#define RADIO_REALLY_LOST 1 +#define STATUS_RADIO_REALLY_LOST 1 #define STATUS_MODE_AUTO 2 #define STATUS_MODE_FAILSAFE 3 #define AVERAGED_CHANNELS_SENT 4 @@ -91,23 +91,30 @@ static inline void inter_mcu_init(void) { /* Prepare data to be sent to mcu0 */ static inline void inter_mcu_fill_fbw_state (void) { + uint8_t status = 0; + +#ifdef RADIO_CONTROL uint8_t i; for(i = 0; i < RADIO_CTL_NB; i++) fbw_state->channels[i] = rc_values[i]; fbw_state->ppm_cpt = last_ppm_cpt; - uint8_t status; status = (rc_status == RC_OK ? _BV(STATUS_RADIO_OK) : 0); - status |= (rc_status == RC_REALLY_LOST ? _BV(RADIO_REALLY_LOST) : 0); + status |= (rc_status == RC_REALLY_LOST ? _BV(STATUS_RADIO_REALLY_LOST) : 0); +#endif // RADIO_CONTROL + status |= (fbw_mode == FBW_MODE_AUTO ? _BV(STATUS_MODE_AUTO) : 0); status |= (fbw_mode == FBW_MODE_FAILSAFE ? _BV(STATUS_MODE_FAILSAFE) : 0); fbw_state->status = status; +#ifdef RADIO_CONTROL if (rc_values_contains_avg_channels) { fbw_state->status |= _BV(AVERAGED_CHANNELS_SENT); rc_values_contains_avg_channels = FALSE; } +#endif // RADIO_CONTROL + fbw_state->vsupply = fbw_vsupply_decivolt; } diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c index dc55938529..496c6987c9 100644 --- a/sw/airborne/main_ap.c +++ b/sw/airborne/main_ap.c @@ -100,6 +100,10 @@ #endif #define LOW_BATTERY_DECIVOLT (LOW_BATTERY*10) +#ifndef MILLIAMP_PER_PERCENT +#define MILLIAMP_PER_PERCENT 0 +#endif + /** FIXME: should be in rc_settings but required by telemetry (ap_downlink.h)*/ uint8_t rc_settings_mode = RC_SETTINGS_MODE_NONE; @@ -198,13 +202,12 @@ static inline void reporting_task( void ) { #define RC_LOST_MODE PPRZ_MODE_HOME #endif -/** \brief Function to be called when a command is available (usually comming from the radio command) - */ +/** \brief Function to be called when a message from FBW is available */ inline void telecommand_task( void ) { uint8_t mode_changed = FALSE; copy_from_to_fbw(); - uint8_t really_lost = bit_is_set(fbw_state->status, RADIO_REALLY_LOST) && (pprz_mode == PPRZ_MODE_AUTO1 || pprz_mode == PPRZ_MODE_MANUAL); + uint8_t really_lost = bit_is_set(fbw_state->status, STATUS_RADIO_REALLY_LOST) && (pprz_mode == PPRZ_MODE_AUTO1 || pprz_mode == PPRZ_MODE_MANUAL); if (pprz_mode != PPRZ_MODE_HOME && pprz_mode != PPRZ_MODE_GPS_OUT_OF_ORDER && launch) { if (too_far_from_home) { pprz_mode = PPRZ_MODE_HOME; @@ -227,7 +230,8 @@ inline void telecommand_task( void ) { mode_changed |= mcu1_status_update(); if ( mode_changed ) PERIODIC_SEND_PPRZ_MODE(); - + +#ifdef RADIO_CONTROL /** In AUTO1 mode, compute roll setpoint and pitch setpoint from * \a RADIO_ROLL and \a RADIO_PITCH \n */ @@ -247,6 +251,9 @@ inline void telecommand_task( void ) { /** else asynchronously set by v_ctl_climb_loop(); */ mcu1_ppm_cpt = fbw_state->ppm_cpt; +#endif // RADIO_CONTROL + + vsupply = fbw_state->vsupply; if (!estimator_flight_time) { @@ -381,7 +388,9 @@ void periodic_task_ap( void ) { stage_time_ds = (int16_t)(stage_time_ds+.5); stage_time++; block_time++; +#if defined DATALINK || defined SITL datalink_time++; +#endif static uint8_t t = 0; if (vsupply < LOW_BATTERY_DECIVOLT) t++; else t = 0; diff --git a/sw/airborne/sim/ppm_hw.c b/sw/airborne/sim/ppm_hw.c index 1d24cc2e42..bf9ffb1ec7 100644 --- a/sw/airborne/sim/ppm_hw.c +++ b/sw/airborne/sim/ppm_hw.c @@ -2,6 +2,7 @@ #include #include "ppm.h" +#ifdef RADIO_CONTROL uint16_t ppm_pulses[ PPM_NB_PULSES ]; volatile bool_t ppm_valid; @@ -15,3 +16,13 @@ value send_ppm(value unit) { ppm_valid = TRUE; return unit; } +#else // RADIO_CONTROL +value update_rc_channel(value c, value v) { + return Val_unit; +} + +value send_ppm(value unit) { + return unit; +} + +#endif // RADIO_CONTROL