cancel
Showing results for 
Search instead for 
Did you mean: 

I need an example or description of how to define the function parameter device pObj that appears in all the ENV sensor function calls in the STM32Cube.

eskul
Associate

I started out with an example bare-metal project for the B-L475W-IOT1A Discovery board, that reads the HTS221 temperature and humidity, and LPS22HB pressure. Very straight forward. For ex, api to read temp: float HTS221_T_ReadTemp(uint16_t DeviceAddr). Only need to provide I2C ID to function call. NOTE: the api's came out of STM32LCube\STM_Discovery_STM32Cube\STM32Cube_FW_L4_V1.13.0\Projects\B-L475E-IOT01A\Examples\Lab2_PTH_FreeRTOS\Drivers\BSP\Components.

Next, ran STM32CubeMX tool, created a new project set up to read same sensors (this process was not really straight forward - the GUI has weird nooks/crannies you need to dig thru to get the I2C set up). This project also included FreeRTOS. When CubeMX created the project, a new api was installed on my drive, C:\...\STM32Cube\Repository\STM32Cube_FW_L4_V1.13.0\Drivers\BSP\B-L475E-IOT01.

This api is completely different than the one above. There is a huge gaping hole in the documentation for this new(?) api - there is no info on now to define the argument to virtually every function call, int32_t HTS221_TEMP_GetTemperature(HTS221_Object_t *pObj, float *Value)

The arg HTS2221_Object_t *pObj, which is defined as a struct,

typedef struct

{

 HTS221_IO_t    IO;

 hts221_ctx_t    Ctx;

 uint8_t      is_initialized;

 uint8_t      hum_is_enabled;

 uint8_t      temp_is_enabled;

} HTS221_Object_t;

with IO and Ctx being yet more structs. How is this initialized and used so that the temperature etc read functions are usable?

Thank you.

Update: Made another attempt in STM32CubeMX, created a new project, this time I did not include the "Additional Software" component for "Board Component MEMS". However I still included in the other "Additional Softwares" viewer (Link is at top-center of the Pinout and Config tab), which lists several groups of STMicroelectronics Packs, including packs for the HTS221 and the LPS22HB that are on the version of Discovery board I'm working with. These were selected/enabled (config for I2C). After Generating Code, there is no inclusion of the API's for either of these sensor functions.

So at this point, it appears even tho these two packs appeared to be included in the project setup, they were ignored by the MX tool. Why?

In the prior iteration, wherein, I had included the additional MEMS board functions, the API's for the HTS/LPS were included but did not match those from the bare-metal example, and as lamented above, are not as straight forward to use.

Still digging. Any guidance to get me over this mountain appreciated (I still have 2 deserts and a river to cross....).

 Update2: Looking in the MX Help-Manage...Packs, the version that the tool is running with is STM32Cube MCU Package for STM32L4 Series, ver 1.13.0. Poking around the earlier versions, at ver. 1.8.1, version notes state that support was added for the board I'm running with. A little more digging around, figured out the tool only inserts the API for the sensors (HTS221, LPS22B that are on the Discovery board) when the Board Components MEMS and BoardSupport STM32Cube Custom BSP Drivers are included, which maps to a Packs subfolder,

\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-MEMS1\5.2.1

It is in that Packs folder that the HTS221.c and corresponding .c for the other chip are being pulled from when the extra SW noted above are included. Without including these, the API's for the two chips are not included regardless that I have included them via the Additional SW list (I noted in previous post above).

OK, if you have read thru this far, you are likely as confused as I am. Bottom line, the tool is not working in an intuitive manner here and the documentation for MX I've looked at doesn't address this issue. I don't see a way to make the MX tool "see" the package for these sensor chips that are in the STM32LCube\STM_Discovery_STM32Cube\STM32Cube_FW_L4_V1.13.0\Drivers\BSP\B-L475E-IOT01 folder, even tho I redirected the Project Manager Firmware Location option to use path,

\STM32LCube\STM_Discovery_STM32Cube\STM32Cube_FW_L4_V1.13.0

The Additional Softwares only sees what is in ver 5.2.1.

I also attempted to just create project w/o the sensor support, and add the files from the above STM32LCube BSP folder but that failed to compile with lots of errors/warnings of missing or obsolete files.

Guidance appreciated...

Update3: One more attempt to manually add the sensor support. This time, after wading thru the errors re. missing files, finished compile. Did a test run first without RTOS (just commented out the thread and kernel startup). Works as expected but man, I feel like I ended up with a mess of a project with files pulled in from several places.

At this point I would like to know:

1) how does one get control over the MX tool's application of Packs? In this case, MX insists on using the 5.2.1 (as noted above) version sensor api. I want to use a different API...

2) In re. the sensor API that MX is insisting (5.2.1), how does the pObj get defined (again, per earlier post above)?

0 REPLIES 0