diff --git a/conf/airframes/plaster1.xml b/conf/airframes/plaster1.xml index bc7ecff23f..8d55076b56 100755 --- a/conf/airframes/plaster1.xml +++ b/conf/airframes/plaster1.xml @@ -4,6 +4,7 @@
+
diff --git a/sw/airborne/inter_mcu.h b/sw/airborne/inter_mcu.h index 8ad55a6290..8acd9fcc57 100644 --- a/sw/airborne/inter_mcu.h +++ b/sw/airborne/inter_mcu.h @@ -154,19 +154,18 @@ static inline void to_autopilot_from_rc_values (void) { #endif } +/** Prepares date for next comm with AP. Set ::ap_ok to TRUE */ static inline void inter_mcu_event_task( void) { - if (from_ap_receive_valid) { - from_ap_receive_valid = FALSE; - time_since_last_ap = 0; - ap_ok = TRUE; - to_autopilot_from_rc_values(); + time_since_last_ap = 0; + ap_ok = TRUE; + to_autopilot_from_rc_values(); #if defined AP - /**Directly set the flag indicating to AP that shared buffer is available*/ - from_fbw_receive_valid = TRUE; + /**Directly set the flag indicating to AP that shared buffer is available*/ + from_fbw_receive_valid = TRUE; #endif - } } +/** Monitors AP. Set ::rc_ok to false if AP is down for a long time. */ static inline void inter_mcu_periodic_task(void) { if (time_since_last_ap >= AP_STALLED_TIME) { ap_ok = FALSE; diff --git a/sw/airborne/main_fbw.c b/sw/airborne/main_fbw.c index d96fb627f2..5cd5904c99 100644 --- a/sw/airborne/main_fbw.c +++ b/sw/airborne/main_fbw.c @@ -91,15 +91,14 @@ void init_fbw( void ) { void event_task_fbw( void) { #ifdef RADIO_CONTROL - radio_control_event_task(); - if ( rc_status == RC_OK ) { + if (ppm_valid) { + ppm_valid = FALSE; + radio_control_event_task(); if (rc_values_contains_avg_channels) { fbw_mode = FBW_MODE_OF_PPRZ(rc_values[RADIO_MODE]); } if (fbw_mode == FBW_MODE_MANUAL) SetCommandsFromRC(commands); - } else if (rc_status == RC_REALLY_LOST) { - fbw_mode = FBW_MODE_AUTO; } #endif @@ -108,9 +107,12 @@ void event_task_fbw( void) { #endif #ifdef INTER_MCU - inter_mcu_event_task(); - if (ap_ok && fbw_mode == FBW_MODE_AUTO) { - SetCommands(from_ap.from_ap.commands); + if (from_ap_receive_valid) { + from_ap_receive_valid = FALSE; + inter_mcu_event_task(); + if (fbw_mode == FBW_MODE_AUTO) { + SetCommands(from_ap.from_ap.commands); + } } #endif @@ -141,6 +143,9 @@ void periodic_task_fbw( void ) { #ifdef RADIO_CONTROL radio_control_periodic_task(); + if (rc_status == RC_REALLY_LOST) { + fbw_mode = FBW_MODE_AUTO; + } #endif #ifdef INTER_MCU diff --git a/sw/airborne/radio_control.h b/sw/airborne/radio_control.h index 29eab94977..a253136c7b 100644 --- a/sw/airborne/radio_control.h +++ b/sw/airborne/radio_control.h @@ -84,24 +84,20 @@ static inline void radio_control_periodic_task ( void ) { /********** EVENT ************************************************************/ static inline void radio_control_event_task ( void ) { - if (ppm_valid) { - ppm_cpt++; - time_since_last_ppm = 0; - rc_status = RC_OK; + ppm_cpt++; + time_since_last_ppm = 0; + rc_status = RC_OK; - /** From ppm values to normalised rc_values */ - NormalizePpm(); + /** From ppm values to normalised rc_values */ + NormalizePpm(); #ifdef DEBUG_RC - uint8_t i; - for(i = 0; i < 7; i++) { - PrintHex16(uart0_transmit, rc_values[i]); - } - uart0_transmit('\n'); -#endif - - ppm_valid = FALSE; + uint8_t i; + for(i = 0; i < 7; i++) { + PrintHex16(uart0_transmit, rc_values[i]); } + uart0_transmit('\n'); +#endif } #endif /* RADIO_CONTROL */