serial1wire MSP and multi-esc configuration logic, compatible with BLHeliSuite 14.0.0.3.2 (beta)
mad props to @4712
This commit is contained in:
parent
291a56d9ca
commit
5be6a0762f
|
@ -110,6 +110,19 @@ sending this message for all adjustment range slots.
|
|||
| adjustmentFunction | uint8 | See below |
|
||||
| auxSwitchChannelIndex | uint8 | The Aux channel number used to perform the function (indexed from 0) |
|
||||
|
||||
### MSP\_SET\_1WIRE
|
||||
|
||||
The MSP\_SET\_1WIRE is used to enable serial1wire passthrough
|
||||
note: it would be ideal to disable this when armed
|
||||
|
||||
| Command | Msg Id | Direction |
|
||||
|---------|--------|-----------|
|
||||
| MSP\_SET\_1WIRE | 243 | to FC |
|
||||
|
||||
| Data | Type | Notes |
|
||||
|------|------|-------|
|
||||
| esc id | uint8 | A monotonically increasing ID, from 0 to the number of escs -1 |
|
||||
|
||||
#### AdjustmentIndex
|
||||
|
||||
The FC maintains internal state for each adjustmentStateIndex, currently 4 simultaneous adjustment states are maintained. Multiple adjustment ranges
|
||||
|
|
|
@ -238,4 +238,4 @@ void usb1WirePassthrough(int8_t escIndex)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -27,5 +27,6 @@ typedef struct {
|
|||
uint32_t pinpos;
|
||||
} escHardware_t;
|
||||
|
||||
void usb1WireInitialize();
|
||||
void usb1WirePassthrough(int8_t escIndex);
|
||||
#endif
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
|
||||
#include "serial_msp.h"
|
||||
|
||||
#ifdef USE_SERIAL_1WIRE
|
||||
#include "io/serial_1wire.h"
|
||||
#endif
|
||||
static serialPort_t *mspSerialPort;
|
||||
|
||||
extern uint16_t cycleTime; // FIXME dependency on mw.c
|
||||
|
@ -310,6 +313,7 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
|||
#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_SET_SERVO_MIX_RULE 242 //in message Sets servo mixer configuration
|
||||
#define MSP_SET_1WIRE 243 //in message Sets 1Wire paththrough
|
||||
|
||||
#define INBUF_SIZE 64
|
||||
|
||||
|
@ -1762,6 +1766,47 @@ 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();
|
||||
// and come back rigth afterwards
|
||||
// rem: App: Wait at least appx. 500 ms for BLHeli to jump into bootloader mode before try to connect any ESC
|
||||
}
|
||||
else {
|
||||
// Check for channel number 0..ESC_COUNT-1
|
||||
if (i < ESC_COUNT) {
|
||||
// because we do not come back after calling usb1WirePassthrough
|
||||
// proceed a success reply first
|
||||
headSerialReply(0);
|
||||
tailSerialReply();
|
||||
//wait for all data is send
|
||||
while (!isSerialTransmitBufferEmpty(mspSerialPort)) {
|
||||
delay(50);
|
||||
}
|
||||
// Start to activate here
|
||||
// motor 1 => index 0
|
||||
usb1WirePassthrough(i);
|
||||
// MPS uart is active again
|
||||
} else {
|
||||
// ESC channel higher than max. allowed
|
||||
// rem: BLHelilSuite 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);
|
||||
}
|
||||
// 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
|
||||
default:
|
||||
// we do not know how to handle the (valid) message, indicate error MSP $M!
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue