Porting Code from STCube to PIO

Hello,

I have a project where I need to setup I2S with DMA on an STM32 microcontroller. I did get it to work using STCube IDE. Now I need to port the code over to platformio. I want to use the Arduino framework.

I tried to just copy over the functions from the main.c file, which did compile but not work on the microcontroller. Copying all h and c files from inc and src into the src folder of pio as suggested in some other threads does not compile.

Does anyone has experience with porting code over?
I really only need the setups made by STCube to be ported. I did not get the I2S to work without the STCube, that is the whole reason for me to port the Code. So if someone knows how to properly setup I2S and DMA directly in pio with the arduino framework this would be my preferred way of doing things here.

Thanks!

Which functions did you copy exactly, and in which functions do you call? There might also be other functions in other files, e.g., HAL_I2S_MspInit() and HAL_I2S_MspDeInit(), HAL_DMA_MspInit(), MX_I2S_Init(), …, and especially the interrupt handling functions in the stm32xxxxx_it.c files. Special care must then be taken to copy those into either also .c files or in .cpp files but with extern "C" marking, otherwise those functions will not be found and respected during linking.

Also, stuff like the clock initialization for SAI is important; The SystemClock_Config() function is overridable if you need a different version from the usual clock init, which may miss SAI clock setup. (See example).

Without having the original working STM32Cube project and your ported project, this is like looking into a cloudy crystal ball. It could be very many things. If you can show the actual code, tracking the problem done would be much easier.