Use SERIAL_PORT_NONE identifier to mark ports which are unavailable
This commit is contained in:
parent
86ddf27515
commit
dce873434b
|
@ -241,8 +241,8 @@ serialPort_t *openSerialPort(
|
|||
portOptions_t options)
|
||||
{
|
||||
serialPortUsage_t *serialPortUsage = findSerialPortUsageByIdentifier(identifier);
|
||||
if (!serialPortUsage->enabled || serialPortUsage->function != FUNCTION_NONE) {
|
||||
// already in use
|
||||
if (!serialPortUsage || serialPortUsage->function != FUNCTION_NONE) {
|
||||
// not available / already in use
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -323,19 +323,18 @@ void serialInit(serialConfig_t *initialSerialConfig, bool softserialEnabled)
|
|||
for (index = 0; index < SERIAL_PORT_COUNT; index++) {
|
||||
serialPortUsageList[index].identifier = serialPortIdentifiers[index];
|
||||
|
||||
serialPortUsageList[index].enabled = true;
|
||||
|
||||
if (!softserialEnabled) {
|
||||
if (0
|
||||
#ifdef USE_SOFTSERIAL1
|
||||
if (serialPortUsageList[index].identifier == SERIAL_PORT_SOFTSERIAL1) {
|
||||
serialPortUsageList[index].enabled = softserialEnabled;
|
||||
}
|
||||
|| serialPortUsageList[index].identifier == SERIAL_PORT_SOFTSERIAL1
|
||||
#endif
|
||||
|
||||
#ifdef USE_SOFTSERIAL2
|
||||
if (serialPortUsageList[index].identifier == SERIAL_PORT_SOFTSERIAL2) {
|
||||
serialPortUsageList[index].enabled = softserialEnabled;
|
||||
}
|
||||
|| serialPortUsageList[index].identifier == SERIAL_PORT_SOFTSERIAL2
|
||||
#endif
|
||||
) {
|
||||
serialPortUsageList[index].identifier = SERIAL_PORT_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ extern uint32_t baudRates[];
|
|||
|
||||
// serial port identifiers are now fixed, these values are used by MSP commands.
|
||||
typedef enum {
|
||||
SERIAL_PORT_NONE = -1,
|
||||
SERIAL_PORT_USART1 = 0,
|
||||
SERIAL_PORT_USART2,
|
||||
SERIAL_PORT_USART3,
|
||||
|
@ -69,7 +70,6 @@ typedef struct serialPortUsage_s {
|
|||
serialPortIdentifier_e identifier;
|
||||
serialPort_t *serialPort;
|
||||
serialPortFunction_e function;
|
||||
bool enabled;
|
||||
} serialPortUsage_t;
|
||||
|
||||
serialPort_t *findSharedSerialPort(uint16_t functionMask, serialPortFunction_e sharedWithFunction);
|
||||
|
|
Loading…
Reference in New Issue