Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
intermcu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 The Paparazzi Team
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 #ifndef INTERMCU_H
28 #define INTERMCU_H
29 
30 #include "std.h"
31 #include "modules/core/commands.h"
32 #include "pprzlink/pprz_transport.h"
33 
34 #ifndef INTERMCU_LOST_CNT
35 #define INTERMCU_LOST_CNT 25 /* 50ms with a 512Hz timer TODO fixed value */
36 #endif
37 
38 #include BOARD_CONFIG
39 
40 /* Different states the InterMCU can be in */
44 };
45 
46 #ifdef BOARD_PX4IO
47 /* InterMCU baudrate protection for PX4 */
48 enum intermcu_PX4_baud_status {
49  PX4_BAUD,
50  CHANGING_BAUD,
51  PPRZ_BAUD
52 };
53 #endif
54 
55 /* InterMCU command status bits */
61 };
62 
63 /* Easy accessible defines for cmd_status bits */
64 #define INTERMCU_SET_CMD_STATUS(_bit) { intermcu.cmd_status |= (1 << _bit); }
65 #define INTERMCU_CLR_CMD_STATUS(_bit) { intermcu.cmd_status &= ~(1 << _bit); }
66 #define INTERMCU_GET_CMD_STATUS(_bit) (intermcu.cmd_status & (1 << _bit))
67 
68 /* Main InterMCU structure */
69 struct intermcu_t {
70  struct link_device *device;
71  struct pprz_transport transport;
72  enum intermcu_status status;
74  bool enabled;
77 
78 #ifdef BOARD_PX4IO
79  enum intermcu_PX4_baud_status stable_px4_baud;
80 #endif
81 };
82 
83 extern struct intermcu_t intermcu;
84 
85 /* Functions defined in XML */
86 extern void intermcu_init(void);
87 extern void intermcu_periodic(void);
88 extern void intermcu_event(void);
89 
90 #endif
91 
Hardware independent code for commands handling.
void intermcu_event(void)
Definition: intermcu_ap.c:95
struct link_device * device
Device used for communication.
Definition: intermcu.h:70
void intermcu_periodic(void)
Definition: intermcu_ap.c:79
intermcu_status
Definition: intermcu.h:41
@ INTERMCU_LOST
No interMCU communication anymore.
Definition: intermcu.h:43
@ INTERMCU_OK
InterMCU communication is OK.
Definition: intermcu.h:42
bool enabled
If the InterMCU communication is enabled.
Definition: intermcu.h:74
intermcu_cmd_status
Definition: intermcu.h:56
@ INTERMCU_CMD_MOTORS_ON
The status of intermcu_ap_motors_on.
Definition: intermcu.h:57
@ INTERMCU_CMD_DISARM
Whether or not to dis-arm the FBW.
Definition: intermcu.h:58
@ INTERMCU_CMD_TIPPROPS
Enable tip props.
Definition: intermcu.h:59
@ INTERMCU_CMD_FAILSAFE
Set FBW in failsafe mode.
Definition: intermcu.h:60
uint8_t cmd_status
Command status information that is transfered (intermcu_cmd_status)
Definition: intermcu.h:76
struct intermcu_t intermcu
Definition: intermcu_ap.c:45
enum intermcu_status status
Status of the INTERMCU.
Definition: intermcu.h:72
bool msg_available
If we have an InterMCU message.
Definition: intermcu.h:75
uint8_t time_since_last_frame
Time since last frame.
Definition: intermcu.h:73
struct pprz_transport transport
Transport over communication line (PPRZ)
Definition: intermcu.h:71
void intermcu_init(void)
Definition: intermcu_ap.c:69
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98