mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-28 01:53:48 +08:00
*** empty log message ***
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#include "radio_control.h"
|
||||
|
||||
int32_t rc_values[RADIO_CTL_NB];
|
||||
uint8_t rc_status;
|
||||
int32_t avg_rc_values[RADIO_CTL_NB];
|
||||
uint8_t rc_values_contains_avg_channels = FALSE;
|
||||
uint8_t time_sime_last_ppm;
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef RADIO_CONTROL_H
|
||||
#define RADIO_CONTROL_H
|
||||
|
||||
#include "led.h"
|
||||
#include "sys_time.h"
|
||||
#include "ppm.h"
|
||||
#include "radio.h"
|
||||
|
||||
#define MAX_PPRZ 9600
|
||||
#define MIN_PPRZ -MAX_PPRZ
|
||||
|
||||
#define RC_AVG_PERIOD 8
|
||||
#define RC_LOST_TIME 10
|
||||
#define RC_REALLY_LOST_TIME 20
|
||||
|
||||
#define RC_OK 0
|
||||
#define RC_LOST 1
|
||||
#define RC_REALLY_LOST 2
|
||||
|
||||
extern int32_t rc_values[RADIO_CTL_NB];
|
||||
extern uint8_t rc_status;
|
||||
extern int32_t avg_rc_values[RADIO_CTL_NB];
|
||||
extern uint8_t rc_values_contains_avg_channels;
|
||||
extern uint8_t time_sime_last_ppm;
|
||||
|
||||
static inline void radio_control_init ( void ) {
|
||||
rc_status = RC_REALLY_LOST;
|
||||
time_sime_last_ppm = RC_REALLY_LOST_TIME;
|
||||
}
|
||||
|
||||
static inline void radio_control_periodic_task ( void ) {
|
||||
if (time_sime_last_ppm >= RC_REALLY_LOST_TIME) {
|
||||
rc_status = RC_REALLY_LOST;
|
||||
LED_OFF(1);
|
||||
}
|
||||
else {
|
||||
time_sime_last_ppm++;
|
||||
if (time_sime_last_ppm >= RC_LOST_TIME) {
|
||||
rc_status = RC_LOST;
|
||||
LED_TOGGLE(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void radio_control_ppm_event ( void ) {
|
||||
if (ppm_valid) {
|
||||
time_sime_last_ppm = 0;
|
||||
rc_status = RC_OK;
|
||||
NormalizePpm();
|
||||
LED_ON(1);
|
||||
// static uint32_t foo;
|
||||
//foo++;
|
||||
// if (!(foo%10)) {
|
||||
// PRINT_RADIO_CONTROL();
|
||||
// }
|
||||
ppm_valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* RADIO_CONTROL_H */
|
||||
Reference in New Issue
Block a user