Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
intermcu_dl.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freek van Tienen <freek.v.tienen@gmail.com>
3  * Copyright (C) 2022 Gautier Hattenberger <gautier.hattenberger@enac.fr>
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  */
22 
30 #include "pprzlink/intermcu_msg.h"
32 
33 #ifndef INTERMCU_DL_UPDATE_DL
34 #define INTERMCU_DL_UPDATE_DL TRUE
35 #endif
36 
38 
39 /* initialization */
40 void intermcu_dl_init(void)
41 {
42 #ifdef TELEMETRY_INTERMCU_DEV
43  intermcu_dl.dev = &(TELEMETRY_INTERMCU_DEV).device;
44 #ifdef DOWNLINK_TRANSPORT
45  intermcu_dl.trans = &(DOWNLINK_TRANSPORT).trans_tx;
46 #else // DEV defined but not transport
47 #error "TELEMETRY_INTERMCU_DEV is defined but not DOWNLINK_TRANSPORT"
48 #endif
49 #else // no DEV
50  intermcu_dl.dev = NULL;
51  intermcu_dl.trans = NULL;
52 #endif
53 }
54 
57 void intermcu_dl_repack(struct transport_tx *trans, struct link_device *dev, uint8_t *msg, uint8_t size)
58 {
59  struct pprzlink_msg pmsg;
60  pmsg.trans = trans;
61  pmsg.dev = dev;
62  pmsg.sender_id = pprzlink_get_msg_sender_id(msg);
63  pmsg.receiver_id = pprzlink_get_msg_receiver_id(msg);
64  pmsg.component_id = pprzlink_get_msg_component_id(msg);
65 
66  if (trans->check_available_space(&pmsg, _FD_ADDR, size)) {
67  trans->count_bytes(&pmsg, size);
68  trans->start_message(&pmsg, _FD, size);
69  trans->put_bytes(&pmsg, _FD, DL_TYPE_UINT8, DL_FORMAT_ARRAY, (void *) msg, size);
70  trans->end_message(&pmsg, _FD);
71  } else {
72  trans->overrun(&pmsg);
73  }
74 }
75 
80 {
81  if (intermcu_dl.dev != NULL) {
83  }
84 }
85 
86 
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
Inter-MCU interface.
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.
Definition: intermcu_dl.c:57
void intermcu_dl_on_msg(uint8_t *msg, uint8_t size)
function to forward telemetry from AP to the ground
Definition: intermcu_dl.c:79
void intermcu_dl_init(void)
Init function.
Definition: intermcu_dl.c:40
struct intermcu_dl_t intermcu_dl
Definition: intermcu_dl.c:37
datalink forwarder for InterMCU
struct link_device * dev
Device structure for communication.
Definition: intermcu_dl.h:35
struct transport_tx * trans
Forwarding transport.
Definition: intermcu_dl.h:36
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
Periodic telemetry system header (includes downlink utility and generated code).
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98