stm32duino / STM32LowPower

Arduino Low Power library for STM32
183 stars 52 forks source link

Issue compiling for STM32MP1 #40

Closed jatincc closed 3 years ago

jatincc commented 4 years ago

I am trying to compile the following sketch. This is the ExternalWakeup sketch. But the error occurs on other examples as well.

Also the Releases for the STM32LowPower and STM32RTC library are not correct. The attached release files are of 1.0.0 and not 1.0.3. Is this intentional? I have tried both and the same error was present.

/*
  ExternalWakeup

  This sketch demonstrates the usage of External Interrupts (on pins) to wakeup
  a chip in sleep mode. Sleep modes allow a significant drop in the power usage
  of a board while it does nothing waiting for an event to happen.
  Battery powered application can take advantage of these modes to enhance
  battery life significantly.

  In this sketch, pressing a pushbutton attached to pin will wake up the board.

  This example code is in the public domain.
*/

#include "hal_conf_extra.h"
#include "STM32LowPower.h"

// Blink sequence number
// Declare it volatile since it's incremented inside an interrupt
volatile int repetitions = 1;

// Pin used to trigger a wakeup
#ifndef USER_BTN
#define USER_BTN SYS_WKUP1
#endif

const int pin = USER_BTN;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Set pin as INPUT_PULLUP to avoid spurious wakeup
  pinMode(pin, INPUT_PULLUP);

  // Configure low power
  LowPower.begin();
  // Attach a wakeup interrupt on pin, calling repetitionsIncrease when the device is woken up
  LowPower.attachInterruptWakeup(pin, repetitionsIncrease, RISING);
}

void loop() {
  for (int i = 0; i < repetitions; i++) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  }
  // Triggers an infinite sleep (the device will be woken up only by the registered wakeup sources)
  // The power consumption of the chip will drop consistently
  LowPower.sleep();
}

void repetitionsIncrease() {
  // This function will be called once on device wakeup
  // You can do some little operations here (like changing variables which will be used in the loop)
  // Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
  repetitions ++;
}

This is the code in "hal_conf_extra.h".

#define HAL_RTC_MODULE_ENABLED

I get the following Error.

In file included from /home/mint/Arduino/libraries/STM32duino_Low_Power/src/STM32LowPower.h:51,
                 from /home/mint/Documents/Shepherd Projects/Low power/ExternalWakeup/ExternalWakeup.ino:17:
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:75:17: error: 'HOUR_FORMAT_12' was not declared in this scope
   75 |       HOUR_12 = HOUR_FORMAT_12,
      |                 ^~~~~~~~~~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:76:17: error: 'HOUR_FORMAT_24' was not declared in this scope
   76 |       HOUR_24 = HOUR_FORMAT_24
      |                 ^~~~~~~~~~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:80:12: error: 'HOUR_AM' was not declared in this scope; did you mean 'HOUR_24'?
   80 |       AM = HOUR_AM,
      |            ^~~~~~~
      |            HOUR_24
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:81:12: error: 'HOUR_PM' was not declared in this scope; did you mean 'HOUR_24'?
   81 |       PM = HOUR_PM
      |            ^~~~~~~
      |            HOUR_24
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:85:28: error: 'OFF_MSK' was not declared in this scope
   85 |       MATCH_OFF          = OFF_MSK,                          // Never
      |                            ^~~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:86:28: error: 'SS_MSK' was not declared in this scope
   86 |       MATCH_SS           = SS_MSK,                           // Every Minute
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:87:28: error: 'SS_MSK' was not declared in this scope
   87 |       MATCH_MMSS         = SS_MSK | MM_MSK,                  // Every Hour
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:87:37: error: 'MM_MSK' was not declared in this scope
   87 |       MATCH_MMSS         = SS_MSK | MM_MSK,                  // Every Hour
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:88:28: error: 'SS_MSK' was not declared in this scope
   88 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:88:37: error: 'MM_MSK' was not declared in this scope
   88 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:88:46: error: 'HH_MSK' was not declared in this scope
   88 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:28: error: 'SS_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:37: error: 'MM_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:46: error: 'HH_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:55: error: 'D_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:28: error: 'SS_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:37: error: 'MM_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:46: error: 'HH_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:55: error: 'D_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:63: error: 'M_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                                               ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:28: error: 'SS_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:37: error: 'MM_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:46: error: 'HH_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:55: error: 'D_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:63: error: 'M_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                                               ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:71: error: 'Y_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h: In member function 'bool STM32RTC::isTimeSet()':
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:204:14: error: 'RTC_IsTimeSet' was not declared in this scope; did you mean 'isTimeSet'?
  204 |       return RTC_IsTimeSet();
      |              ^~~~~~~~~~~~~
      |              isTimeSet
exit status 1
Error compiling for board STM32MP1 series coprocessor.
fpistm commented 3 years ago

Hi @khepri420

Also the Releases for the STM32LowPower and STM32RTC library are not correct. The attached release files are of 1.0.0 and not 1.0.3. Is this intentional?

There is non issue with the release. The latest tag is 1.0.3 and this is the one installed with the Arduino library manager. About https://github.com/stm32duino/STM32LowPower/blob/3f3cd07d3b80e58afb76ddd2a3b4e840300ec1dd/library.properties#L2 This is the version of the master which is always ongoing and will be the next release. It is currently not tag as it will be done at the same time than the core.

About your issue, in fact the MP1 could not use this library as the RTC shall not be handled by Arduino in STM32MP1xx. https://github.com/stm32duino/STM32RTC/blob/5be72b02fe6430cb6fecaa441863ae767a172656/src/rtc.c#L42-L50

Anyway, I don't know how you get this error, probably you doesn't have the STM32RTC library installed. Else you would get this error:

STM32duino_RTC\src/STM32RTC.h:46:4: error: #error "RTC configuration is missing. Check flag HAL_RTC_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"
   46 |   #error "RTC configuration is missing. Check flag HAL_RTC_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"
      |    ^~~~~