Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
rc_datalink.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2014 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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
29 #include "modules/core/abi.h"
30 #include "pprzlink/dl_protocol.h"
31 
33 volatile bool rc_dl_frame_available;
34 
35 
36 void rc_datalink_init(void)
37 {
39  rc_dl_frame_available = false;
40 }
41 
43 {
44 #ifdef RADIO_CONTROL_DATALINK_LED
45  LED_TOGGLE(RADIO_CONTROL_DATALINK_LED);
46 #endif
47  parse_rc_up_datalink(DL_RC_UP_channels_length(buf),
48  DL_RC_UP_channels(buf));
49 }
50 
52  int8_t n,
53  int8_t *channels)
54 {
55  for (int i = 0; i < n; i++) {
56  rc_dl_values[i] = channels[i];
57  }
58  rc_dl_frame_available = true;
59 }
60 
64 static void rc_datalink_normalize(int8_t *in, int16_t *out)
65 {
66  for (int i = 0; i < RC_DL_NB_CHANNEL; i++) {
67  out[i] = (MAX_PPRZ / 128) * in[i];
68  if (i == RADIO_THROTTLE) {
69  Bound(out[i], 0, MAX_PPRZ);
70  } else {
71  Bound(out[i], MIN_PPRZ, MAX_PPRZ);
72  }
73  }
74 }
75 
77 {
84  AbiSendMsgRADIO_CONTROL(RADIO_CONTROL_DATALINK_ID, &radio_control);
85  rc_dl_frame_available = false;
86  }
87 }
Main include for ABI (AirBorneInterface).
#define RADIO_CONTROL_DATALINK_ID
#define LED_TOGGLE(i)
Definition: led_hw.h:53
#define MAX_PPRZ
Definition: paparazzi.h:8
#define MIN_PPRZ
Definition: paparazzi.h:9
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
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
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
signed char int8_t
Typedef defining 8 bit char type.
Definition: vl53l1_types.h:103