Well, the setup() method could simply fail with descriptive error (SPIx/TWIx already in use) if it is already setup by the other interface. So you would need to unsetup() one to use the other. Also the simplest and sensible to me is to let people handle it themselves and not hide which is which and silently use other.
Or if switching same interface between SPI/TWI is an issue at runtime then it could be at least static at build time how many of each one could use. So 0,1,2 of I2C in board config = up to 3,2,1 of SPI
As for usability - it would make better sense to use multiple HW SPIs if you could write to them asynchronously at the same time (like e.g. http). It could be useful e.g. for multiple displays. If the interpreter is waiting to write all bytes then indeed SW implementation might be enough if it is fast enough.
© Espruino, powered by microcosm.
Report a problem