37
37
********************************************************************************
38
38
*/
39
39
40
+ /* *
41
+ * @enum LowPowerReturnCode
42
+ * @brief Provides the return codes for the standby operations.
43
+ * The codes indicate the success or failure of the operations.
44
+ */
40
45
enum class LowPowerReturnCode
41
46
{
42
47
success, // /< The call was successful
@@ -60,19 +65,50 @@ enum class LowPowerReturnCode
60
65
********************************************************************************
61
66
*/
62
67
68
+ /* *
69
+ * @brief The LowPowerStandbyType class represents different types of standby modes for low power operation.
70
+ *
71
+ * This class provides options for standby modes: waiting until pin activity or until a specified time has elapsed.
72
+ * It also allows to combine the two options.
73
+ */
63
74
class LowPowerStandbyType {
64
75
public:
76
+ /* *
77
+ * @brief Class representing an activity that waits until a pin changes its state.
78
+ *
79
+ * This class provides functionality to wait until a specified pin changes its state,
80
+ * either from LOW to HIGH or from HIGH to LOW.
81
+ */
65
82
class UntilPinActivityClass {
66
83
};
67
84
85
+ /* *
86
+ * @brief Represents a wakeup option which waits until a pin activity occurs.
87
+ * This allows the microcontroller to wake up from standby through a pin interrupt
88
+ * from a peripheral device.
89
+ */
68
90
static const UntilPinActivityClass untilPinActivity;
69
91
92
+ /* *
93
+ * @brief A class representing a time elapsed condition.
94
+ *
95
+ * This class is used to specify a condition based on the elapsed time.
96
+ * It is typically used in conjunction with the LowPower library for Arduino.
97
+ */
70
98
class UntilTimeElapsedClass {
71
99
};
72
100
101
+ /* *
102
+ * @brief Represents a wakeup option which waits until a specified time has elapsed.
103
+ */
73
104
static const UntilTimeElapsedClass untilTimeElapsed;
74
105
75
106
private:
107
+
108
+ /* *
109
+ * @brief Represents a wakeup option which waits until either
110
+ * a pin activity occurs or a specified time has elapsed.
111
+ */
76
112
class UntilEitherClass {
77
113
};
78
114
@@ -85,6 +121,9 @@ class LowPowerStandbyType {
85
121
const LowPowerStandbyType::UntilPinActivityClass& untilPinActivity);
86
122
};
87
123
124
+ /* *
125
+ * @brief The RTCWakeupDelay class represents a delay before waking up from a low power mode.
126
+ */
88
127
class RTCWakeupDelay {
89
128
public:
90
129
/* *
@@ -104,6 +143,11 @@ class RTCWakeupDelay {
104
143
// We don't really need this large type, but we must use this specific
105
144
// type for user-defined literals to work.
106
145
unsigned long long int value;
146
+
147
+ /* *
148
+ * @brief Private constructor to create a delay object with a specific delay value.
149
+ * @param delay The delay value in seconds.
150
+ */
107
151
RTCWakeupDelay (const unsigned long long int delay) : value(delay)
108
152
{
109
153
}
@@ -117,6 +161,20 @@ class RTCWakeupDelay {
117
161
friend class LowPowerPortentaH7 ;
118
162
};
119
163
164
+ /* *
165
+ * @class LowPowerPortentaH7
166
+ * @brief A class that provides low power functionality for the Portenta H7 board.
167
+ *
168
+ * The LowPowerPortentaH7 class allows the microcontroller on the Portenta H7 board
169
+ * to enter low power modes such as Standby Mode and Deep Sleep Mode. It provides
170
+ * functions to check the current mode, prepare the option bytes for entering Standby Mode,
171
+ * and control the M4 and M7 cores independently. It also provides functions to measure
172
+ * the time since boot, time spent in idle, sleep, and deep sleep modes.
173
+ *
174
+ * This class is a singleton and can be accessed using the getInstance() function.
175
+ *
176
+ * @note This class is specific to the Portenta H7 board.
177
+ */
120
178
class LowPowerPortentaH7 {
121
179
private:
122
180
LowPowerPortentaH7 () = default ;
@@ -168,11 +226,18 @@ class LowPowerPortentaH7 {
168
226
}
169
227
170
228
public:
229
+ /* *
230
+ * Returns the singleton instance of the LowPowerPortentaH7 class.
231
+ * Due to the way the low power modes are configured, only one instance
232
+ * of this class can exist at a time.
233
+ *
234
+ * @return The singleton instance of the LowPowerPortentaH7 class.
235
+ */
171
236
static LowPowerPortentaH7& getInstance () noexcept {
172
237
static LowPowerPortentaH7 instance;
173
238
return instance;
174
239
}
175
-
240
+
176
241
// / @cond DEV
177
242
LowPowerPortentaH7 (const LowPowerPortentaH7&) = delete ;
178
243
LowPowerPortentaH7 (LowPowerPortentaH7&&) = delete ;
@@ -290,6 +355,9 @@ class LowPowerPortentaH7 {
290
355
********************************************************************************
291
356
*/
292
357
358
+ /* *
359
+ * @brief The global LowPower singleton object provides access to low power features of the Portenta H7 board.
360
+ */
293
361
extern const LowPowerPortentaH7& LowPower;
294
362
295
363
/*
@@ -298,15 +366,51 @@ extern const LowPowerPortentaH7& LowPower;
298
366
********************************************************************************
299
367
*/
300
368
369
+ /* *
370
+ * @brief Literals operator to add multiple delays together. e.g. 5_s + 10_min + 2_h
371
+ * @param d1 The first delay.
372
+ * @param d2 The second delay.
373
+ * @return The sum of the two delays.
374
+ */
301
375
RTCWakeupDelay operator +(const RTCWakeupDelay d1, const RTCWakeupDelay d2);
376
+
377
+ /* *
378
+ * @brief Literals operator to create a delay in seconds.
379
+ * @param seconds The number of seconds to wait before waking up.
380
+ * @return The delay object.
381
+ */
302
382
RTCWakeupDelay operator " " _s(const unsigned long long int seconds);
383
+
384
+ /* *
385
+ * @brief Literals operator to create a delay in minutes.
386
+ * @param minutes The number of minutes to wait before waking up.
387
+ * @return The delay object.
388
+ */
303
389
RTCWakeupDelay operator " " _min(const unsigned long long int minutes);
304
390
391
+ /* *
392
+ * @brief Literals operator to create a delay in hours.
393
+ * @param hours The number of hours to wait before waking up.
394
+ * @return The delay object.
395
+ */
305
396
RTCWakeupDelay operator " " _h(const unsigned long long int hours);
397
+
398
+ /* *
399
+ * @brief Operator to combine two wakeup options.
400
+ * @param untilPinActivity The pin activity wakeup option.
401
+ * @param untilTimeElapsed The time elapsed wakeup option.
402
+ * @return The combined wakeup option.
403
+ */
306
404
LowPowerStandbyType::UntilEitherClass operator |(
307
405
const LowPowerStandbyType::UntilPinActivityClass& untilPinActivity,
308
406
const LowPowerStandbyType::UntilTimeElapsedClass& untilTimeElapsed);
309
407
408
+ /* *
409
+ * @brief Operator to combine two wakeup options.
410
+ * @param untilTimeElapsed The time elapsed wakeup option.
411
+ * @param untilPinActivity The pin activity wakeup option.
412
+ * @return The combined wakeup option.
413
+ */
310
414
LowPowerStandbyType::UntilEitherClass operator |(
311
415
const LowPowerStandbyType::UntilTimeElapsedClass& untilTimeElapsed,
312
416
const LowPowerStandbyType::UntilPinActivityClass& untilPinActivity);
0 commit comments