29 #include "pprzlink/intermcu_msg.h"
30 #include "generated/modules.h"
33 #if TELEMETRY_INTERMCU
44 #include "libopencm3/cm3/scb.h"
47 static uint8_t px4RebootSequence[] = {0x41, 0xd7, 0x32, 0x0a, 0x46, 0x39};
48 static uint8_t px4RebootSequenceCount = 0;
52 #if RADIO_CONTROL_NB_CHANNEL > 8
55 INFO(
"InterMCU UART will only send 8 radio channels!")
71 static void checkPx4RebootCommand(
unsigned char b);
75 #ifndef IMCU_RADIO_CONTROL_ID
76 #define IMCU_RADIO_CONTROL_ID ABI_BROADCAST
85 #define IMCU_GPS_ID GPS_MULTI_ID
127 checkPx4RebootCommand(c);
144 if (class_id == DL_intermcu_CLASS_ID) {
147 #if TELEMETRY_INTERMCU
174 uint8_t size = DL_IMCU_COMMANDS_values_length(buf);
175 int16_t *new_commands = DL_IMCU_COMMANDS_values(buf);
182 for (
int i = 0; i < size; i++) {
192 #if defined(SPEKTRUM_HAS_SOFT_BIND_PIN)
200 #if TELEMETRY_INTERMCU
201 uint8_t size = (DOWNLINK_TRANSPORT).trans_rx.payload_len;
218 #ifdef RADIO_KILL_SWITCH
223 #ifdef RADIO_KILL_SWITCH
224 #warning "RC AUX1 and KILL_SWITCH are on the same channel. AUX1 is discarded."
243 uint32_t stamp __attribute__((unused)),
265 static void checkPx4RebootCommand(
uint8_t b)
270 intermcu.stable_px4_baud = PPRZ_BAUD;
271 }
else if (
intermcu.stable_px4_baud == PX4_BAUD) {
281 intermcu.stable_px4_baud = CHANGING_BAUD;
290 if (
b == px4RebootSequence[px4RebootSequenceCount]) {
291 px4RebootSequenceCount++;
293 px4RebootSequenceCount = 0;
296 if (px4RebootSequenceCount >= 6) {
297 px4RebootSequenceCount = 0;
Main include for ABI (AirBorneInterface).
Event structure to store callbacks in a linked list.
Handling of messages coming from ground and other A/Cs.
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
float vsupply
supply voltage in V
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)
struct EcefCoor_i ecef_pos
position in ECEF in cm
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
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
struct link_device * device
Device used for communication.
#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.
uint8_t cmd_status
Command status information that is transfered (intermcu_cmd_status)
enum intermcu_status status
Status of the INTERMCU.
bool msg_available
If we have an InterMCU message.
uint8_t time_since_last_frame
Time since last frame.
#define INTERMCU_CLR_CMD_STATUS(_bit)
struct pprz_transport transport
Transport over communication line (PPRZ)
#define INTERMCU_GET_CMD_STATUS(_bit)
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
struct intermcu_t intermcu
uint8_t imcu_msg_buf[256]
The InterMCU message buffer.
#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
arch independent LED (Light Emitting Diodes) API
void uart_periph_set_baudrate(struct uart_periph *periph, uint32_t baud)
uint8_t fbw_mode
Fly by wire modes.
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define RADIO_KILL_SWITCH
#define RADIO_ROLL
Redefining RADIO_* Do not use with radio.h (ppm rc)
void dl_parse_msg(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
Should be called when chars are available in dl_buffer.
void received_spektrum_soft_bind(void)
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
void sys_time_cancel_timer(tid_t id)
Cancel a system timer by id.
Architecture independent timing functions.
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
int8_t tid_t
sys_time timer id type
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.