Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
rc_intermcu.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
29 #include "pprzlink/intermcu_msg.h"
30 #include "modules/core/abi.h"
31 
32 struct _rc_intermcu {
36 };
37 
38 static struct _rc_intermcu rc_intermcu;
39 
40 void rc_intermcu_init(void)
41 {
45  for (int i = 0; i < RC_IMCU_NB_CHANNEL; i++) {
46  rc_intermcu.values[i] = 0;
47  }
48 }
49 
50 
52 {
53  uint8_t size = DL_IMCU_RADIO_COMMANDS_values_length(buf);
54  //rc_intermcu.status = DL_IMCU_RADIO_COMMANDS_status(imcu_msg_buf); TODO change status on FBW side to have RC status here
55  for (uint8_t i = 0; i < size; i++) {
56  rc_intermcu.values[i] = DL_IMCU_RADIO_COMMANDS_values(buf)[i];
57  radio_control.values[i] = rc_intermcu.values[i]; // for now a simple copy
58  }
59 
64  AbiSendMsgRADIO_CONTROL(RADIO_CONTROL_INTERMCU_ID, &radio_control);
65 }
66 
68 {
69  // update status and frame rate, send message for mode update
70  rc_intermcu.status = DL_IMCU_FBW_STATUS_rc_status(buf);
71  rc_intermcu.frame_rate = DL_IMCU_FBW_STATUS_frame_rate(buf);
72  AbiSendMsgRADIO_CONTROL(RADIO_CONTROL_INTERMCU_ID, &radio_control);
73 }
74 
Main include for ABI (AirBorneInterface).
#define RADIO_CONTROL_INTERMCU_ID
struct RadioControl radio_control
Definition: radio_control.c:33
Generic interface for radio control modules.
uint8_t time_since_last_frame
Definition: radio_control.h:62
#define RC_REALLY_LOST
Definition: radio_control.h:51
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:67
uint8_t status
Definition: radio_control.h:61
uint8_t radio_ok_cpt
Definition: radio_control.h:63
uint8_t frame_cpt
Definition: radio_control.h:65
#define RC_OK
Definition: radio_control.h:49
uint8_t nb_channel
Definition: radio_control.h:66
void rc_intermcu_init(void)
RC init function.
Definition: rc_intermcu.c:40
uint8_t frame_rate
Definition: rc_intermcu.c:35
void rc_intermcu_parse_fbw_status(uint8_t *buf)
Definition: rc_intermcu.c:67
static struct _rc_intermcu rc_intermcu
Definition: rc_intermcu.c:38
uint8_t status
Definition: rc_intermcu.c:34
void rc_intermcu_parse_msg(uint8_t *buf)
Decode intermcu message to get rc values and FBW status for RC status and frame rate TODO make a sing...
Definition: rc_intermcu.c:51
uint16_t values[RC_IMCU_NB_CHANNEL]
Definition: rc_intermcu.c:33
Radio control input via intermcu.
#define RC_IMCU_NB_CHANNEL
Definition: rc_intermcu.h:45
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98