1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 06:45:16 +03:00

Added abillity to specify USART6 as default port.

This fixes the mismatch between identifier and index when uarts are actually missing and not defined.
This commit is contained in:
blckmn 2016-11-11 17:19:43 +11:00
parent e82e4465f1
commit 0ebaef175e
4 changed files with 19 additions and 3 deletions

View file

@ -724,7 +724,10 @@ void createDefaultConfig(master_t *config)
#ifdef SERIALRX_UART
if (featureConfigured(FEATURE_RX_SERIAL)) {
config->serialConfig.portConfigs[SERIALRX_UART].functionMask = FUNCTION_RX_SERIAL;
int serialIndex = findSerialPortIndexByIdentifier(SERIALRX_UART);
if (serialIndex >= 0) {
config->serialConfig.portConfigs[serialIndex].functionMask = FUNCTION_RX_SERIAL;
}
}
#endif

View file

@ -107,6 +107,17 @@ baudRate_e lookupBaudRateIndex(uint32_t baudRate)
return BAUD_AUTO;
}
int findSerialPortIndexByIdentifier(serialPortIdentifier_e identifier)
{
for (int index = 0; index < SERIAL_PORT_COUNT; index++) {
const serialPortUsage_t *candidate = &serialPortUsageList[index];
if (candidate->identifier == identifier) {
return index;
}
}
return -1;
}
serialPortUsage_t *findSerialPortUsageByIdentifier(serialPortIdentifier_e identifier)
{
uint8_t index;

View file

@ -127,7 +127,7 @@ portSharing_e determinePortSharing(serialPortConfig_t *portConfig, serialPortFun
bool isSerialPortShared(serialPortConfig_t *portConfig, uint16_t functionMask, serialPortFunction_e sharedWithFunction);
serialPortUsage_t *findSerialPortUsageByIdentifier(serialPortIdentifier_e identifier);
int findSerialPortIndexByIdentifier(serialPortIdentifier_e identifier);
//
// runtime
//

View file

@ -148,8 +148,10 @@
#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
#define DEFAULT_RX_FEATURE FEATURE_RX_PPM
#define DEFAULT_FEATURES FEATURE_BLACKBOX
#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
#define SERIALRX_PROVIDER SERIALRX_SBUS
#define SERIALRX_UART SERIAL_PORT_USART6
#define USE_SERIAL_4WAY_BLHELI_INTERFACE