Skip to content

Commit 38bdac1

Browse files
authored
Merge pull request #5 from alrvid/main
Documentation improvements plus Ethernet turn-off fix
2 parents 5254425 + 7a13c73 commit 38bdac1

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

Diff for: docs/api.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This class is specific to the Portenta H7 board.
2828
| [`numberOfDeepSleepLocks`](#class_low_power_portenta_h7_1a9d2730d86abf42782261b0f03778c3bb) | Check how many Deep Sleep locks are held at the moment. |
2929
| [`prepareOptionBytes`](#class_low_power_portenta_h7_1abdc0ce13b68d3a2188702690997af2ae) | Prepare the option bytes for entry into Standby Mode. |
3030
| [`standbyM4`](#class_low_power_portenta_h7_1a9e07fd4f7895a7753e7e28f99aca1ace) | Make the M4 core enter Standby Mode. |
31-
| [`standbyM7`](#class_low_power_portenta_h7_1a1eb5cec6e9604a48074f1c10ef5e7fb0) | Make the M7 core enter Standby Mode. |
31+
| [`standbyM7`](#class_low_power_portenta_h7_1aa9c1cb86c832c35f6653a3d6c9f0d32f) | Make the M7 core enter Standby Mode. |
3232
| [`timeSinceBoot`](#class_low_power_portenta_h7_1a4758c25574b6d099545ac8d55eff6f68) | Time since the board was booted. It reports the time since the last wake-up reset (after being in Standby Mode) or power-on depending on what happened last. |
3333
| [`timeSpentIdle`](#class_low_power_portenta_h7_1ad42fdfa6885d8e0fdca5aa012fdb4c60) | Time spent in idle. |
3434
| [`timeSpentInSleep`](#class_low_power_portenta_h7_1a994eb6fcc0382515a82b81fa37ca9f3c) | Time spent in Sleep Mode. |
@@ -130,18 +130,18 @@ Make the M4 core enter Standby Mode.
130130
A constant from the LowPowerReturnCode enum.
131131
<hr />
132132

133-
### `standbyM7` <a id="class_low_power_portenta_h7_1a1eb5cec6e9604a48074f1c10ef5e7fb0" class="anchor"></a>
133+
### `standbyM7` <a id="class_low_power_portenta_h7_1aa9c1cb86c832c35f6653a3d6c9f0d32f" class="anchor"></a>
134134

135135
```cpp
136-
template<> std::enable_if< ArgumentsAreCorrect< T, Args... >::value, LowPowerReturnCode >::type standbyM7(const T standbyType, const Args... args) const
136+
LowPowerReturnCode standbyM7(const T standbyType, const Args... args) const
137137
```
138138
139139
Make the M7 core enter Standby Mode.
140140
141141
#### Parameters
142142
* `standbyType` One or a combination of [LowPowerStandbyType::untilPinActivity](#class_low_power_standby_type_1a4c5b50ac615cf60ff88dd3b9bb145fa9) and [LowPowerStandbyType::untilTimeElapsed](#class_low_power_standby_type_1aa4882e571c0e9444c5978c8520e8e90e). The combination is done with the | operator.
143143
144-
* `args` The delay before waking up again
144+
* `args` An optional delay before waking up again, if [LowPowerStandbyType::untilTimeElapsed](#class_low_power_standby_type_1aa4882e571c0e9444c5978c8520e8e90e) is used.
145145
146146
#### Returns
147147
A constant from the LowPowerReturnCode enum.

Diff for: examples/Standby/Standby.ino

+6-1
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ void setup() {
127127

128128
#if defined CORE_CM7
129129
LowPower.standbyM7(LowPowerStandbyType::untilPinActivity | LowPowerStandbyType::untilTimeElapsed, 10_s);
130-
// The following is an alternative way to go into standby for 10 seconds
130+
//
131+
// The following is an alternative way to go into Standby Mode for 10 seconds:
131132
// LowPower.standbyM7(LowPowerStandbyType::untilTimeElapsed, RTCWakeupDelay(0, 0, 10));
133+
//
134+
// The following is how to go to into Standby Mode waiting only for a wakeup pin:
135+
// LowPower.standbyM7(LowPowerStandbyType::untilPinActivity);
136+
//
132137
#else
133138
LowPower.standbyM4();
134139
#endif

Diff for: src/Arduino_LowPowerPortentaH7.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ bool LowPowerPortentaH7::wasInCPUMode(CPUMode mode) const
233233

234234
void LowPowerPortentaH7::resetPreviousCPUModeFlags() const
235235
{
236-
PWR->CPUCR |= PWR_CPUCR_CSSF; // Clear standby flags
236+
PWR->CPUCR |= PWR_CPUCR_CSSF;
237237
}
238238

239239
uint16_t LowPowerPortentaH7::numberOfDeepSleepLocks() const
@@ -312,7 +312,7 @@ LowPowerReturnCode LowPowerPortentaH7::standbyM4() const
312312
// <--
313313

314314
// Disable and clear all pending interrupts in the NVIC. There are 8
315-
// registers in the Cortex-M7.
315+
// registers in the Cortex-M4.
316316
for (auto i = 0; i < 8; i++)
317317
{
318318
NVIC->ICER[i] = 0xffffffff;

Diff for: src/Arduino_LowPowerPortentaH7.h

+26-8
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class LowPowerPortentaH7 {
312312
*/
313313
[[deprecated("This function is experimental and should not be used in production code")]]
314314
uint16_t numberOfDeepSleepLocks() const;
315-
315+
316316
/**
317317
* @brief Prepare the option bytes for entry into Standby Mode.
318318
* @return A constant from the LowPowerReturnCode enum.
@@ -325,18 +325,27 @@ class LowPowerPortentaH7 {
325325
*/
326326
LowPowerReturnCode standbyM4() const;
327327

328+
// This is the variant that the compiler will see and use
329+
/// @cond DEV
330+
template<typename T, typename... Args>
331+
typename std::enable_if<ArgumentsAreCorrect<T, Args...>::value,
332+
LowPowerReturnCode>::type
333+
standbyM7(const T standbyType, const Args... args) const;
334+
/// @endcond
335+
// This is the simplified variant that Doxygen will see and use
336+
// Notice that DOXYGEN_ONLY isn't defined anywhere - it doesn't
337+
// have to be since Doxygen is configured with ENABLE_PREPROCESSING NO
338+
#ifdef DOXYGEN_ONLY
328339
/**
329340
* @brief Make the M7 core enter Standby Mode.
330341
* @param standbyType One or a combination of LowPowerStandbyType::untilPinActivity
331342
* and LowPowerStandbyType::untilTimeElapsed. The combination is done with the | operator.
332-
* @param args The delay before waking up again
343+
* @param args An optional delay before waking up again, if LowPowerStandbyType::untilTimeElapsed is used.
333344
* @return A constant from the LowPowerReturnCode enum.
334345
*/
335-
template<typename T, typename... Args>
336-
typename std::enable_if<ArgumentsAreCorrect<T, Args...>::value,
337-
LowPowerReturnCode>::type
338-
standbyM7(const T standbyType, const Args... args) const;
339-
346+
LowPowerReturnCode standbyM7(const T standbyType, const Args... args) const;
347+
#endif
348+
340349
/**
341350
* @brief Time since the board was booted.
342351
* It reports the time since the last wake-up reset (after being in Standby Mode)
@@ -436,6 +445,7 @@ LowPowerStandbyType::UntilEitherClass operator|(
436445
********************************************************************************
437446
*/
438447

448+
/// @cond DEV
439449
template<typename T, typename... Args>
440450
typename std::enable_if<LowPowerPortentaH7::ArgumentsAreCorrect<T, Args...>::value,
441451
LowPowerReturnCode>::type
@@ -453,11 +463,18 @@ LowPowerPortentaH7::standbyM7(const T standbyType,
453463
// otherwise, the Ethernet transmit termination resistors will overheat
454464
// from the voltage that gets applied over them. It would be 125 mW in each
455465
// of them, while they are rated at 50 mW. If we fail to turn off Ethernet,
456-
// we must not proceed.
466+
// we must not proceed. If this library is used with another library that
467+
// turns off the rail that powers the Ethernet chip before calling this
468+
// function, that library should #define NO_ETHERNET_TURN_OFF, or entering
469+
// Standby Mode will fail. Anyone who defines that constant takes
470+
// responsibility for not overheating the resistors. It is NOT part of the
471+
// API intended for ordinary users.
472+
#ifndef NO_ETHERNET_TURN_OFF
457473
if (false == turnOffEthernet())
458474
{
459475
return LowPowerReturnCode::turningOffEthernetFailed;
460476
}
477+
#endif
461478

462479
// Prevent Mbed from changing things
463480
core_util_critical_section_enter();
@@ -687,5 +704,6 @@ LowPowerPortentaH7::standbyM7(const T standbyType,
687704

688705
return LowPowerReturnCode::m7StandbyFailed;
689706
}
707+
/// @endcond
690708

691709
#endif // End of header guard

0 commit comments

Comments
 (0)