The SPI api will only work on the pins as detailed on the platform as I mentioned.
If you want to do your own SPI implementation you would need to set your pins to something like this:
DigitalOut CS(D8); // chip (device) select pin
DigitalOut RS(D9); // chip (device) reset pin
DigitalOut MOSI(D10); // mosi(sometimes called SDA) data out to device pin
DigitalIn MISO(D11); // miso date from device pin
DigitalOut SCK(D12); // clock
These can be set to any pin combination.
The problem with this is that almost all your MCU resorces will be tied up with your SPI function, you have no buffer so can not do anything else until you have finished your transmit or receive sequence.
I would not recommend it unless there’s a specific reason.
You can find all the F103RB MCU built in peripheral function pins here:
I have found this that will give you an example for software SPI: