Swan SPI and I2C speed limitations and settings

Does the existing Arduino-based control over the SPI and I2C have limitations on the bit rate lower than the STM32L4R5 spec?

I’d like to implement a SPI slave at 50 MHz and I2C at 400kHz based on some specs in a peripheral. I tried using Wire.setClock() and resorted to something like HAL_SPI_Receive(&hspi2, buffer, bufLen, 5000); for SPI after initializing the SPI for slave in STM32Cube. I’m not seeing a good clock on the I2C and the SPI seems poorly configured as well. I think it wants me to set the clock config but this seems to conflict with the Swan’s regular peripherals for debug and maybe notecard. Has anyone set these up with through the HAL that could share a working example to get me started?


Hey @icuham thanks for the question, and welcome to the Blues community! (Apologies for the delay as well!)

Just to clarify, are you looking for Swan clock configuration help in an Arduino/STM32Duino-app or in an STM32Cube app?

I started a proof of concept using the Arduino/STM32Duino framework but when I went to implement the SPI component I found out that the Core Arduino API implementation seems to not support slave mode. Others encountered this and online guidance was to use the HAL directly.

So I opened up STM32Cube and generated code for a SPI that in theory should provide the 50MHz+ clock I need as a slave implementation. However, STM32Cube defaults SPI2 on PB15 - MOSI, PD3 - MISO, and PD1 - SCLK. … The docs show PB14 as an alternate MISO and PB13 as an alternate SCLK. When I look at the SWAN docs they reference PB15, PB14, and PD1.
There’s lot’s of confusion now… Unfortunately, I can’t sample a 50MHz SPI at the moment so debugging the communication is a nightmare. On a high note I2C seems fine now. I am hoping someone has a small working example to reference and modify.