I am using an Argon board running OS 1.4.4 and am unable to convert the Serial1 RX/TX pins into GPIO.
In the setup function, I initialize the Serial1 port with this code:
Serial1.begin(38400, SERIAL_8E2);
I have a wire connected directly to the RX pin that acts as a one-wire Serial communication bus. When that wire is measured with the bus active, the output is around 2.2 Volts to 2.5 Volts. My understanding is that reading from that pin should return a non-zero result, but the output of reading that pin is always 0 Volts.
In the loop, I call a function to read characters from the Serial1 port and that function works correctly. However, when I end the Serial1 communication and attempt to read an analog voltage from that pin, the result does not match the input to that pin. The code I have used to try and free those pins for reading is as below:
Serial1.end();
int32_t rxStatus = analogRead(RX);
LOGINFO(("RX - %d", rxStatus));
Serial1.begin(38400, SERIAL_8E2);
My understanding of the USART library is that when a serial port is closed, the pins return to an INPUT state, from this code in the Serial1.end() function:
HAL_Pin_Mode(txPin_, INPUT);
HAL_Set_Pin_Function(txPin_, PF_NONE);
HAL_Pin_Mode(rxPin_, INPUT);
HAL_Set_Pin_Function(rxPin_, PF_NONE);
if (config_.config & SERIAL_FLOW_CONTROL_CTS) {
HAL_Pin_Mode(ctsPin_, INPUT);
HAL_Set_Pin_Function(ctsPin_, PF_NONE);
}
if (config_.config & SERIAL_FLOW_CONTROL_RTS) {
HAL_Pin_Mode(rtsPin_, INPUT);
HAL_Set_Pin_Function(rtsPin_, PF_NONE);
}
I have also attempted to define the RX pin as the INPUT, INPUT_PULLDOWN, or INPUT_PULLUP states, but the result still does not match the input.
Is there a way to free the RX pin to be read as an analog GPIO pin and return that pin to the Serial1 port?