STM32LowPower library won't compile

Hi all!

I’m currently working on a project on a Nucleo Board (the one with the STM32L054R8), using the Arduino framework. My application requires low power operation most of the time, To do this, I’m attempting to use the STM32LowPower by Wi6Labs (it is found in the library search in PlatformIO). however, when attempting to compile I get the following message:

‘LowPower_init’ was not declared in this scope; did you mean ‘LowPower’?

After checking the source files for the libraries I found that there’s an #ifdef inside the LowPower.c file that checks for some defines, the line question is the following:

#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION > 0x01090000) && defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)

which fails (gets a false result) and comments out all the code required for the library to work without problems. From further searching on the source files, I noticed that the things that should be defined (STM32_CORE_VERSION and HAL_PWR_MODULE_ENABLED), however I don’t know if the core version is greater than the value being evaluated. I understand that the library was made for Arduino IDE in mind, so it might be that core versions on PlatformIO might be differently numbered. If anyone could provide me with some pointers on what to look for, I would deeply appreciate it.



PS: Sorry for the formatting, now sure how to work with the controls on the forum’s text editor.

Which board did you select? I did not find a PlatformIO board (PlatformIO Registry) which has this chip. What’s your platformio.ini?

The specific Board is nucleo_l053r8

Quick Update: I managed to get a “fix” on this by modifying the library files to use a >= condition instead of a >. This makes everything compile, haven’t tested it yet to see if it works. Despite this, I would still like to know if there’s some other way to do a more appropriate fix for this problem.

Oh yeah makes total sense. As you can see in Releases · platformio/platform-ststm32 · GitHub the latest included Arduino-STM32 version is 1.9.0. This is also the latest actual version: Releases · stm32duino/Arduino_Core_STM32 · GitHub

So STM32_CORE_VERSION can be impossibly higher than 1.9.0 if you’re using the release version of things. Only if you’re using the bleeding edge version you get “2.0.0” as a working version number

The release version 1.9.0 does however say

So you should use the library version which is meant for that release version, which seems to be 1.0.3 (GitHub - stm32duino/STM32LowPower at 1.0.3) by writing

lib_deps = 
   STM32duino Low Power@1.0.3

in the platformio.ini.

Thanks a lot! That makes total sense, didn’t know about that part. Will implement it like that.