Skip to content

Commit

Permalink
Merge branch 'iNavFlight:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
b14ckyy authored Aug 2, 2024
2 parents b347a48 + 3cc11ce commit c15c44c
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/Cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ While connected to the CLI, all Logical Switches are temporarily disabled (5.1.0
| `save` | Save and reboot |
| `sd_info` | Sdcard info |
| `serial` | Configure serial ports. [Usage](Serial.md) |
| `serialpassthrough` | Passthrough serial data to port, with `<id> <baud> <mode>`, where `id` is the zero based port index, `baud` is a standard baud rate, and mode is `rx`, `tx`, or both (`rxtx`) |
| `serialpassthrough` | Passthrough serial data to port, with `<id> <baud> <mode> <options>`, where `id` is the zero based port index, `baud` is a standard baud rate, mode is `rx`, `tx`, or both (`rxtx`), and options is a short string like `8N1` or `8E2` |
| `servo` | Configure servos |
| `set` | Change setting with name=value or blank or * for list |
| `smix` | Custom servo mixer |
Expand Down
71 changes: 47 additions & 24 deletions src/main/blackbox/blackbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#define BLACKBOX_INVERTED_CARD_DETECTION 0
#endif

PG_REGISTER_WITH_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 2);
PG_REGISTER_WITH_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 3);

PG_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig,
.device = DEFAULT_BLACKBOX_DEVICE,
Expand All @@ -108,7 +108,8 @@ PG_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig,
.invertedCardDetection = BLACKBOX_INVERTED_CARD_DETECTION,
.includeFlags = BLACKBOX_FEATURE_NAV_PID | BLACKBOX_FEATURE_NAV_POS |
BLACKBOX_FEATURE_MAG | BLACKBOX_FEATURE_ACC | BLACKBOX_FEATURE_ATTITUDE |
BLACKBOX_FEATURE_RC_DATA | BLACKBOX_FEATURE_RC_COMMAND | BLACKBOX_FEATURE_MOTORS,
BLACKBOX_FEATURE_RC_DATA | BLACKBOX_FEATURE_RC_COMMAND |
BLACKBOX_FEATURE_MOTORS | BLACKBOX_FEATURE_SERVOS,
);

void blackboxIncludeFlagSet(uint32_t mask)
Expand Down Expand Up @@ -334,24 +335,24 @@ static const blackboxDeltaFieldDefinition_t blackboxMainFields[] = {
{"motor", 7, UNSIGNED, .Ipredict = PREDICT(MOTOR_0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_MOTORS_8)},

/* servos */
{"servo", 0, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 1, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 2, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 3, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 4, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 5, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 6, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 7, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 8, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 9, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 10, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 11, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 12, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 13, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 14, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 15, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 16, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 17, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)},
{"servo", 0, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_1)},
{"servo", 1, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_2)},
{"servo", 2, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_3)},
{"servo", 3, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_4)},
{"servo", 4, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_5)},
{"servo", 5, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_6)},
{"servo", 6, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_7)},
{"servo", 7, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_8)},
{"servo", 8, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_9)},
{"servo", 9, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_10)},
{"servo", 10, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_11)},
{"servo", 11, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_12)},
{"servo", 12, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_13)},
{"servo", 13, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_14)},
{"servo", 14, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_15)},
{"servo", 15, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_16)},
{"servo", 16, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_17)},
{"servo", 17, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_18)},

{"navState", -1, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(SIGNED_VB), CONDITION(ALWAYS)},
{"navFlags", -1, UNSIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(SIGNED_VB), CONDITION(ALWAYS)},
Expand Down Expand Up @@ -654,7 +655,27 @@ static bool testBlackboxConditionUncached(FlightLogFieldCondition condition)
return (getMotorCount() >= condition - FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_1 + 1) && blackboxIncludeFlag(BLACKBOX_FEATURE_MOTORS);

case FLIGHT_LOG_FIELD_CONDITION_SERVOS:
return isMixerUsingServos();
return blackboxIncludeFlag(BLACKBOX_FEATURE_SERVOS) && isMixerUsingServos();

case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_1:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_2:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_3:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_4:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_5:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_6:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_7:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_8:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_9:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_10:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_11:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_12:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_13:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_14:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_15:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_16:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_17:
case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_18:
return ((FlightLogFieldCondition)getServoCount() >= condition - FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_1 + 1) && blackboxIncludeFlag(BLACKBOX_FEATURE_SERVOS);

case FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_0:
case FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_1:
Expand Down Expand Up @@ -955,7 +976,8 @@ static void writeIntraframe(void)
}

if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_SERVOS)) {
for (int x = 0; x < MAX_SUPPORTED_SERVOS; x++) {
const int servoCount = getServoCount();
for (int x = 0; x < servoCount; x++) {
//Assume that servos spends most of its time around the center
blackboxWriteSignedVB(blackboxCurrent->servo[x] - 1500);
}
Expand Down Expand Up @@ -1214,7 +1236,7 @@ static void writeInterframe(void)
}

if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_SERVOS)) {
blackboxWriteArrayUsingAveragePredictor16(offsetof(blackboxMainState_t, servo), MAX_SUPPORTED_SERVOS);
blackboxWriteArrayUsingAveragePredictor16(offsetof(blackboxMainState_t, servo), getServoCount());
}

blackboxWriteSignedVB(blackboxCurrent->navState - blackboxLast->navState);
Expand Down Expand Up @@ -1682,7 +1704,8 @@ static void loadMainState(timeUs_t currentTimeUs)

blackboxCurrent->rssi = getRSSI();

for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
const int servoCount = getServoCount();
for (int i = 0; i < servoCount; i++) {
blackboxCurrent->servo[i] = servo[i];
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/blackbox/blackbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef enum {
BLACKBOX_FEATURE_GYRO_PEAKS_ROLL = 1 << 10,
BLACKBOX_FEATURE_GYRO_PEAKS_PITCH = 1 << 11,
BLACKBOX_FEATURE_GYRO_PEAKS_YAW = 1 << 12,
BLACKBOX_FEATURE_SERVOS = 1 << 13,
} blackboxFeatureMask_e;
typedef struct blackboxConfig_s {
uint16_t rate_num;
Expand All @@ -55,4 +56,4 @@ void blackboxFinish(void);
bool blackboxMayEditConfig(void);
void blackboxIncludeFlagSet(uint32_t mask);
void blackboxIncludeFlagClear(uint32_t mask);
bool blackboxIncludeFlag(uint32_t mask);
bool blackboxIncludeFlag(uint32_t mask);
19 changes: 19 additions & 0 deletions src/main/blackbox/blackbox_fielddefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,26 @@ typedef enum FlightLogFieldCondition {
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_6,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_7,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_8,

FLIGHT_LOG_FIELD_CONDITION_SERVOS,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_1,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_2,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_3,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_4,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_5,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_6,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_7,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_8,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_9,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_10,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_11,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_12,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_13,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_14,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_15,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_16,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_17,
FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_18,

FLIGHT_LOG_FIELD_CONDITION_MAG,
FLIGHT_LOG_FIELD_CONDITION_BARO,
Expand Down
5 changes: 5 additions & 0 deletions src/main/drivers/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ void serialSetMode(serialPort_t *instance, portMode_t mode)
instance->vTable->setMode(instance, mode);
}

void serialSetOptions(serialPort_t *instance, portOptions_t options)
{
instance->vTable->setOptions(instance, options);
}

void serialWriteBufShim(void *instance, const uint8_t *data, int count)
{
serialWriteBuf((serialPort_t *)instance, data, count);
Expand Down
3 changes: 3 additions & 0 deletions src/main/drivers/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ struct serialPortVTable {

void (*setMode)(serialPort_t *instance, portMode_t mode);

void (*setOptions)(serialPort_t *instance, portOptions_t options);

void (*writeBuf)(serialPort_t *instance, const void *data, int count);

bool (*isConnected)(const serialPort_t *instance);
Expand All @@ -113,6 +115,7 @@ void serialWriteBuf(serialPort_t *instance, const uint8_t *data, int count);
uint8_t serialRead(serialPort_t *instance);
void serialSetBaudRate(serialPort_t *instance, uint32_t baudRate);
void serialSetMode(serialPort_t *instance, portMode_t mode);
void serialSetOptions(serialPort_t *instance, portOptions_t options);
bool isSerialTransmitBufferEmpty(const serialPort_t *instance);
void serialPrint(serialPort_t *instance, const char *str);
uint32_t serialGetBaudRate(serialPort_t *instance);
Expand Down
6 changes: 6 additions & 0 deletions src/main/drivers/serial_softserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,11 @@ void softSerialSetMode(serialPort_t *instance, portMode_t mode)
instance->mode = mode;
}

void softSerialSetOptions(serialPort_t *instance, portOptions_t options)
{
instance->options = options;
}

bool isSoftSerialTransmitBufferEmpty(const serialPort_t *instance)
{
return instance->txBufferHead == instance->txBufferTail;
Expand All @@ -636,6 +641,7 @@ static const struct serialPortVTable softSerialVTable = {
.serialSetBaudRate = softSerialSetBaudRate,
.isSerialTransmitBufferEmpty = isSoftSerialTransmitBufferEmpty,
.setMode = softSerialSetMode,
.setOptions = softSerialSetOptions,
.isConnected = NULL,
.writeBuf = NULL,
.beginWrite = NULL,
Expand Down
7 changes: 7 additions & 0 deletions src/main/drivers/serial_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ void tcpSetMode(serialPort_t *instance, portMode_t mode)
UNUSED(mode);
}

void tcpSetOptions(serialPort_t *instance, portOptions_t options)
{
UNUSED(instance);
UNUSED(options);
}

static const struct serialPortVTable tcpVTable[] = {
{
.serialWrite = tcpWrite,
Expand All @@ -326,6 +332,7 @@ static const struct serialPortVTable tcpVTable[] = {
.serialSetBaudRate = tcpSetBaudRate,
.isSerialTransmitBufferEmpty = isTcpTransmitBufferEmpty,
.setMode = tcpSetMode,
.setOptions = tcpSetOptions,
.isConnected = tcpIsConnected,
.writeBuf = tcpWritBuf,
.beginWrite = NULL,
Expand Down
8 changes: 8 additions & 0 deletions src/main/drivers/serial_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ void uartSetMode(serialPort_t *instance, portMode_t mode)
uartReconfigure(uartPort);
}

void uartSetOptions(serialPort_t *instance, portOptions_t options)
{
uartPort_t *uartPort = (uartPort_t *)instance;
uartPort->port.options = options;
uartReconfigure(uartPort);
}

uint32_t uartTotalRxBytesWaiting(const serialPort_t *instance)
{
const uartPort_t *s = (const uartPort_t*)instance;
Expand Down Expand Up @@ -255,6 +262,7 @@ const struct serialPortVTable uartVTable[] = {
.serialSetBaudRate = uartSetBaudRate,
.isSerialTransmitBufferEmpty = isUartTransmitBufferEmpty,
.setMode = uartSetMode,
.setOptions = uartSetOptions,
.isConnected = NULL,
.writeBuf = NULL,
.beginWrite = NULL,
Expand Down
8 changes: 8 additions & 0 deletions src/main/drivers/serial_uart_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ void uartSetMode(serialPort_t *instance, portMode_t mode)
uartReconfigure(uartPort);
}

void uartSetOptions(serialPort_t *instance, portOptions_t options)
{
uartPort_t *uartPort = (uartPort_t *)instance;
uartPort->port.options = options;
uartReconfigure(uartPort);
}

uint32_t uartTotalRxBytesWaiting(const serialPort_t *instance)
{
uartPort_t *s = (uartPort_t*)instance;
Expand Down Expand Up @@ -266,6 +273,7 @@ const struct serialPortVTable uartVTable[] = {
.serialSetBaudRate = uartSetBaudRate,
.isSerialTransmitBufferEmpty = isUartTransmitBufferEmpty,
.setMode = uartSetMode,
.setOptions = uartSetOptions,
.isConnected = NULL,
.writeBuf = NULL,
.beginWrite = NULL,
Expand Down
8 changes: 8 additions & 0 deletions src/main/drivers/serial_uart_hal_at32f43x.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ void uartSetMode(serialPort_t *instance, portMode_t mode)
uartReconfigure(uartPort);
}

void uartSetOptions(serialPort_t *instance, portOptions_t options)
{
uartPort_t *uartPort = (uartPort_t *)instance;
uartPort->port.options = options;
uartReconfigure(uartPort);
}

uint32_t uartTotalRxBytesWaiting(const serialPort_t *instance)
{
const uartPort_t *s = (const uartPort_t*)instance;
Expand Down Expand Up @@ -260,6 +267,7 @@ const struct serialPortVTable uartVTable[] = {
.serialSetBaudRate = uartSetBaudRate,
.isSerialTransmitBufferEmpty = isUartTransmitBufferEmpty,
.setMode = uartSetMode,
.setOptions = uartSetOptions,
.isConnected = NULL,
.writeBuf = NULL,
.beginWrite = NULL,
Expand Down
9 changes: 9 additions & 0 deletions src/main/drivers/serial_usb_vcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ static void usbVcpSetMode(serialPort_t *instance, portMode_t mode)
// TODO implement
}

static void usbVcpSetOptions(serialPort_t *instance, portOptions_t options)
{
UNUSED(instance);
UNUSED(options);

// TODO implement
}

static bool isUsbVcpTransmitBufferEmpty(const serialPort_t *instance)
{
UNUSED(instance);
Expand Down Expand Up @@ -184,6 +192,7 @@ static const struct serialPortVTable usbVTable[] = {
.serialSetBaudRate = usbVcpSetBaudRate,
.isSerialTransmitBufferEmpty = isUsbVcpTransmitBufferEmpty,
.setMode = usbVcpSetMode,
.setOptions = usbVcpSetOptions,
.isConnected = usbVcpIsConnected,
.writeBuf = usbVcpWriteBuf,
.beginWrite = usbVcpBeginWrite,
Expand Down
Loading

0 comments on commit c15c44c

Please sign in to comment.