fix SPI register switch and prepare for UDC, thanks to Henk Vergonet (#4783)