Unified the handling of the EXTI pin for SPI RX.
[betaflight.git] / src / main / rx / cyrf6936_spektrum.h
blobf1b7651a5c3d40dcb11ab5d2cf9a38f615d8877e
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <stdbool.h>
24 #include <stdint.h>
26 #define DSM_BIND_TIMEOUT_US 10000
27 #define DSM_SYNC_TIMEOUT_US 20000
28 #define DSM_RECV_LONG_TIMEOUT_US 18010
29 #define DSM_RECV_MID_TIMEOUT_US 7000
30 #define DSM_RECV_SHORT_TIMEOUT_US 4010
31 #define DSM_RECV_TIMEOUT_OFFSET_US 1000
33 #define DSM_MAX_MISSED_PACKETS 31
35 #define DSM_MAX_RF_CHANNEL 0x4F
36 #define DSM_MAX_CHANNEL_COUNT 12
37 #define DSM_INITIAL_BIND_CHANNEL 0x0D
39 #define DSM_TELEMETRY_FRAME_RPM 0x7E
40 #define DSM_TELEMETRY_TIMEOUT_US 1500
41 #define DSM_TELEMETRY_TIME_US 176000
43 typedef struct spektrumConfig_s {
44 uint8_t protocol;
45 uint8_t mfgId[4];
46 uint8_t numChannels;
47 } spektrumConfig_t;
49 PG_DECLARE(spektrumConfig_t, spektrumConfig);
51 bool spektrumSpiInit(const struct rxSpiConfig_s *rxConfig, struct rxRuntimeState_s *rxRuntimeState, rxSpiExtiConfig_t *extiConfig);
52 void spektrumSpiSetRcDataFromPayload(uint16_t *rcData, const uint8_t *payload);
53 rx_spi_received_e spektrumSpiDataReceived(uint8_t *payload);