35 #include "generated/airframe.h"
52 #if PERIODIC_TELEMETRY
86 #if !OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP && !OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP_IRREVERSIBLE
94 #if OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP
95 #warning WARNING DANGER: OUTBACK_CHALLENGE RULE RC_LOST_NO_AP defined. If you loose RC you will NOT go to automatically go to AUTO2 Anymore!!
96 static inline void set_failsafe_mode(
void);
103 #if OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP_IRREVERSIBLE
104 #warning WARNING DANGER: OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP_IRREVERSIBLE defined. If you ever temporarly lost RC while in manual, you will failsafe forever even if RC is restored
107 commands[COMMAND_FORCECRASH] = 9600;
155 #if defined ACTUATORS && defined INTER_MCU
159 pprz_t trimmed_commands[COMMANDS_NB];
161 for (i = 0; i < COMMANDS_NB; i++) {trimmed_commands[i] =
commands[i];}
187 void pre_inter_mcu_received_ap(
void);
188 void post_inter_mcu_received_ap(
void);
194 #define FBW_MODE_INTER_MCU_FAILSAFE FBW_MODE_AUTO
196 #if !OUTBACK_CHALLENGE_VERY_DANGEROUS_RULE_NO_AP_MUST_FAILSAFE && !OUTBACK_CHALLENGE_VERY_DANGEROUS_RULE_AP_CAN_FORCE_FAILSAFE
197 void pre_inter_mcu_received_ap(
void) {};
198 void post_inter_mcu_received_ap(
void) {};
202 #if OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP
203 #undef FBW_MODE_INTER_MCU_FAILSAFE
204 #define FBW_MODE_INTER_MCU_FAILSAFE fbw_mode
208 #if OUTBACK_CHALLENGE_VERY_DANGEROUS_RULE_NO_AP_MUST_FAILSAFE
209 #warning OUTBACK_CHALLENGE_VERY_DANGEROUS_RULE_NO_AP_MUST_FAILSAFE loose ap is forced crash
210 void pre_inter_mcu_received_ap(
void)
216 commands[COMMAND_FORCECRASH] = 9600;
219 void post_inter_mcu_received_ap(
void) {};
223 #if OUTBACK_CHALLENGE_VERY_DANGEROUS_RULE_AP_CAN_FORCE_FAILSAFE
224 #warning DANGER DANGER DANGER DANGER: Outback Challenge Rule FORCE-CRASH-RULE: DANGER DANGER:
225 #warning AP is now capable to FORCE your FBW in failsafe mode EVEN IF RC IS NOT LOST: Consider the consequences.
227 void pre_inter_mcu_received_ap(
void) {};
228 void post_inter_mcu_received_ap(
void)
230 if (
commands[COMMAND_FORCECRASH] >= 8000) {
240 static inline void set_failsafe_mode(
void)
252 inter_mcu_periodic_task();
257 #if defined MCU_UART_LINK || defined MCU_CAN_LINK
258 inter_mcu_fill_fbw_state();
268 #if defined MCU_SPI_LINK | defined MCU_UART_LINK
272 pre_inter_mcu_received_ap();
276 inter_mcu_event_task();
283 fbw_mode = FBW_MODE_INTER_MCU_FAILSAFE;
288 #if SET_AP_ONLY_COMMANDS
289 SetApOnlyCommands(
ap_state->commands);
296 inter_mcu_fill_fbw_state();
300 post_inter_mcu_received_ap();
307 inter_mcu_fill_fbw_state();
318 #if PERIODIC_TELEMETRY
321 pprz_msg_send_COMMANDS(trans, dev, AC_ID, COMMANDS_NB,
commands);
327 pprz_msg_send_FBW_STATUS(trans, dev, AC_ID,
331 static void send_rc(
struct transport_tx *trans,
struct link_device *
dev)
340 pprz_msg_send_FBW_STATUS(trans, dev, AC_ID,
348 pprz_msg_send_ACTUATORS(trans, dev, AC_ID , ACTUATORS_NB, actuators);
366 #if !(DISABLE_ELECTRICAL)
385 #if defined MCU_SPI_LINK || defined MCU_CAN_LINK
403 #if PERIODIC_TELEMETRY
451 #if !(DISABLE_ELECTRICAL)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void mcu_init(void)
Microcontroller peripherals initialization.
Communication between fbw and ap processes.
void radio_control_event(void)
Periodic telemetry system header (includes downlink utility and generated code).
pprz_t command_pitch_trim
tid_t electrical_tid
id for electrical_periodic() timer
#define PPRZ_MUTEX_LOCK(_mtx)
void fbw_datalink_periodic(void)
float vsupply
supply voltage in V
volatile bool inter_mcu_received_ap
void event_task_fbw(void)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
void fbw_datalink_event(void)
void periodic_task_fbw(void)
static void send_actuators(struct transport_tx *trans, struct link_device *dev)
void link_mcu_event_task(void)
void radio_control_init(void)
const pprz_t commands_failsafe[COMMANDS_NB]
struct ap_state * ap_state
#define RADIO_CONTROL_NB_CHANNEL
tid_t fbw_periodic_tid
id for periodic_task_fbw() timer
#define RadioControlEvent(_received_frame_handler)
Hardware independent API for actuators (servos, motor controllers).
volatile uint8_t fbw_new_actuators
void electrical_init(void)
void handle_periodic_tasks_fbw(void)
void update_actuators(void)
Common transport functions for the communication between FBW and AP.
Interface for electrical status: supply voltage, current, battery status, etc.
Architecture independent timing functions.
pprz_t command_roll_trim
Trim commands for roll, pitch and yaw.
void fbw_datalink_periodic_handle(void)
void radio_control_periodic_task(void)
void radio_lost_mode(void)
Defines behavior when the RC is lost, default goes to AUTO.
void radio_control_periodic_handle(void)
int8_t tid_t
sys_time timer id type
#define DefaultPeriodic
Set default periodic telemetry.
Hardware independent code for commands handling.
struct RadioControl radio_control
void fbw_datalink_event_handle(void)
void electrical_periodic(void)
static const struct usb_device_descriptor dev
Core autopilot interface common to all firmwares.
static void send_rc(struct transport_tx *trans, struct link_device *dev)
#define FBW_MODE_OF_PPRZ(mode)
void inter_mcu_periodic_handle(void)
Arch independent mcu ( Micro Controller Unit ) utilities.
pprz_t commands[COMMANDS_NB]
Storage of intermediate command values.
static void send_commands(struct transport_tx *trans, struct link_device *dev)
static void send_fbw_status(struct transport_tx *trans, struct link_device *dev)
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
void inter_mcu_event_handle(void)
void mcu_event(void)
MCU event functions.
struct Electrical electrical
FBW ( FlyByWire ) process API.
float current
current in A
static void handle_rc_frame(void)
Handling of messages coming from ground in FTD.
#define PPRZ_MUTEX_UNLOCK(_mtx)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
void link_mcu_periodic_task(void)
uint8_t autopilot_get_mode(void)
get autopilot mode
void periodic_telemetry_handle(void)
Architecture independent I2C (Inter-Integrated Circuit Bus) API.