This is a bad mess...
Better is:
1. Don't. Use another GPIO port to control pull-up/downs at bus voltage. (You're still writing exactly one port to set pull state. What's it matter that it's called PULLUP instead of OUT?
) Sense the input voltage with a voltage divider (and preferably a schmitt trigger gate as well, so the GPIO isn't seeing indeterminate logic levels in case of that).
2. Pull both simultaneously, so the open-circuit input pin voltage is 14V (or whatever Vbus/2 is). Sense the input voltage with a split voltage divider (3 resistors in series), wired to two GPIO pins. When GPIO(low) and GPIO(high) are both high, you know you have ~28V on the input. When GPIO(high) is high and GPIO(low) is low, you know you have ~14V (o/c). When both are low, you have ~0V. Bonus points for using a precision schmitt trigger (e.g. 74HC7014) or comparators to set well-defined thresholds here.
3. Do (2), but with ADC inputs. Read the full, say, 0-36V range, and set thresholds in software. Bonus: add digital filtering and hysteresis, so your input circuit is as simple as possible (three resistors and a capacitor, maybe a TVS optionally), while your detected states are precision and robust.
Note that 2 is just a discrete (unary) ADC, and 3 is using the onboard hardware, with many more bits (and binary!), for the same end.
I've done (1) and (3), professionally, with excellent results. MCUs are cheap as sand; PCB space, BOM count and engineer time isn't!
Tim