#ifdef added to be able to compile an A/C without RC

This commit is contained in:
Pascal Brisset
2008-01-06 20:46:22 +00:00
parent 454e273779
commit 3676530d2c
4 changed files with 44 additions and 9 deletions
+10 -2
View File
@@ -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
+10 -3
View File
@@ -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;
}
+13 -4
View File
@@ -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;
+11
View File
@@ -2,6 +2,7 @@
#include <caml/mlvalues.h>
#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