Microsoft MakeCode

Releasing SPI pins

Imagine you use the SPI pins to control a device in conjunction with another digital ouput pin P0 as the chip select.

Then later in the code you need to send ordinary digital signals to the CLK and MOSI pins by using pins.digitalWritePin() - this would be because you have a second device attached to those two pins and with a second chip select pin P1 and you have no additional spare pins.

Do you need to do anything other than pins.digitalWritePin() to get the SPI driver to release the pins?

Ah, I’ve just answered the question by testing with a couple of LEDs.

If you initialise and use the SPI system and then do a pins.digitalWritePin() then nothing happens - the pins are presumably still owned by the SPI driver. Hmm.