Paparazzi UAS  v5.17_devel-24-g2ae834f
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cc2500_paparazzi.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Tom van Dijk <tomvand@users.noreply.github.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 #include "cc2500_paparazzi.h"
23 
25 #include "peripherals/cc2500.h"
26 #include "cc2500_common.h"
27 #include "cc2500_frsky_common.h"
28 #include "cc2500_settings.h"
29 #include "cc2500_rx.h"
30 
31 #include <stdint.h>
32 
33 
34 static uint16_t frsky_raw[RADIO_CTL_NB];
35 
36 
37 #if PERIODIC_TELEMETRY
39 
40 static void send_cc2500_ppm(struct transport_tx *trans, struct link_device *dev)
41 {
42  pprz_msg_send_PPM(trans, dev, AC_ID,
44  (sizeof(frsky_raw) / sizeof(frsky_raw[0])),
45  frsky_raw);
46 }
47 #endif
48 
49 
52  cc2500_init();
53  cc2500Reset();
54  rxInit();
55 #if PERIODIC_TELEMETRY
57 #endif
58 }
59 
60 
61 void radio_control_impl_event(void (* _received_frame_handler)(void)) {
66  if (radio_control.radio_ok_cpt > 0) {
68  } else {
70  for (int i = 0; i < RADIO_CONTROL_NB_CHANNEL; ++i) {
72  }
73  NormalizePpmIIR(frsky_raw, radio_control);
74  _received_frame_handler();
75  }
76  }
77 }
unsigned short uint16_t
Definition: types.h:16
void cc2500_settings_init(void)
Periodic telemetry system header (includes downlink utility and generated code).
uint8_t radio_ok_cpt
Definition: radio_control.h:66
uint8_t status
Definition: radio_control.h:64
rxRuntimeConfig_t rxRuntimeConfig
Definition: cc2500_rx.c:131
static uint16_t frsky_raw[RADIO_CTL_NB]
#define RADIO_CONTROL_NB_CHANNEL
Definition: intermcu_ap.h:49
void radio_control_impl_init(void)
static void send_cc2500_ppm(struct transport_tx *trans, struct link_device *dev)
rcFrameStatusFnPtr rcFrameStatusFn
Definition: cc2500_rx.h:148
#define DefaultPeriodic
Set default periodic telemetry.
Definition: telemetry.h:66
rcReadRawDataFnPtr rcReadRawFn
Definition: cc2500_rx.h:147
struct RadioControl radio_control
Definition: radio_control.c:30
#define RC_OK
Definition: radio_control.h:56
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
void rxInit(void)
!TODO remove this extern, only needed once for channelCount
Definition: cc2500_rx.c:263
void cc2500_init(void)
Definition: cc2500.c:43
uint8_t time_since_last_frame
Definition: radio_control.h:65
rcProcessFrameFnPtr rcProcessFrameFn
Definition: cc2500_rx.h:149
void radio_control_impl_event(void(*_received_frame_handler)(void))
RC event function with handler callback.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition: telemetry.c:46
uint8_t frame_cpt
Definition: radio_control.h:68
uint8_t frame_rate
Definition: radio_control.h:67
uint8_t cc2500Reset(void)
Definition: cc2500.c:228