34 #define MSG_INTERMCU_COMMAND_MASTER_ID 0x01
35 #define MSG_INTERMCU_COMMAND_EXTRA_ID 0x02
37 #define MSG_INTERMCU_RADIO_LOW_ID 0x04
38 #define MSG_INTERMCU_RADIO_HIGH_ID 0x05
40 #define MSG_INTERMCU_TRIM_ID 0x09
42 #define MSG_INTERMCU_FBW_STATUS_ID 0x10
50 #define INTERMCU_COMMAND(_intermcu_payload, nr) (pprz_t)((uint16_t)(*((uint8_t*)_intermcu_payload+0+(2*(nr)))|*((uint8_t*)_intermcu_payload+1+(2*(nr)))<<8))
60 #error "INTERMCU_CAN CAN ONLY SEND 4 OR 8 COMMANDS (packets of 8 bytes)"
62 #if RADIO_CONTROL_NB_CHANNEL > 8
63 #warning "INTERMCU_CAN CAN ONLY SEND 8 RADIO CHANNELS: CHANNELS 9 and higher will not be sent"
68 for (
int i = 0; (i < 4) && (i < COMMANDS_NB); i++) {
78 for (
int i = 0; (i < 4) && (i < (COMMANDS_NB - 4)); i++) {
105 fbw_state->vsupply = data[3] + (data[4] << 8);
122 for (
int i = 0; (i < COMMANDS_NB) && (i < 4); i++) {
125 for (
int i = 0; (i < (COMMANDS_NB - 4)) && (i < 4); i++) {
143 inter_mcu_fill_fbw_state();
147 intermcu_tx_buff[0] =
fbw_state->ppm_cpt;
154 #if defined RADIO_CONTROL || RADIO_CONTROL_AUTO1
184 #define RC_REALLY_LOST 2
187 static void send_commands(
struct transport_tx *trans,
struct link_device *
dev)
189 pprz_msg_send_COMMANDS(trans, dev, AC_ID, COMMANDS_NB,
ap_state->commands);
196 if (bit_is_set(
fbw_state->status, STATUS_MODE_AUTO)) {
199 if (bit_is_set(
fbw_state->status, STATUS_MODE_FAILSAFE)) {
202 if (bit_is_set(
fbw_state->status, STATUS_RADIO_REALLY_LOST)) {
209 pprz_msg_send_FBW_STATUS(trans, dev, AC_ID,
219 #if PERIODIC_TELEMETRY
static struct fbw_status_t fbw_status
Periodic telemetry system header (includes downlink utility and generated code).
#define MSG_INTERMCU_RADIO_LOW_ID
volatile bool inter_mcu_received_ap
void ppz_can_init(can_rx_callback_t callback)
struct fbw_state * fbw_state
void link_mcu_event_task(void)
void(* can_rx_callback_t)(uint32_t id, uint8_t *buf, uint8_t len)
struct ap_state * ap_state
struct link_mcu_msg link_mcu_from_ap_msg
int ppz_can_transmit(uint32_t id, const uint8_t *buf, uint8_t len)
#define MSG_INTERMCU_TRIM_ID
struct link_mcu_msg link_mcu_from_fbw_msg
#define MSG_INTERMCU_RADIO_HIGH_ID
#define MSG_INTERMCU_COMMAND_EXTRA_ID
#define DefaultPeriodic
Set default periodic telemetry.
Hardware independent code for commands handling.
Transport for the communication between FBW and AP via CAN.
#define RADIO_CONTROL_NB_CHANNEL
static const struct usb_device_descriptor dev
volatile bool inter_mcu_received_fbw
#define MSG_INTERMCU_COMMAND_MASTER_ID
static void send_fbw_status(struct transport_tx *trans, struct link_device *dev)
static void send_commands(struct transport_tx *trans, struct link_device *dev)
arch independent LED (Light Emitting Diodes) API
#define MSG_INTERMCU_FBW_STATUS_ID
void link_mcu_on_can_msg(uint32_t id, uint8_t *data, int len)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
void link_mcu_periodic_task(void)
#define INTERMCU_COMMAND(_intermcu_payload, nr)