29#include "pprzlink/intermcu_msg.h"
30#include "generated/modules.h"
44#if RADIO_CONTROL_NB_CHANNEL > 8
47INFO(
"InterMCU UART will only send 8 radio channels!")
52 .device = (&((INTERMCU_LINK).device)),
63#ifndef IMCU_RADIO_CONTROL_ID
64#define IMCU_RADIO_CONTROL_ID ABI_BROADCAST
73#define IMCU_GPS_ID GPS_MULTI_ID
81 pprz_transport_init(&
intermcu.transport);
111 if (
intermcu.transport.trans_rx.msg_received) {
112 for (i = 0; i <
intermcu.transport.trans_rx.payload_len; i++) {
117 intermcu.transport.trans_rx.msg_received =
false;
123 if (class_id == DL_intermcu_CLASS_ID) {
126#if TELEMETRY_INTERMCU
146 pprz_msg_send_IMCU_FBW_STATUS(&(
intermcu.transport.trans_tx),
intermcu.device, AC_ID,
153 uint8_t size = DL_IMCU_COMMANDS_values_length(buf);
154 int16_t *new_commands = DL_IMCU_COMMANDS_values(buf);
155 intermcu.cmd_status |= DL_IMCU_COMMANDS_status(buf);
161 for (
int i = 0; i < size; i++) {
171#if defined(SPEKTRUM_HAS_SOFT_BIND_PIN)
179#if TELEMETRY_INTERMCU
180 uint8_t size = (DOWNLINK_TRANSPORT).trans_rx.payload_len;
197#ifdef RADIO_KILL_SWITCH
202#ifdef RADIO_KILL_SWITCH
203#warning "RC AUX1 and KILL_SWITCH are on the same channel. AUX1 is discarded."
215 pprz_msg_send_IMCU_RADIO_COMMANDS(&(
intermcu.transport.trans_tx),
intermcu.device,
222 uint32_t stamp __attribute__((unused)),
227 pprz_msg_send_IMCU_REMOTE_GPS(&(
intermcu.transport.trans_tx),
intermcu.device, INTERMCU_FBW,
Main include for ABI (AirBorneInterface).
struct abi_struct abi_event
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
static void rc_cb(uint8_t sender_id, struct RadioControl *rc)
void WEAK dl_parse_msg(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
Should be called when chars are available in datalink uffer.
Handling of messages coming from ground and other A/Cs.
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
struct EcefCoor_i ecef_vel_int_from_gps(struct GpsState *gps_s)
Get GPS ecef velocity (integer) Converted on the fly if not available.
struct EcefCoor_i ecef_int_from_gps(struct GpsState *gps_s)
Get GPS ecef pos (integer) Converted on the fly if not available.
Device independent GPS code (interface).
int32_t hmsl
height above mean sea level (MSL) in mm
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
uint32_t sacc
speed accuracy in cm/s
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north).
uint32_t pacc
position accuracy in cm
uint16_t gspeed
norm of 2d ground speed in cm/s
uint8_t num_sv
number of sat in fix
data structure for GPS information
int32_t alt
in millimeters above WGS84 reference ellipsoid
vector in EarthCenteredEarthFixed coordinates
#define INTERMCU_LOST_CNT
@ INTERMCU_LOST
No interMCU communication anymore.
@ INTERMCU_OK
InterMCU communication is OK.
bool enabled
If the InterMCU communication is enabled.
@ INTERMCU_CMD_MOTORS_ON
The status of intermcu_ap_motors_on.
struct intermcu_t intermcu
bool msg_available
If we have an InterMCU message.
#define INTERMCU_CLR_CMD_STATUS(_bit)
#define INTERMCU_GET_CMD_STATUS(_bit)
uint8_t imcu_msg_buf[128]
The InterMCU message buffer.
void intermcu_dl_repack(struct transport_tx *trans, struct link_device *dev, uint8_t *msg, uint8_t size)
Repack message with same header and send on selected link if possible.
void intermcu_dl_on_msg(uint8_t *msg, uint8_t size)
function to forward telemetry from AP to the ground
datalink forwarder for InterMCU
void intermcu_event(void)
void intermcu_periodic(void)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
static void rc_cb(uint8_t sender_id, struct RadioControl *rc)
void intermcu_send_status(void)
send fbw status message
#define IMCU_RADIO_CONTROL_ID
void intermcu_parse_IMCU_COMMANDS(uint8_t *buf)
Datalink event functions.
void intermcu_parse_IMCU_SPEKTRUM_SOFT_BIND(uint8_t *buf)
void intermcu_forward_uplink(uint8_t *buf)
pprz_t intermcu_commands[COMMANDS_NB]
bool intermcu_ap_motors_on
Inter-MCU on FlyByWire side.
#define INTERMCU_RADIO_KILL_SWITCH
#define INTERMCU_RADIO_AUX2
#define INTERMCU_RADIO_AUX1
#define INTERMCU_RADIO_ROLL
#define INTERMCU_RADIO_YAW
#define INTERMCU_RADIO_MODE
#define INTERMCU_RADIO_CONTROL_NB_CHANNEL
#define INTERMCU_RADIO_THROTTLE
#define INTERMCU_RADIO_PITCH
#define INTERMCU_RADIO_AUX3
uint8_t fbw_mode
Fly by wire modes.
struct RadioControl radio_control
Generic interface for radio control modules.
#define RADIO_KILL_SWITCH
#define RADIO_ROLL
Redefining RADIO_* Do not use with radio.h (ppm rc).
void received_spektrum_soft_bind(void)
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.