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_common.c
Go to the documentation of this file.
1#include "cc2500_compat.h"
2
4
5// betaflight/src/main/rx/rx_spi_common.c @ afb2bf5
6/*
7 * This file is part of Cleanflight and Betaflight.
8 *
9 * Cleanflight and Betaflight are free software. You can redistribute
10 * this software and/or modify this software under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation, either version 3 of the License, or (at your option)
13 * any later version.
14 *
15 * Cleanflight and Betaflight are distributed in the hope that they
16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 * See the GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this software.
22 *
23 * If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include <stdbool.h>
27#include <stdint.h>
28
29//#include "platform.h"
30
31#ifdef USE_RX_SPI
32
33//#include "drivers/io.h"
34//#include "drivers/time.h"
35//#include "rx/rx_spi_common.h"
36//#include "rx/rx_spi.h"
37
38static IO_t ledPin;
39static bool ledInversion = false;
40
42static bool bindRequested;
44
66
67void rxSpiLedOn(void)
68{
69 if (ledPin) {
71 }
72}
73
74void rxSpiLedOff(void)
75{
76 if (ledPin) {
78 }
79}
80
82{
83 if (ledPin) {
85 }
86}
87
89{
90 static timeMs_t ledBlinkMs = 0;
91
92 if ((ledBlinkMs + blinkMs) > millis()) {
93 return;
94 }
96
98}
99
101{
102 static uint16_t rxLossCount = 0;
103
104 if (ledPin) {
105 if (result == RX_SPI_RECEIVED_DATA) {
106 rxLossCount = 0;
107 rxSpiLedOn();
108 } else {
110 rxLossCount++;
111 } else {
113 }
114 }
115 }
116}
117
122
123void rxSpiBind(void)
124{
125 bindRequested = true;
126}
127
129{
130 if (bindPin) {
133 bindRequested = true;
134 }
136 }
137
138 if (!bindRequested) {
139 return false;
140 } else {
141 if (reset) {
142 bindRequested = false;
143 }
144
145 return true;
146 }
147}
148#endif
static uint8_t reset[3]
@ IOCFG_IPU
@ IOCFG_OUT_PP
#define IOHi(io)
#define IOInit(io, owner, index)
uint32_t timeMs_t
#define IOGetByTag(io)
@ OWNER_RX_SPI_BIND
@ OWNER_LED
#define IO_NONE
#define IORead(gpio)
#define IOLo(io)
#define IOConfigGPIO(io, cfg)
#define millis()
#define IOToggle(io)
rx_spi_received_e
@ RX_SPI_RECEIVED_DATA
static bool lastBindPinStatus
void rxSpiLedOn(void)
void rxSpiLedOff(void)
static bool bindRequested
static bool ledInversion
static IO_t ledPin
void rxSpiLedBlinkRxLoss(rx_spi_received_e result)
void rxSpiBind(void)
void rxSpiLedToggle(void)
void rxSpiCommonIOInit(const rxSpiConfig_t *rxSpiConfig)
void rxSpiLedBlinkBind(void)
static IO_t bindPin
void rxSpiLedBlink(timeMs_t blinkMs)
bool rxSpiCheckBindRequested(bool reset)
#define INTERVAL_RX_LOSS_MS
#define INTERVAL_RX_BIND_MS
#define RX_LOSS_COUNT
const rxSpiConfig_t * rxSpiConfig(void)
uint16_t foo
Definition main_demo5.c:58
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.