Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
superbitrf_rc.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
26 #include "superbitrf_rc.h"
28 #include "modules/core/abi.h"
29 
30 #if RADIO_CONTROL_NB_CHANNEL < SUPERBITRF_RC_NB_CHANNEL
31 #error "RADIO_CONTROL_NB_CHANNEL mustn't be lower than 14. X-Plus channel expansion is not (yet) usable"
32 #endif
33 
38 {
41 }
42 
44 static void superbitrf_rc_normalize(int16_t *in, int16_t *out, uint8_t count)
45 {
46  uint8_t i;
47  for (i = 0; i < count; i++) {
48  if (i == RADIO_THROTTLE) {
49  out[i] = (in[i] + MAX_PPRZ) / 2;
50  Bound(out[i], 0, MAX_PPRZ);
51  } else {
52  out[i] = in[i];
53  Bound(out[i], MIN_PPRZ, MAX_PPRZ);
54  }
55  }
56 }
57 
59 {
69  AbiSendMsgRADIO_CONTROL(RADIO_CONTROL_SUPERBITRF_RC_ID, &radio_control);
71  }
72 }
Main include for ABI (AirBorneInterface).
#define RADIO_CONTROL_SUPERBITRF_RC_ID
void cyrf6936_event(struct Cyrf6936 *cyrf)
The on event call for the CYRF6936 chip.
Definition: cyrf6936.c:86
#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
static void superbitrf_rc_normalize(int16_t *in, int16_t *out, uint8_t count)
normalize superbitrf rc_values to radio values
Definition: superbitrf_rc.c:44
void superbitrf_rc_init(void)
Initialization.
Definition: superbitrf_rc.c:37
void superbitrf_rc_event(void)
RC event function.
Definition: superbitrf_rc.c:58
DSM2 and DSMX radio control implementation for the cyrf6936 2.4GHz radio chip trough SPI.
#define SUPERBITRF_RC_NB_CHANNEL
Definition: superbitrf_rc.h:32
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