Way to Check Hardware Serial in Use?

Status
Not open for further replies.

brtaylor

Well-known member
Is there a way to see if one of the Hardware Serial ports is already being used (i.e. for Serial1, that Serial1.begin() has already been called)? I have two serial based device libraries and I'd like to make sure that the serial port isn't already in use by one library before initializing the second library so that I can either free the resource (i.e. Serial1.end()) or switch the serial port that is being used.

Thanks!
 
Not from the Serial1 object, but you could look at the hardware registers.

Code:
    if ((SIM_SCGC4 & SIM_SCGC4_UART0)) {
        Serial.println("Serial1 hardware is turned on");
    }
 
Status
Not open for further replies.
Back
Top