A Raspberry Pi 3B+ is talking to an STM32 chip via UART over pins 8 (TXD) & 10 (RXD). When I take control of those pins using
GPIO.setup(8, GPIO.OUTPUT); GPIO.output(8, GPIO.LOW); and later release them by calling
GPIO.cleanup(), UART no longer works. To restore UART, I have to reboot the Pi.
How do I restore UART pins to the way the kernel sets them without rebooting the Pi?
The reason why I need to pull down the UART pins, is because the Pi and a the STM32 have a common ground, but the STM32's board has a safety diode that seems to be turned on by the Pi's UART pins when it's power source is off. Pulling down the pins to zero when the STM32 is off seems to prevent this current from flowing. This is obviously not ideal, but due to time constraints, I can't add an opto-coupler yet.