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

serial1wire cleanup per @4712 and @Echelon9

This commit is contained in:
nathan 2015-08-24 20:15:47 -07:00
parent 67f74121d6
commit 6d66aecf6d
4 changed files with 9 additions and 13 deletions

View file

@ -12,7 +12,7 @@ Currently supported on the SPRACINGF3, STM32F3DISCOVERY, NAZE32 (including clone
## Wiring
- For the NAZE, no external wiring is necessary. Simply plugin the board via USB cable.
- For the NAZE, no external wiring is necessary. Simply plug in the board via USB cable.
- For the CC3D, connect [a USB to UART adapter](http://bit.ly/cf-cp2102) to the main port. If you need one, I prefer the [CP2102](http://bit.ly/cf-cp2102) as it is cheap and [the driver](https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx) is readily available.

View file

@ -75,7 +75,7 @@ static void gpio_set_mode(GPIO_TypeDef* gpio, uint16_t pin, GPIO_Mode mode) {
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
}
}

View file

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

View file

@ -1730,21 +1730,22 @@ static bool processInCommand(void)
// get channel number
i = read8();
// we do not give any data back, assume channel number is transmitted OK
if (i==0xFF) {
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
// 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
}
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
// proceed with a success reply first
headSerialReply(0);
tailSerialReply();
//wait for all data is send
// wait for all data to send
while (!isSerialTransmitBufferEmpty(mspSerialPort)) {
delay(50);
}
@ -1754,10 +1755,7 @@ static bool processInCommand(void)
// 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
// rem: BLHeliSuite will not support more than 8
headSerialError(0);
}
// proceed as usual with MSP commands