Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cc2500_rx_spi.c
Go to the documentation of this file.
1#include "cc2500_compat.h"
2
3#include "cc2500_settings.h"
4#include "cc2500_rx_spi.h"
6
7#define UNUSED(x) (void)(x)
8
9// betaflight/src/main/rx/rx_spi.c @ 766c90b
10/*
11 * This file is part of Cleanflight and Betaflight.
12 *
13 * Cleanflight and Betaflight are free software. You can redistribute
14 * this software and/or modify this software under the terms of the
15 * GNU General Public License as published by the Free Software
16 * Foundation, either version 3 of the License, or (at your option)
17 * any later version.
18 *
19 * Cleanflight and Betaflight are distributed in the hope that they
20 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
21 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 * See the GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this software.
26 *
27 * If not, see <http://www.gnu.org/licenses/>.
28 */
29
30#include <stdbool.h>
31#include <stdint.h>
32
33//#include "platform.h"
34
35#ifdef USE_RX_SPI
36
37//#include "build/build_config.h"
38//
39//#include "common/utils.h"
40//
41//#include "config/feature.h"
42//
43//#include "drivers/rx/rx_spi.h"
44//#include "drivers/rx/rx_nrf24l01.h"
45//
46//#include "fc/config.h"
47//
48//#include "pg/rx_spi.h"
49//
50//#include "rx/rx_spi.h"
51//#include "rx/cc2500_frsky_common.h"
52//#include "rx/nrf24_cx10.h"
53//#include "rx/nrf24_syma.h"
54//#include "rx/nrf24_v202.h"
55//#include "rx/nrf24_h8_3d.h"
56//#include "rx/nrf24_inav.h"
57//#include "rx/nrf24_kn.h"
58//#include "rx/a7105_flysky.h"
59//#include "rx/cc2500_sfhss.h"
60//#include "rx/cyrf6936_spektrum.h"
61
62
65STATIC_UNIT_TESTED uint8_t rxSpiNewPacketAvailable; // set true when a new packet is received
66
71
76
90
92{
93 switch (protocol) {
94 default:
95#ifdef USE_RX_V202
101 break;
102#endif
103#ifdef USE_RX_SYMA
109 break;
110#endif
111#ifdef USE_RX_CX10
117 break;
118#endif
119#ifdef USE_RX_H8_3D
124 break;
125#endif
126#ifdef USE_RX_KN
127 case RX_SPI_NRF24_KN:
131 break;
132#endif
133#ifdef USE_RX_INAV
138 break;
139#endif
140#if defined(USE_RX_FRSKY_SPI)
141#if defined(USE_RX_FRSKY_SPI_D)
142 case RX_SPI_FRSKY_D:
143#endif
144#if defined(USE_RX_FRSKY_SPI_X)
145 case RX_SPI_FRSKY_X:
147#endif
152
153 break;
154#endif // USE_RX_FRSKY_SPI
155#ifdef USE_RX_FLYSKY
161 break;
162#endif
163#ifdef USE_RX_SFHSS_SPI
164 case RX_SPI_SFHSS:
168 break;
169#endif
170#ifdef USE_RX_SPEKTRUM
175 break;
176#endif
177 }
178 return true;
179}
180
181/*
182 * Returns true if the RX has received new data.
183 * Called from updateRx in rx.c, updateRx called from taskUpdateRxCheck.
184 * If taskUpdateRxCheck returns true, then taskUpdateRxMain will shortly be called.
185 */
205
207{
209
212
213 if (result & RX_SPI_RECEIVED_DATA) {
215 }
216
217 if (result & RX_SPI_ROCESSING_REQUIRED) {
218 return false;
219 }
220 }
221
222 return true;
223}
224
225/*
226 * Set and initialize the RX protocol
227 */
248#endif
static uint8_t status
#define STATIC_UNIT_TESTED
#define rxSpiDeviceInit(rxSpiConfig)
#define STATIC_ASSERT(...)
#define RX_SPI_MAX_PAYLOAD_SIZE
rx_spi_received_e frSkySpiDataReceived(uint8_t *packet)
void frSkySpiSetRcData(uint16_t *rcData, const uint8_t *payload)
rx_spi_received_e frSkySpiProcessFrame(uint8_t *packet)
bool frSkySpiInit(const rxSpiConfig_t *rxSpiConfig, rxRuntimeConfig_t *rxRuntimeConfig)
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]
Definition cc2500_rx.c:118
rxRuntimeConfig_t rxRuntimeConfig
Definition cc2500_rx.c:131
#define MAX_SUPPORTED_RC_CHANNEL_COUNT
Definition cc2500_rx.h:78
@ RX_FRAME_PENDING
Definition cc2500_rx.h:52
@ RX_FRAME_COMPLETE
Definition cc2500_rx.h:53
@ RX_FRAME_PROCESSING_REQUIRED
Definition cc2500_rx.h:55
rcFrameStatusFnPtr rcFrameStatusFn
Definition cc2500_rx.h:148
uint8_t channelCount
Definition cc2500_rx.h:145
uint16_t rxRefreshRate
Definition cc2500_rx.h:146
rcProcessFrameFnPtr rcProcessFrameFn
Definition cc2500_rx.h:149
rcReadRawDataFnPtr rcReadRawFn
Definition cc2500_rx.h:147
rx_spi_received_e(* protocolDataReceivedFnPtr)(uint8_t *payload)
static protocolSetRcDataFromPayloadFnPtr protocolSetRcDataFromPayload
static bool rxSpiProcessFrame(const rxRuntimeConfig_t *rxRuntimeConfig)
static protocolInitFnPtr protocolInit
STATIC_UNIT_TESTED bool rxSpiSetProtocol(rx_spi_protocol_e protocol)
rx_spi_received_e(* protocolProcessFrameFnPtr)(uint8_t *payload)
uint16_t rxSpiRcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]
static protocolDataReceivedFnPtr protocolDataReceived
bool rxSpiInit(const rxSpiConfig_t *rxSpiConfig, rxRuntimeConfig_t *rxRuntimeConfig)
static protocolProcessFrameFnPtr protocolProcessFrame
bool(* protocolInitFnPtr)(const rxSpiConfig_t *rxSpiConfig, rxRuntimeConfig_t *rxRuntimeConfig)
#define UNUSED(x)
STATIC_UNIT_TESTED uint8_t rxSpiPayload[RX_SPI_MAX_PAYLOAD_SIZE]
STATIC_UNIT_TESTED uint8_t rxSpiNewPacketAvailable
void(* protocolSetRcDataFromPayloadFnPtr)(uint16_t *rcData, const uint8_t *payload)
static uint8_t rxSpiFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig)
STATIC_UNIT_TESTED uint16_t rxSpiReadRawRC(const rxRuntimeConfig_t *rxRuntimeConfig, uint8_t channel)
rx_spi_protocol_e
@ RX_SPI_NRF24_INAV
@ RX_SPI_A7105_FLYSKY_2A
@ RX_SPI_NRF24_KN
@ RX_SPI_CYRF6936_DSM
@ RX_SPI_NRF24_SYMA_X
@ RX_SPI_NRF24_CX10A
@ RX_SPI_FRSKY_X
@ RX_SPI_SFHSS
@ RX_SPI_NRF24_SYMA_X5C
@ RX_SPI_NRF24_CX10
@ RX_SPI_NRF24_H8_3D
@ RX_SPI_NRF24_V202_1M
@ RX_SPI_FRSKY_D
@ RX_SPI_FRSKY_X_LBT
@ RX_SPI_A7105_FLYSKY
@ RX_SPI_NRF24_V202_250K
rx_spi_received_e
@ RX_SPI_ROCESSING_REQUIRED
@ RX_SPI_RECEIVED_DATA
const rxSpiConfig_t * rxSpiConfig(void)
uint8_t rx_spi_protocol
uint16_t foo
Definition main_demo5.c:58
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.