Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
telemetry_intermcu_fbw.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freek van Tienen <freek.v.tienen@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
27 #include "telemetry_intermcu.h"
28 #include "subsystems/intermcu.h"
29 #include "pprzlink/pprz_transport.h"
30 #include "pprzlink/intermcu_msg.h"
32 
33 /* Structure for handling telemetry over InterMCU */
34 struct telemetry_intermcu_t {
35  struct link_device *dev;
36  struct pprz_transport trans;
37 };
38 
39 /* Telemetry InterMCU throughput */
41 
42 /* Statically defined functions */
43 static void telemetry_intermcu_repack(struct transport_tx *trans, struct link_device *dev, uint8_t ac_id, uint8_t msg_id, uint8_t *msg, uint8_t size);
44 
45 /* InterMCU initialization */
47 {
48  // Initialize transport structure
49  pprz_transport_init(&telemetry_intermcu.trans);
50 
51  // Set the link device
52  telemetry_intermcu.dev = &(TELEMETRY_INTERMCU_DEV.device);
53 }
54 
55 /* InterMCU periodic handling of telemetry */
57 {
58 
59 }
60 
62 {
63  telemetry_intermcu_repack(&(telemetry_intermcu.trans.trans_tx), telemetry_intermcu.dev, AC_ID, msg_id, msg, size);
64 }
65 
66 static void telemetry_intermcu_repack(struct transport_tx *trans, struct link_device *dev, uint8_t ac_id, uint8_t msg_id, uint8_t *msg, uint8_t size)
67 {
68  trans->count_bytes(trans->impl, dev, trans->size_of(trans->impl, size + 2 /* msg header overhead */));
69  trans->start_message(trans->impl, dev, 0, size + 2 /* msg header overhead */);
70  trans->put_bytes(trans->impl, dev, 0, DL_TYPE_UINT8, DL_FORMAT_SCALAR, &ac_id, 1);
71  trans->put_bytes(trans->impl, dev, 0, DL_TYPE_UINT8, DL_FORMAT_SCALAR, &msg_id, 1);
72  trans->put_bytes(trans->impl, dev, 0, DL_TYPE_UINT8, DL_FORMAT_ARRAY, (void *) msg, size);
73  trans->end_message(trans->impl, dev, 0);
74 }
uint8_t ac_id
Definition: sim_ap.c:46
struct link_device dev
Device structure for communication.
struct short_transport trans
Transport without any extra encoding.
Periodic telemetry system header (includes downlink utility and generated code).
Telemetry through InterMCU.
struct link_device * dev
Device structure for communication.
static struct telemetry_intermcu_t telemetry_intermcu
void telemetry_intermcu_on_msg(uint8_t msg_id, uint8_t *msg, uint8_t size)
void telemetry_intermcu_init(void)
Rotorcraft Inter-MCU interface.
static void telemetry_intermcu_repack(struct transport_tx *trans, struct link_device *dev, uint8_t ac_id, uint8_t msg_id, uint8_t *msg, uint8_t size)
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:73
unsigned char uint8_t
Definition: types.h:14
void telemetry_intermcu_periodic(void)
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)