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

Support programming of Arduino devices in serial passthrough mode (#5129)

* Support DTR in serial passthrough mode to enable programming of Arduino
based devices such as MinimOSD.

Use 'serialpassthrough 5 57600 rxtx 56' and then use Ardino to program MinimOSD
Use 'serialpassthrough 5 115200' and then use MWOSD configurator to setup

* Fix comment for CDC_SetCtrlLineStateCb routine

* Handle F7 CDC interface

* Use strToPin() to allow easy port/pin specification

* Fix use of CDC_SetCtrlLineStateCb for all processor types

* Only set baud when specified

* Fix unit tests for cli

* Only register callback if needed

* Fix white space

* Provide implementation of IOConfigGPIO in SITL

* Update serialpassthrough help text

* DTR handling through serial drivers

* Fix F3, F7 and SITL builds

* If serialpassthrough command specifies baud rate of 0, set baud rate over USB. MWOSD configurator can now access config and reflash MinimOSD without rebooting and changing baud rate.

* Fix F3 build

* Fix failing unit tests

* Use resources to declare DTR pin assignment

* Don't assert DTR during normal operation as MW_OSD doesn't like it

* MW_OSD must be built with MAX_SOFTRESET defined in order to support DTR resets

* Minimise changes after dropping DTR pin param from serialpassthrough cmd

* Remove DTR pin param from serialpassthrough cmd

* Treat ioDtrTag as boolean in conditional statements

* Tidy buffer check

* Check buffer size in CDC_Itf_Control

* Fix unit test

* Add documentation for DTR

* Add note on MAX_SOFTRESET to documentation

* Remove superfluous function definitions

* Fix tabs

* Fix tabs

* Removed superfluous entried from vtable

* Backout whitespace changes unrelated to this PR

* Pass true/false to IOWrite()

* Fix line coding packing

* Add LINE_CODING structure defintion

* Revise serial documentation

* Prevent tx buffer overflow in serialPassthrough()

* Revert change unrelated to PR

* Review feedback from ledvinap

* Fix unit test

* Use PINIO to drive DTR

* Fix unit test

* Remove change unrelated to PR

* Fix SITL build

* Use shifted bits for mask definition

* Fix serialpassthrough documentation

* Only compile PINIO functionality if USE_PINIO defined

* IOConfigGPIO not needed

* Move cbCtrlLine callback to cli.c

* serialPassthrough params changed

* Check packed structure size

* Fix unit test

* Tidy up baud rate handling
This commit is contained in:
SteveCEvans 2018-03-21 10:17:31 +00:00 committed by Michael Keller
parent 46291a8374
commit 5558174d33
23 changed files with 347 additions and 33 deletions

View file

@ -58,6 +58,8 @@
#include "telemetry/telemetry.h"
#endif
#include "pg/pinio.h"
static serialPortUsage_t serialPortUsageList[SERIAL_PORT_COUNT];
const serialPortIdentifier_e serialPortIdentifiers[SERIAL_PORT_COUNT] = {
@ -429,7 +431,6 @@ void closeSerialPort(serialPort_t *serialPort)
}
// TODO wait until data has been transmitted.
serialPort->rxCallback = NULL;
serialPortUsage->function = FUNCTION_NONE;
@ -540,6 +541,8 @@ void serialPassthrough(serialPort_t *left, serialPort_t *right, serialConsumer *
if (serialRxBytesWaiting(left)) {
LED0_ON;
uint8_t c = serialRead(left);
// Make sure there is space in the tx buffer
while (!serialTxBytesFree(right));
serialWrite(right, c);
leftC(c);
LED0_OFF;
@ -547,6 +550,8 @@ void serialPassthrough(serialPort_t *left, serialPort_t *right, serialConsumer *
if (serialRxBytesWaiting(right)) {
LED0_ON;
uint8_t c = serialRead(right);
// Make sure there is space in the tx buffer
while (!serialTxBytesFree(left));
serialWrite(left, c);
rightC(c);
LED0_OFF;