Is there any generic way to determine the GPIO pin numbers of the Tx and Rx pins of an hardware serial interface in arduino?
My use case is the following : i use the uart to implement a half-duplex protocol, by disabling uart rx and tx alternatively, and i would like to enable the pullup on the Tx pin, so that the line is not floating in receiving state.
Won't you know which pins are used from looking at the relevant datasheet for the microprocessor you are using? Or, more simply from the Arduino pin mapping for the Arduino board you are using. And the Rx and Tx functions are printed beside the pins on Uno and Mega boards.
Sure i can, but then i will have to handle each case (arduino model and serial port) manually.
I know how to do it, but that's slightly tedious, and i just want to be sure that there is not already something predefined that does that.
I did look in the HardwareSerial code and didn't find anything, but i am asking in case i have missed something.
If you look at the source code for many of the low-level Arduino features you will see that it has many chunks of code for the different variants. For example look in the file wiring.c