1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 15:25:36 +03:00

4way-if cleanup

removed superseded 1wire-uart and 1wire-vcp
This commit is contained in:
4712 2016-04-08 18:47:18 +02:00
parent e681f9db3e
commit 5a1cb21ad5
27 changed files with 312 additions and 1188 deletions

View file

@ -92,14 +92,7 @@
#include "serial_msp.h"
#ifdef USE_SERIAL_1WIRE
#include "io/serial_1wire.h"
#endif
#ifdef USE_SERIAL_1WIRE_VCP
#include "io/serial_1wire_vcp.h"
#endif
#if (defined(USE_SERIAL_4WAY_BLHELI_BOOTLOADER) || defined(USE_SERIAL_4WAY_SK_BOOTLOADER))
#ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE
#include "io/serial_4way.h"
#endif
@ -1745,117 +1738,7 @@ static bool processInCommand(void)
isRebootScheduled = true;
break;
#ifdef USE_SERIAL_1WIRE
case MSP_SET_1WIRE:
// get channel number
i = read8();
// we do not give any data back, assume channel number is transmitted OK
if (i == 0xFF) {
// 0xFF -> preinitialize the Passthrough
// switch all motor lines HI
usb1WireInitialize();
// reply the count of ESC found
headSerialReply(2);
serialize8(escCount);
serialize8(currentPort->port->identifier);
// 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
return true;
} else if (i < escCount) {
// Check for channel number 0..ESC_COUNT-1
// because we do not come back after calling usb1WirePassthrough
// proceed with a success reply first
headSerialReply(0);
tailSerialReply();
// flush the transmit buffer
bufWriterFlush(writer);
// wait for all data to send
waitForSerialPortToFinishTransmitting(currentPort->port);
// Start to activate here
// motor 1 => index 0
// search currentPort portIndex
/* next lines seems to be unnecessary, because the currentPort always point to the same mspPorts[portIndex]
uint8_t portIndex;
for (portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
if (currentPort == &mspPorts[portIndex]) {
break;
}
}
*/
// *mspReleasePortIfAllocated(mspSerialPort); // CloseSerialPort also marks currentPort as UNUSED_PORT
usb1WirePassthrough(i);
// Wait a bit more to let App read the 0 byte and/or switch baudrate
// 2ms will most likely do the job, but give some grace time
delay(10);
// rebuild/refill currentPort structure, does openSerialPort if marked UNUSED_PORT - used ports are skiped
// *mspAllocateSerialPorts(&masterConfig.serialConfig);
/* restore currentPort and mspSerialPort
setCurrentPort(&mspPorts[portIndex]); // not needed same index will be restored
*/
// former used MSP uart is active again
// restore MSP_SET_1WIRE as current command for correct headSerialReply(0)
//currentPort->cmdMSP = MSP_SET_1WIRE;
} else if (i == 0xFE) {
usb1WireDeInitialize();
} else {
// ESC channel higher than max. allowed
headSerialError(0);
}
// proceed as usual with MSP commands
// and wait to switch to next channel
// rem: App needs to call MSP_BOOT to deinitialize Passthrough
break;
#endif
#ifdef USE_SERIAL_1WIRE_VCP
case MSP_SET_1WIRE:
// get channel number
i = read8();
// we do not give any data back, assume channel number is transmitted OK
if (i == 0xFF) {
// 0xFF -> preinitialize the Passthrough
// switch all motor lines HI
usb1WireInitializeVcp();
// reply the count of ESC found
headSerialReply(2);
serialize8(escCount);
serialize8(currentPort->port->identifier);
// 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
return true;
} else if (i < escCount) {
// Check for channel number 0..ESC_COUNT-1
// because we do not come back after calling usb1WirePassthrough
// proceed with a success reply first
headSerialReply(0);
tailSerialReply();
// flush the transmit buffer
bufWriterFlush(writer);
// wait for all data to send
waitForSerialPortToFinishTransmitting(currentPort->port);
// Start to activate here
// motor 1 => index 0
usb1WirePassthroughVcp(currentPort, writer, i);
// Wait a bit more to let App switch baudrate
delay(10);
// former used MSP uart is still active
// proceed as usual with MSP commands
// and wait to switch to next channel
// rem: App needs to call MSP_SET_1WIRE(0xFE) to deinitialize Passthrough
} else if (i == 0xFE) {
usb1WireDeInitializeVcp();
} else {
// ESC channel higher than max. allowed
headSerialError(0);
}
break;
#endif
#if (defined(USE_SERIAL_4WAY_BLHELI_BOOTLOADER) || defined(USE_SERIAL_4WAY_SK_BOOTLOADER))
#ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE
case MSP_SET_4WAY_IF:
// get channel number
// switch all motor lines HI