1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 22:05:17 +03:00

bring betaflight up to par with serial1wire-blheli-multiesc

This commit is contained in:
nathan 2015-09-02 20:46:51 -07:00
parent d7ad58412c
commit 80be01e530
3 changed files with 10 additions and 13 deletions

View file

@ -75,13 +75,14 @@ static void gpio_set_mode(GPIO_TypeDef* gpio, uint16_t pin, GPIO_Mode mode) {
void usb1WireInitialize() void usb1WireInitialize()
{ {
for (volatile uint8_t i = 0; i<ESC_COUNT ; i++){ for (volatile uint8_t i = 0; i < ESC_COUNT; i++) {
gpio_set_mode(escHardware[i].gpio, (1U << escHardware[i].pinpos), Mode_IPU); //GPIO_Mode_IPU gpio_set_mode(escHardware[i].gpio, (1U << escHardware[i].pinpos), Mode_IPU); //GPIO_Mode_IPU
} }
} }
#ifdef STM32F10X #ifdef STM32F10X
static volatile uint32_t in_cr_mask, out_cr_mask; static volatile uint32_t in_cr_mask, out_cr_mask;
static __IO uint32_t *cr; static __IO uint32_t *cr;
static void gpio_prep_vars(uint16_t escIndex) static void gpio_prep_vars(uint16_t escIndex)
{ {

View file

@ -2138,8 +2138,6 @@ static void cliUSB1Wire(char *cmdline)
printf("Invalid motor port, valid range: 1 to %d\r\n", ESC_COUNT); printf("Invalid motor port, valid range: 1 to %d\r\n", ESC_COUNT);
} }
} }
UNUSED(cmdline);
StopPwmAllMotors();
// motor 1 => index 0 // motor 1 => index 0
usb1WirePassthrough(i-1); usb1WirePassthrough(i-1);
} }

View file

@ -313,7 +313,7 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
#define MSP_GPSSVINFO 164 //out message get Signal Strength (only U-Blox) #define MSP_GPSSVINFO 164 //out message get Signal Strength (only U-Blox)
#define MSP_SERVO_MIX_RULES 241 //out message Returns servo mixer configuration #define MSP_SERVO_MIX_RULES 241 //out message Returns servo mixer configuration
#define MSP_SET_SERVO_MIX_RULE 242 //in message Sets servo mixer configuration #define MSP_SET_SERVO_MIX_RULE 242 //in message Sets servo mixer configuration
#define MSP_SET_1WIRE 243 //in message Sets 1Wire paththrough #define MSP_SET_1WIRE 243 //in message Sets 1Wire paththrough
#define INBUF_SIZE 64 #define INBUF_SIZE 64
@ -1771,21 +1771,22 @@ static bool processInCommand(void)
// get channel number // get channel number
i = read8(); i = read8();
// we do not give any data back, assume channel number is transmitted OK // we do not give any data back, assume channel number is transmitted OK
if (i==0xFF) { if (i == 0xFF) {
// 0xFF -> preinitialize the Passthrough // 0xFF -> preinitialize the Passthrough
// switch all motor lines HI // switch all motor lines HI
usb1WireInitialize(); usb1WireInitialize();
// and come back rigth afterwards // and come back right afterwards
// rem: App: Wait at least appx. 500 ms for BLHeli to jump into bootloader mode before try to connect any ESC // rem: App: Wait at least appx. 500 ms for BLHeli to jump into
// bootloader mode before try to connect any ESC
} }
else { else {
// Check for channel number 0..ESC_COUNT-1 // Check for channel number 0..ESC_COUNT-1
if (i < ESC_COUNT) { if (i < ESC_COUNT) {
// because we do not come back after calling usb1WirePassthrough // because we do not come back after calling usb1WirePassthrough
// proceed a success reply first // proceed with a success reply first
headSerialReply(0); headSerialReply(0);
tailSerialReply(); tailSerialReply();
//wait for all data is send // wait for all data to send
while (!isSerialTransmitBufferEmpty(mspSerialPort)) { while (!isSerialTransmitBufferEmpty(mspSerialPort)) {
delay(50); delay(50);
} }
@ -1795,10 +1796,7 @@ static bool processInCommand(void)
// MPS uart is active again // MPS uart is active again
} else { } else {
// ESC channel higher than max. allowed // ESC channel higher than max. allowed
// rem: BLHelilSuite will not support more than 8 // rem: BLHeliSuite will not support more than 8
// Client should check active Motors before preinitialize the Passthrough
// with MSP_MOTOR and check each value >0 and later call only active channels
// rem: atm not allowed channel mapping other than 0..x ascending
headSerialError(0); headSerialError(0);
} }
// proceed as usual with MSP commands // proceed as usual with MSP commands