Timo's NMEA2000 stm32 mcp2515

I’m trying to use Timo’s great NMEA2000 library on a STM32.
How do I specify which SPI port to use?
I also have a TFT connected, which needs max SPI-speed, but the CAN controller has a max of 10MHz, so I want to use two SPI-ports on my STM32.

Im using a Bluepill, but changed the STM to a STM32F103CBT6 (more memory).
I’m using Visual Studio Code with PlatformIO - a ST-LINK for upload/debug, a MCP2515 as controller and MCP2542 for transceiver.

Libraries (Timo’s):

The micro should have 2xSPI, but I can’t find info how to use SPI2
Just tell me if you need more information…

I think library specific questions should go to Issues · ttlappalainen/NMEA2000 · GitHub.

I see that the library constructs this type of object which has a SetSPI function

at this place

So technically it might be possible to recast this pionter to its original type and call the SetSPI function on that…

#include <SPI.h>
//            MOSI  MISO  SCLK
SPIClass SPI_3(PC12, PC11, PC10);

void setup() {
  tNMEA2000_mcp* pNMEA = (tNMEA2000_mcp*) &NMEA2000;

Creating a new SPI object is per API · stm32duino/wiki Wiki · GitHub.


Thanks - I’ll try in the weekend…I’m very new to C++ so I might get back with questions :smile: