2023-11-14 02:28 AM
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):
Configured SPI1 in mode Full-Duplex Master and X-CUBE-MEMS1:
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.
2023-11-14 03:40 AM
in your code i see no hspi init:
so : define spi in Cube -> generate code ! and compile again...hspi should be there then.
2023-11-14 05:36 AM
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.
2023-11-14 06:26 AM - edited 2023-11-14 06:33 AM
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:
except you dont want it -- see in project manger -> advanced settings:
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
2023-11-14 07:12 AM
Well..
If I leave undefined BSP_BUS_DRIVER
then SPI is visible in Advanced Settings:
When gearwheel is pressed a Warning appears.
If Yes is pressed, code is generated:
I think I'll live with it :)
Thank You for these suggestions.