I haven’t been able to get a super straight answer on this anywhere, so I figured I should ask. Back when I used Mbed 2, it was normal to have each driver create its own SPI or I2C object from the pins passed into it. This was straightforward, and it was also nice because if, for instance, two different sensors used different SPI modes, Mbed would handle switching them depending on which SPI object was being used to access the bus.
However, since updating to Mbed 6.x, this no longer seems to work properly, at least on LPC1768. Creating two SPI or I2C objects representing the same physical bus seems to cause one of the objects to fail to send or receive data. I did some quick checking with the debugger and it looks like the I2C code is receiving errors from the chip registers inside the HAL. So it seems like creating two I2Cs somehow causes the LPC1768 I2C peripheral to be configured incorrectly.
Is this intended behavior? If so, how is one supposed to handle sharing an SPI bus between sensors that use different frequencies or modes?