From 168aa89c57b3a3754892faf87781e3d9be6e8f1a Mon Sep 17 00:00:00 2001 From: pascallanger Date: Mon, 10 Mar 2025 17:38:37 +0100 Subject: [PATCH] New SFC protocol WL91x --- Lua_scripts/MultiChan.txt | 1 + Multiprotocol/Multi.txt | 3 +- Multiprotocol/Multi_Protos.ino | 11 ++-- Multiprotocol/Multiprotocol.h | 3 +- Multiprotocol/Validate.h | 2 + Multiprotocol/WL91X_ccnrf.ino | 96 ++++++++++++++++++++++++++++++++++ Multiprotocol/_Config.h | 1 + Protocols_Details.md | 8 +++ 8 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 Multiprotocol/WL91X_ccnrf.ino diff --git a/Lua_scripts/MultiChan.txt b/Lua_scripts/MultiChan.txt index ac99315..1bb59d8 100644 --- a/Lua_scripts/MultiChan.txt +++ b/Lua_scripts/MultiChan.txt @@ -233,3 +233,4 @@ 103,0,H36,Std,1,Flip,HLess,RTH 104,0,KAMTOM,Std,0,ST_Tr,TH_Tr,TH_DR 105,0,Shenqi2,Std,1 +106,0,WL91x,Std,0 diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index 1e82678..5dab856 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -100,4 +100,5 @@ 102,JIABAILE,STD,GYRO 103,H36 104,KAMTOM -105,Shenqi2 \ No newline at end of file +105,Shenqi2 +106,WL91x \ No newline at end of file diff --git a/Multiprotocol/Multi_Protos.ino b/Multiprotocol/Multi_Protos.ino index 62af875..1b6433b 100644 --- a/Multiprotocol/Multi_Protos.ino +++ b/Multiprotocol/Multi_Protos.ino @@ -117,6 +117,7 @@ const char STR_YUXIANG[] ="YuXiang"; const char STR_UDIRC[] ="UDIRC"; const char STR_JIABAILE[] ="JIABAILE"; const char STR_KAMTOM[] ="KAMTOM"; +const char STR_WL91X[] ="WL91x"; const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20"; const char STR_SUBTYPE_HUBSAN[] = "\x04""H107""H301""H501"; @@ -504,9 +505,6 @@ const mm_protocol_definition multi_protocols[] = { #if defined(V911S_CCNRF_INO) {PROTO_V911S, STR_V911S, STR_SUBTYPE_V911S, 2, OPTION_RFTUNE, 0, 0, SW_NRF, V911S_init, V911S_callback }, #endif - #if defined(WK2x01_CYRF6936_INO) - {PROTO_WK2x01, STR_WK2x01, STR_SUBTYPE_WK2x01, 6, OPTION_NONE, 1, 1, SW_CYRF, WK_init, WK_callback }, - #endif #if defined(WFLY_CYRF6936_INO) {PROTO_WFLY, STR_WFLY, STR_SUBTYPE_WFLY, 1, OPTION_NONE, 1, 0, SW_CYRF, WFLY_init, WFLY_callback }, #endif @@ -514,6 +512,13 @@ const mm_protocol_definition multi_protocols[] = { {PROTO_WFLY2, STR_WFLY2, STR_SUBTYPE_WFLY2, 1, OPTION_OPTION, 1, 0, SW_A7105, WFLY2_init, WFLY2_callback }, // {PROTO_WFLY2, STR_WFLY2, STR_SUBTYPE_WFLY2, 1, OPTION_WBUS, 1, 0, SW_A7105, WFLY2_init, WFLY2_callback },// crash OpenTX... #endif + #if defined(WK2x01_CYRF6936_INO) + {PROTO_WK2x01, STR_WK2x01, STR_SUBTYPE_WK2x01, 6, OPTION_NONE, 1, 1, SW_CYRF, WK_init, WK_callback }, + #endif + #if defined(WL91X_CCNRF_INO) + {PROTO_WL91X, STR_WL91X, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, WL91X_init, WL91X_callback }, + #endif + #if defined(XERALL_NRF24L01_INO) {PROTO_XERALL, STR_XERALL, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, XERALL_init, XERALL_callback }, #endif diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 5d982c3..157fc7a 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 4 -#define VERSION_PATCH_LEVEL 42 +#define VERSION_PATCH_LEVEL 43 #define MODE_SERIAL 0 @@ -133,6 +133,7 @@ enum PROTOCOLS PROTO_H36 = 103, // =>NRF24L01 PROTO_KAMTOM = 104, // =>NRF24L01 PROTO_SHENQI2 = 105, // =>NRF24L01 + PROTO_WL91X = 106, // =>CC2500 & NRF24L01 PROTO_NANORF = 126, // =>NRF24L01 PROTO_TEST = 127, // =>CC2500 diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 1843629..f8444c1 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -359,6 +359,7 @@ #undef SLT_CCNRF_INO #undef UDIRC_CCNRF_INO #undef V911S_CCNRF_INO + #undef WL91X_CCNRF_INO #undef XK_CCNRF_INO #undef XK2_CCNRF_INO #endif @@ -397,6 +398,7 @@ #undef JIABAILE_NRF24L01_INO #undef UDIRC_CCNRF_INO #undef KAMTOM_NRF24L01_INO + #undef WL91X_CCNRF_INO #endif #ifdef MULTI_SURFACE diff --git a/Multiprotocol/WL91X_ccnrf.ino b/Multiprotocol/WL91X_ccnrf.ino new file mode 100644 index 0000000..60ba11c --- /dev/null +++ b/Multiprotocol/WL91X_ccnrf.ino @@ -0,0 +1,96 @@ +/* + This project is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Multiprotocol is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Multiprotocol. If not, see . + */ + +#if defined(WL91X_CCNRF_INO) + +#include "iface_xn297.h" + +//#define FORCE_WL91X_ORIGINAL_ID + +#define WL91X_PAYLOAD_SIZE 9 +#define WL91X_RF_NUM_CHANNELS 3 +#define WL91X_PACKET_PERIOD 2594 + +static void __attribute__((unused)) WL91X_send_packet() +{ + uint8_t val; + + //RF freq + XN297_Hopping(hopping_frequency_no++); + hopping_frequency_no %= WL91X_RF_NUM_CHANNELS; + + //Sticks + val = convert_channel_16b_limit(CH2,0x21,0xE0); //THR forward 00..5F, backward 80..DF + if(val < 128) val = 127 - val; + packet[0] = val - 0x80; + val = convert_channel_s8b(CH1); //ST right 00..7F, left 80..FF + packet[1] = val - 0x80; + //Trims + val = convert_channel_s8b(CH3); //ST_Trim centered=80, increment/decrement=4, right 04..7C, left 84..FC + packet[2] = val - 0x80; + packet[3] = convert_channel_16b_limit(CH4,0x00,0x70); //TH_Trim increment/decrement=3, 00..39..6F + //TX_ID + memcpy(&packet[4], rx_tx_addr, 4); + //Checksum + val = 0; + for(uint8_t i=0; i 6GSENIOR: -100% - 6G, +100% - Senior mode (turn off gyro), LIGHT: cycle the light through on-flash-off when the CH9 value is changed from -100% to 100% +## WL91X - *106* + +Models: WLtoys WL911, WL913, WL915 and may be others... + +CH1|CH2|CH3|CH4 +---|---|---|--- +ST|TH|ST_TR|TH_TR + ## XK - *62* CC2500: only X450 is supported.