44 #include "generated/airframe.h"
52 #if defined RADIO_CONTROL || RADIO_CONTROL_AUTO1
69 #define STATUS_RADIO_OK 0
70 #define STATUS_RADIO_REALLY_LOST 1
71 #define STATUS_MODE_AUTO 2
72 #define STATUS_MODE_FAILSAFE 3
73 #define AVERAGED_CHANNELS_SENT 4
74 #define MASK_FBW_CHANGED 0xf
109 ap_state->commands[
cmd_idx] = cmd;
116 static inline pprz_t imcu_get_roll_trim(
void)
119 pprz_t val = ap_state->command_roll_trim;
127 static inline void imcu_set_roll_trim(
pprz_t roll_trim)
130 ap_state->command_roll_trim = roll_trim;
137 static inline pprz_t imcu_get_pitch_trim(
void)
140 pprz_t val = ap_state->command_pitch_trim;
148 static inline void imcu_set_pitch_trim(
pprz_t pitch_trim)
151 ap_state->command_pitch_trim = pitch_trim;
158 static inline pprz_t imcu_get_yaw_trim(
void)
169 static inline void imcu_set_yaw_trim(
pprz_t yaw_trim)
172 ap_state->command_yaw_trim = yaw_trim;
176 #if defined RADIO_CONTROL || RADIO_CONTROL_AUTO1
184 pprz_t val = fbw_state->channels[radio_idx];
193 static inline void imcu_set_radio(
uint8_t radio_idx,
pprz_t radio)
196 fbw_state->channels[radio_idx] = radio;
203 static inline uint8_t imcu_get_ppm_cpt(
void)
214 static inline void imcu_set_ppm_cpt(
uint8_t ppm_cpt)
217 fbw_state->ppm_cpt = ppm_cpt;
225 static inline uint8_t imcu_get_status(
void)
239 fbw_state->status =
status;
246 static inline void imcu_get_electrical(
struct Electrical *_electrical)
249 *_electrical = fbw_state->electrical;
256 static inline void imcu_set_electrical(
struct Electrical *_electrical)
259 fbw_state->electrical = *_electrical;
265 extern uint8_t time_since_last_ap;
268 #define AP_STALLED_TIME 30 // 500ms with a 60Hz timer
271 static inline void inter_mcu_init(
void)
273 fbw_state->status = 0;
274 fbw_state->nb_err = 0;
284 static inline void inter_mcu_fill_fbw_state(
void)
301 #endif // RADIO_CONTROL
305 fbw_state->status =
status;
308 #if defined SINGLE_MCU
316 static inline void inter_mcu_event_task(
void)
318 time_since_last_ap = 0;
323 static inline void inter_mcu_periodic_task(
void)
325 if (time_since_last_ap >= AP_STALLED_TIME) {
329 inter_mcu_fill_fbw_state();
333 time_since_last_ap++;
pprz_t command_pitch_trim
#define PPRZ_MUTEX_LOCK(_mtx)
volatile bool inter_mcu_received_ap
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
struct fbw_state * fbw_state
struct ap_state * ap_state
#define RADIO_CONTROL_NB_CHANNEL
Interface for electrical status: supply voltage, current, battery status, etc.
pprz_t command_roll_trim
Trim commands for roll, pitch and yaw.
#define PPRZ_MUTEX_DECL(_mtx)
struct RadioControl radio_control
#define PPRZ_MUTEX_INIT(_mtx)
volatile bool inter_mcu_received_fbw
Utility functions and macros to abstract some RTOS functionalities such as mutexes.
pprz_t commands[COMMANDS_NB]
Storage of intermediate command values.
struct Electrical electrical
FBW ( FlyByWire ) process API.
#define PPRZ_MUTEX_UNLOCK(_mtx)