44 #include "generated/airframe.h"
52 #if defined RADIO_CONTROL || RADIO_CONTROL_AUTO1
71 #define STATUS_RADIO_OK 0
72 #define STATUS_RADIO_REALLY_LOST 1
73 #define STATUS_MODE_AUTO 2
74 #define STATUS_MODE_FAILSAFE 3
75 #define AVERAGED_CHANNELS_SENT 4
76 #define MASK_FBW_CHANGED 0xf
111 ap_state->commands[
cmd_idx] = cmd;
118 static inline pprz_t imcu_get_roll_trim(
void)
121 pprz_t val = ap_state->command_roll_trim;
129 static inline void imcu_set_roll_trim(
pprz_t roll_trim)
132 ap_state->command_roll_trim = roll_trim;
139 static inline pprz_t imcu_get_pitch_trim(
void)
142 pprz_t val = ap_state->command_pitch_trim;
150 static inline void imcu_set_pitch_trim(
pprz_t pitch_trim)
153 ap_state->command_pitch_trim = pitch_trim;
160 static inline pprz_t imcu_get_yaw_trim(
void)
171 static inline void imcu_set_yaw_trim(
pprz_t yaw_trim)
174 ap_state->command_yaw_trim = yaw_trim;
178 #if defined RADIO_CONTROL || RADIO_CONTROL_AUTO1
186 pprz_t val = fbw_state->channels[radio_idx];
195 static inline void imcu_set_radio(
uint8_t radio_idx,
pprz_t radio)
198 fbw_state->channels[radio_idx] = radio;
205 static inline uint8_t imcu_get_ppm_cpt(
void)
216 static inline void imcu_set_ppm_cpt(
uint8_t ppm_cpt)
219 fbw_state->ppm_cpt = ppm_cpt;
227 static inline uint8_t imcu_get_status(
void)
241 fbw_state->status =
status;
250 static inline void imcu_get_electrical(
uint16_t *_vsupply,
int32_t *_current,
float *_energy)
253 *_vsupply = fbw_state->vsupply;
254 *_current = fbw_state->current;
255 *_energy = fbw_state->energy;
264 static inline void imcu_set_electrical(
uint16_t _vsupply,
int32_t _current,
float _energy)
267 fbw_state->vsupply = _vsupply;
268 fbw_state->current = _current;
269 fbw_state->energy = _energy;
275 extern uint8_t time_since_last_ap;
278 #define AP_STALLED_TIME 30 // 500ms with a 60Hz timer
281 static inline void inter_mcu_init(
void)
283 fbw_state->status = 0;
284 fbw_state->nb_err = 0;
294 static inline void inter_mcu_fill_fbw_state(
void)
311 #endif // RADIO_CONTROL
315 fbw_state->status =
status;
320 #if defined SINGLE_MCU
328 static inline void inter_mcu_event_task(
void)
330 time_since_last_ap = 0;
335 static inline void inter_mcu_periodic_task(
void)
337 if (time_since_last_ap >= AP_STALLED_TIME) {
341 inter_mcu_fill_fbw_state();
345 time_since_last_ap++;
int32_t current
current in milliamps
uint16_t vsupply
Supply voltage in deciVolt.
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
int32_t current
Supply current in milliAmpere.
struct ap_state * ap_state
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)
#define RADIO_CONTROL_NB_CHANNEL
volatile bool inter_mcu_received_fbw
Utility functions and macros to abstract some RTOS functionalities such as mutexes.
float energy
Energy consumption (mAh) This is the ap copy of the measurement from fbw.
pprz_t commands[COMMANDS_NB]
Storage of intermediate command values.
uint16_t vsupply
supply voltage in decivolts
float energy
consumed energy in mAh
struct Electrical electrical
FBW ( FlyByWire ) process API.
#define PPRZ_MUTEX_UNLOCK(_mtx)