1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Spectrum bind code to be more geenic

Actualy only activated for the NAZE taget for USART2

#define SPEKTRUM_BIND
#define BIND_PORT  GPIOA
#define BIND_PIN   Pin_3

This is to activate the Hardware bind pug feature
#define HARDWARE_BIND_PLUG
#define BINDPLUG_PORT  GPIOB
#define BINDPLUG_PIN   Pin_5

can now be easyly added and configured for other tagets after testing.
This commit is contained in:
Michael Jakob 2014-12-01 14:10:28 +01:00 committed by Dominic Clifton
parent 3aaaa3f9f5
commit 1766857da6
3 changed files with 14 additions and 7 deletions

View file

@ -150,6 +150,7 @@ void init(void)
systemInit(); systemInit();
#ifdef SPEKTRUM_BIND
// Spektrum sattelite bind - ported from Baseflight // Spektrum sattelite bind - ported from Baseflight
if (feature(FEATURE_RX_SERIAL)) { if (feature(FEATURE_RX_SERIAL)) {
switch (masterConfig.rxConfig.serialrx_provider) { switch (masterConfig.rxConfig.serialrx_provider) {
@ -162,6 +163,7 @@ void init(void)
break; break;
} }
} }
#endif
delay(100); delay(100);

View file

@ -43,8 +43,6 @@
#define SPEKTRUM_BAUDRATE 115200 #define SPEKTRUM_BAUDRATE 115200
#define BKP_SOFTRESET (0x50F7B007)
static uint8_t spek_chan_shift; static uint8_t spek_chan_shift;
static uint8_t spek_chan_mask; static uint8_t spek_chan_mask;
static bool rcFrameComplete = false; static bool rcFrameComplete = false;
@ -144,6 +142,9 @@ static uint16_t spektrumReadRawRC(rxRuntimeConfig_t *rxRuntimeConfig, uint8_t ch
return data; return data;
} }
#ifdef SPEKTRUM_BIND
#define BKP_SOFTRESET (0x50F7B007)
uint32_t rccReadBkpDr(void) uint32_t rccReadBkpDr(void)
{ {
return *((uint16_t *)BKP_BASE + 0x04) | *((uint16_t *)BKP_BASE + 0x08) << 16; return *((uint16_t *)BKP_BASE + 0x04) | *((uint16_t *)BKP_BASE + 0x08) << 16;
@ -151,7 +152,6 @@ uint32_t rccReadBkpDr(void)
/* spektrumBind function ported from Baseflight. It's used to bind satellite receiver to TX. /* spektrumBind function ported from Baseflight. It's used to bind satellite receiver to TX.
* Function must be called immediately after startup so that we don't miss satellite bind window. * Function must be called immediately after startup so that we don't miss satellite bind window.
* It will only work for USART2, PA3 pin.
* Known parameters. Tested with DSMX satellite and DX8 radio. Framerate (11ms or 22ms) must be selected from TX. * Known parameters. Tested with DSMX satellite and DX8 radio. Framerate (11ms or 22ms) must be selected from TX.
* 9 = DSMX 11ms / DSMX 22ms * 9 = DSMX 11ms / DSMX 22ms
* 5 = DSM2 11ms 2048 / DSM2 22ms 1024 * 5 = DSM2 11ms 2048 / DSM2 22ms 1024
@ -168,8 +168,8 @@ void spektrumBind(rxConfig_t *rxConfig)
GPIO_TypeDef *hwBindPort; GPIO_TypeDef *hwBindPort;
uint16_t hwBindPin; uint16_t hwBindPin;
hwBindPort = GPIOB; hwBindPort = BINDPLUG_PORT;
hwBindPin = Pin_5; hwBindPin = BINDPLUG_PIN;
gpio.speed = Speed_2MHz; gpio.speed = Speed_2MHz;
gpio.pin = hwBindPin; gpio.pin = hwBindPin;
gpio.mode = Mode_IPU; gpio.mode = Mode_IPU;
@ -180,8 +180,8 @@ void spektrumBind(rxConfig_t *rxConfig)
#endif #endif
// USART2, PA3 // USART2, PA3
spekBindPort = GPIOA; spekBindPort = BIND_PORT;
spekBindPin = Pin_3; spekBindPin = BIND_PIN;
// don't try to bind if: here after soft reset or bind flag is out of range // don't try to bind if: here after soft reset or bind flag is out of range
if (rccReadBkpDr() == BKP_SOFTRESET || rxConfig->spektrum_sat_bind == 0 || rxConfig->spektrum_sat_bind > 10) if (rccReadBkpDr() == BKP_SOFTRESET || rxConfig->spektrum_sat_bind == 0 || rxConfig->spektrum_sat_bind > 10)
@ -215,3 +215,4 @@ void spektrumBind(rxConfig_t *rxConfig)
#endif #endif
} }
#endif

View file

@ -112,3 +112,7 @@
#define TELEMETRY #define TELEMETRY
#define SERIAL_RX #define SERIAL_RX
#define AUTOTUNE #define AUTOTUNE
#define SPEKTRUM_BIND
#define BIND_PORT GPIOA
#define BIND_PIN Pin_3