Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 8 months ago.
Is there a way to change a pin declaration?
I have a pin that is normally declared as a SPI port. Later on, under certain conditions, I'd like to change it to a PwmOut. Anyone know how to accomplish this?
1 Answer
6 years, 7 months ago.
With most interfaces you can just re-declare the pin (as PwmOut) and that'd be it. SPI might be special though.
If you see that that does not work, you can use the DestructableSPI class.
DestructableSPI spi(D8, D9, /* etc */); // when you want to switch spi.free(); PwmOut pwm(D8);