mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 20:38:27 +08:00
event handling rewritten
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<section name="adc" prefix="ADC_CHANNEL_">
|
||||
<define name="IR1" value="1"/>
|
||||
<define name="IR2" value="0"/>
|
||||
<define name="VSUPPLY" value="3"/>
|
||||
<define name="IR_NB_SAMPLES" value="16"/>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+12
-7
@@ -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
|
||||
|
||||
+10
-14
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user