Skip to main content
Bogdan Golab
Lead
January 19, 2017
Solved

CubeMX integration with BSP drivers

  • January 19, 2017
  • 14 replies
  • 5854 views
Posted on January 19, 2017 at 19:52

I have been using the CubexMX for a few years and have no problems with programming nucleo and discovery boards.

I am using Keil IDE.

I recently bough the

http://www.st.com/en/ecosystems/x-nucleo-iks01a1.html

and have some problems with integration it with nucleo-F411.

===

Starting with the library description and trying to understand all the dependencies seems to be daunting task.

I tried it but I found it difficult to solve library dependencies issues. I am not talking about what function to call - it's rather inter library dependencies issues.

===

Opening already existing example project for F401 and replacing the MCU with F411  gives so many compilation errors so I rejected the idea for now.

===

I wonder if someone have some experience how to quickly integrate the CubeMX-generated program skeleton with BSP drivers. The goal is to have compilation/linking error free application skeleton.

The Getting started document for x-nucleo boards is focused on general ideas of the HAL and BSP layers.

I am looking for more practical approach of integrating BSP with Cubex.

Thanks for any suggestion,

Bogdan

#bsp #cube-mx
This topic has been closed for replies.
Best answer by Bogdan Golab
Posted on February 01, 2017 at 23:44

Hi Sirma / Eric,

I tried again and I think I found the final solution:

I. Follow your procedure but point 1) shall be changed to:

Create a project with CubeMX and enable I2C1 because the BSP drivers will use it

This way you will eliminate all I2C related error

II. Include the following files in your main.c

#include 'x_nucleo_iks01a1.h'

#include 'x_nucleo_iks01a1_temperature.h'

#include <string.h>

#include <math.h>

Note :string.h and math.h are required because I reused an example function.

III. Add the pointers required by MEM APIe.g. for temperature sensor:

    static void *HTS221_T_0_handle  = NULL;

IV. Use API for example:

    BSP_TEMPERATURE_Init( HTS221_T_0, &HTS221_T_0_handle );

    BSP_TEMPERATURE_Sensor_Enable( HTS221_T_0_handle );

    Temperature_Sensor_Handler( HTS221_T_0_handle );

    BSP_TEMPERATURE_Sensor_Disable( HTS221_T_0_handle );

I reused Temperature_Sensor_Handler( HTS221_T_0_handle ); for simplicity

V. Copy the example function to main.c:

static void Temperature_Sensor_Handler( void *handle )

{

...

}

VI. Add required *.C files to your project (in this case *.C files from the drivers folders e.g. in my case

              <FileName>x_nucleo_iks01a1_temperature.c</FileName>

              <FileName>HTS221_Driver.c</FileName>

              <FileName>HTS221_Driver_HL.c</FileName>

              <FileName>x_nucleo_iks01a1.c</FileName>

              <FileName>LPS22HB_Driver.c</FileName>

              <FileName>LPS22HB_Driver_HL.c</FileName>

              <FileName>LPS25HB_Driver.c</FileName>

              <FileName>LPS25HB_Driver_HL.c</FileName>

===

Summary: It seems that CubeMX and MEMs BSP can be easly integrated.

The general idea is:

-generate CubeMX and enable required resources. In case of MEMs it's I2C1, In case of L476G (Eric's example) it's

DFSDM1

-add include search paths to your project

-add *.C files from Drivers folders to satisfy linker

-then work with the API

===

Sirma/Eric,

Thank you very much for great support.

Bogdan

14 replies

victagayun
Senior III
August 5, 2020

Why cant CudeIDE add the BSP folder anyway? Just a few MBs.

Until there is a better solution, just add the BSP folder when generating projects by CubeIDE together with the include paths and linker paths.

This way we can reduce the problems and confusions.

Copy here, copy there, add paths to this and that.

victagayun
Senior III
August 7, 2020

Why cant just copy the whole BSP folder and add in the include paths and also symbols.

The folder is just few MBs.

This way it wont create any confusion among newbie like me.