Skip to content

Commit e4dd9d6

Browse files
committed
Improve documentation
1 parent 9d403bc commit e4dd9d6

File tree

2 files changed

+38
-29
lines changed

2 files changed

+38
-29
lines changed

examples/WakeFromPin/WakeFromPin.ino

+18-12
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@
55
* The pin can be configured to wake up the device on a rising or falling edge, but not all pins are supported.
66
* Please check the README.md file for more information about the supported pins.
77
*
8-
* The example uses two buttons connected to pin 0 and A3:
9-
* * The device will go to sleep when the button connected to pin 0 is pressed.
8+
* The example uses two buttons connected to pin D0 and A3:
9+
* * The device will go to sleep when the button connected to pin D0 is pressed.
1010
* * The device will wake up when the button connected to pin A3 is pressed.
1111
*
1212
* The example also demonstrates how to use the PF1550 PMIC to turn off the peripherals
1313
* before going to sleep and turn them back on after waking up.
14-
* uncomment #define TURN_PERIPHERALS_OFF on line 33 to enable this feature.
14+
* uncomment #define TURN_PERIPHERALS_OFF to enable this feature.
1515
*
16-
* When the device is not sleeping it will blink the built-in LED every 100ms.
16+
* When the device is not sleeping it will blink the built-in LED.
1717
*
1818
* INSTRUCTIONS:
19-
* - Make sure you are running the latest version of the Renesas Core
19+
* - Make sure you are running the latest version of the Portenta C33 Core
2020
* - Select the Portenta C33 board from the Tools menu
21-
* - Select the Portenta C33 USB port from the Tools menu
21+
* - Select the Portenta C33's USB port from the Tools menu
2222
* - Upload the code to your Portenta C33
23-
* - Connect a button to pin 0 and with a pull-up resistor to 3.3V
24-
* - Connect a button to pin A3 and with a pull-up resistor to 3.3V
23+
* - Connect a button to pin D0 and ground (internal pull-up resistor is enabled)
24+
* - Connect a button to pin A3 and ground (internal pull-up resistor is enabled)
2525
* (If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
2626
*
27-
* Original author: C. Dragomir (http://arduino.cc)
27+
* Initial author: C. Dragomir
2828
*/
2929

3030
#include "Arduino_LowPowerPortentaC33.h"
3131

32-
// #define TURN_PERIPHERALS_OFF
33-
#define SLEEP_PIN 0 // Pin used to put the device to sleep
32+
// #define TURN_PERIPHERALS_OFF // Uncomment this line to turn off the peripherals before going to sleep
33+
#define SLEEP_PIN D0 // Pin used to put the device to sleep
3434
#define WAKE_PIN A3 // Pin used to wake up the device
3535

3636
LowPower lowPower;
@@ -60,16 +60,22 @@ LowPower lowPower;
6060
void goToSleep(){
6161
#ifdef TURN_PERIPHERALS_OFF
6262
turnPeripheralsOff();
63+
#else
64+
// Turn off the built-in LED before going to sleep
65+
digitalWrite(LED_BUILTIN, HIGH);
6366
#endif
6467
lowPower.deepSleep();
6568
}
6669

6770
void setup(){
68-
lowPower = LowPower();
71+
// Register the sleep and wake-up pins as inputs with pull-up resistors
72+
pinMode(SLEEP_PIN, INPUT_PULLUP);
73+
pinMode(WAKE_PIN, INPUT_PULLUP);
6974

7075
// Register the callback function to put the device to sleep when the button is pressed
7176
attachInterrupt(digitalPinToInterrupt(SLEEP_PIN), goToSleep, RISING);
7277
lowPower.enableWakeupFromPin(WAKE_PIN, RISING);
78+
7379
pinMode(LED_BUILTIN, OUTPUT);
7480

7581
#ifdef TURN_PERIPHERALS_OFF

examples/WakeFromRTC/WakeFromRTC.ino

+20-17
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22
********************************************************************************
33
*
44
* This example demonstrates how to use the RTC to wake up the
5-
* Portenta C33 from deep sleep. The device will go to sleep for 1 second and
5+
* Portenta C33 from deep sleep. The device will go to sleep for 5 seconds and
66
* then wake up. The built-in LED will blink every second.
77
*
88
* The example also demonstrates how to use the PF1550 PMIC to turn off the peripherals
99
* before going to sleep and turn them back on after waking up.
10-
* uncomment #define TURN_PERIPHERALS_OFF on line 23 to enable this feature.
10+
* uncomment #define TURN_PERIPHERALS_OFF to enable this feature.
1111
*
1212
* INSTRUCTIONS:
1313
* - Make sure you are running the latest version of the Renesas Core
1414
* - Select the Portenta C33 board from the Tools menu
1515
* - Select the Portenta C33 USB port from the Tools menu
1616
* - Upload the code to your Portenta C33
1717
*
18-
* Original author: C. Dragomir (http://arduino.cc)
19-
18+
* Initial author: C. Dragomir
2019
*/
2120

22-
// #define TURN_PERIPHERALS_OFF
21+
// #define TURN_PERIPHERALS_OFF // Uncomment this line to turn off the peripherals before going to sleep
2322

2423
#include "RTC.h"
2524
#include "Arduino_LowPowerPortentaC33.h"
@@ -61,9 +60,19 @@ void initializeRealTimeClock(){
6160
}
6261
}
6362

64-
void setup(){
65-
lowPower = LowPower();
63+
void goToSleep(){
64+
#ifdef TURN_PERIPHERALS_OFF
65+
// Turn peripherals off before going to sleep
66+
// LED turns off automatically as part of this process
67+
turnPeripheralsOff();
68+
#else
69+
// Turn off the LED to indicate the device is going to sleep
70+
digitalWrite(LED_BUILTIN, HIGH);
71+
#endif
72+
lowPower.deepSleep();
73+
}
6674

75+
void setup(){
6776
#ifdef TURN_PERIPHERALS_OFF
6877
PMIC.begin();
6978
turnPeripheralsOn();
@@ -75,10 +84,11 @@ void setup(){
7584
pinMode(LEDR, OUTPUT); // Use the red LED to indicate errors
7685
digitalWrite(LEDR, HIGH); // Turn off the red LED
7786
digitalWrite(LED_BUILTIN, LOW); // Turn on the LED
87+
7888
delay(5000); // lets the user see the led for 5 seconds
7989

80-
// The device will go to sleep every 5 seconds and wake up after 5 seconds to blink the LED
81-
// effectivelly creating the same efect as the blink sketch
90+
// The device will go to sleep after 5 seconds and wake up after 5 seconds to light up the LED
91+
// effectivelly creating the same visual effect as the blink sketch.
8292
if(!lowPower.setWakeUpAlarm(0, 0, 5)){
8393
// Blink the red LED indefinitely to indicate an error
8494
while(true){
@@ -89,14 +99,7 @@ void setup(){
8999
}
90100
}
91101

92-
#ifdef TURN_PERIPHERALS_OFF
93-
// turn peripherals off before going to sleep
94-
turnPeripheralsOff();
95-
#else
96-
// Turn off the LED to indicate the device is going to sleep
97-
digitalWrite(LED_BUILTIN, HIGH);
98-
#endif
99-
lowPower.deepSleep();
102+
goToSleep();
100103
}
101104

102105
void loop(){}

0 commit comments

Comments
 (0)