Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 }
radio_control.h
uint16_t
unsigned short uint16_t
Definition: types.h:16
RadioControl::radio_ok_cpt
uint8_t radio_ok_cpt
Definition: radio_control.h:66
rxRuntimeConfig_s::rcProcessFrameFn
rcProcessFrameFnPtr rcProcessFrameFn
Definition: cc2500_rx.h:149
cc2500_init
void cc2500_init(void)
Definition: cc2500.c:43
RadioControl::time_since_last_frame
uint8_t time_since_last_frame
Definition: radio_control.h:65
send_cc2500_ppm
static void send_cc2500_ppm(struct transport_tx *trans, struct link_device *dev)
Definition: cc2500_paparazzi.c:40
RadioControl::frame_rate
uint8_t frame_rate
Definition: radio_control.h:67
cc2500Reset
uint8_t cc2500Reset(void)
Definition: cc2500.c:228
radio_control_impl_init
void radio_control_impl_init(void)
Definition: cc2500_paparazzi.c:50
cc2500_common.h
RX_FRAME_COMPLETE
@ RX_FRAME_COMPLETE
Definition: cc2500_rx.h:53
telemetry.h
rxRuntimeConfig
rxRuntimeConfig_t rxRuntimeConfig
Definition: cc2500_rx.c:131
cc2500_frsky_common.h
cc2500_settings.h
radio_control_impl_event
void radio_control_impl_event(void(*_received_frame_handler)(void))
RC event function with handler callback.
Definition: cc2500_paparazzi.c:61
dev
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
RADIO_CONTROL_NB_CHANNEL
#define RADIO_CONTROL_NB_CHANNEL
Definition: intermcu_ap.h:49
register_periodic_telemetry
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition: telemetry.c:46
rxRuntimeConfig_s::rcFrameStatusFn
rcFrameStatusFnPtr rcFrameStatusFn
Definition: cc2500_rx.h:148
RadioControl::status
uint8_t status
Definition: radio_control.h:64
rxInit
void rxInit(void)
!TODO remove this extern, only needed once for channelCount
Definition: cc2500_rx.c:263
RadioControl::frame_cpt
uint8_t frame_cpt
Definition: radio_control.h:68
frsky_raw
static uint16_t frsky_raw[RADIO_CTL_NB]
Definition: cc2500_paparazzi.c:34
cc2500_rx.h
rxRuntimeConfig_s::rcReadRawFn
rcReadRawDataFnPtr rcReadRawFn
Definition: cc2500_rx.h:147
RC_OK
#define RC_OK
Definition: radio_control.h:56
cc2500_paparazzi.h
cc2500_settings_init
void cc2500_settings_init(void)
Definition: cc2500_settings.c:159
cc2500.h
DefaultPeriodic
#define DefaultPeriodic
Set default periodic telemetry.
Definition: telemetry.h:66
radio_control
struct RadioControl radio_control
Definition: radio_control.c:30