cancel
Showing results for 
Search instead for 
Did you mean: 

DT0141 How to import STMems_Standard_C_drivers in an STM32CubeIDE project - something is missing

Imie
Associate II

Hi,

I'm trying to make first steps in ST32CubeIDE with some knowledge of C/C++. As a playground I want to communicate with Accelerometer in LSM6DSOX using driver described in document:

"DT0141 How to import STMems_Standard_C_drivers in an STM32CubeIDE project.pdf".

So, created new project.

Added in Software Packs Component Selector an LSM6DSOX - SPI (v1.8.0):

LSM6DSOX_SPI 1.png

 

Configured SPI1 in mode Full-Duplex Master and X-CUBE-MEMS1:

LSM6DSOX_SPI 2.png

 

When testing lines added to main.c I get an error from compiler in:

lsm6dsoxDriver.handle = &hspi1;

../Core/Src/main.c:110:32: error: 'hspi1' undeclared (first use in this function)

110 | lsm6dsoxDriver.handle = &hspi1;

| ^~~~~

There are more errors, but this one is first that I'm not able to fix

What am I missing? Maybe there is an error in PDF file.

 

Thanks for every word of help.

 

4 REPLIES 4
AScha.3
Chief II

in your code i see no hspi init:

AScha3_0-1699961996131.png

so : define spi in Cube -> generate code ! and compile again...hspi should be there then.

If you feel a post has answered your question, please click "Accept as Solution".
Imie
Associate II

hmm...

did the steps again with a special care of:

- Cube -> Project -> Generate Code. (this switches view to main.c)

- Cube -> Project -> Build All.

Nothing new appears in section you showed.

btw no need for "build all" ; just use the nice symbols : the gearwheel to gen.code, the hammer to compile. 🙂

see - all used units get a call for init:

AScha3_0-1699971571005.png

except you dont want it -- see in project manger -> advanced settings:

AScha3_1-1699971778608.png

when you activate/use the spi - is the mx..init active and also no "do not ge. function call" set ?

+

you should read  - first - :

https://www.st.com/resource/en/user_manual/dm00629856-stm32cubeide-user-guide-stmicroelectronics.pdf

 

If you feel a post has answered your question, please click "Accept as Solution".
Imie
Associate II

Well..

If I leave undefined BSP_BUS_DRIVER

LSM6DSOX_SPI 3 undefined.jpg

then SPI is visible in Advanced Settings:

LSM6DSOX_SPI 3 undefined PR_man.jpg

When gearwheel is pressed a Warning appears.

LSM6DSOX_SPI 3 undefined warning.jpg

If Yes is pressed, code is generated:

LSM6DSOX_SPI 3 undefined main.c.jpg

I think I'll live with it 🙂

Thank You for these suggestions.