|
5 | 5 | * The pin can be configured to wake up the device on a rising or falling edge, but not all pins are supported.
|
6 | 6 | * Please check the README.md file for more information about the supported pins.
|
7 | 7 | *
|
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. |
10 | 10 | * * The device will wake up when the button connected to pin A3 is pressed.
|
11 | 11 | *
|
12 | 12 | * The example also demonstrates how to use the PF1550 PMIC to turn off the peripherals
|
13 | 13 | * 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. |
15 | 15 | *
|
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. |
17 | 17 | *
|
18 | 18 | * 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 |
20 | 20 | * - 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 |
22 | 22 | * - 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) |
25 | 25 | * (If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
|
26 | 26 | *
|
27 |
| -* Original author: C. Dragomir (http://arduino.cc) |
| 27 | +* Initial author: C. Dragomir |
28 | 28 | */
|
29 | 29 |
|
30 | 30 | #include "Arduino_LowPowerPortentaC33.h"
|
31 | 31 |
|
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 |
34 | 34 | #define WAKE_PIN A3 // Pin used to wake up the device
|
35 | 35 |
|
36 | 36 | LowPower lowPower;
|
@@ -60,16 +60,22 @@ LowPower lowPower;
|
60 | 60 | void goToSleep(){
|
61 | 61 | #ifdef TURN_PERIPHERALS_OFF
|
62 | 62 | turnPeripheralsOff();
|
| 63 | + #else |
| 64 | + // Turn off the built-in LED before going to sleep |
| 65 | + digitalWrite(LED_BUILTIN, HIGH); |
63 | 66 | #endif
|
64 | 67 | lowPower.deepSleep();
|
65 | 68 | }
|
66 | 69 |
|
67 | 70 | 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); |
69 | 74 |
|
70 | 75 | // Register the callback function to put the device to sleep when the button is pressed
|
71 | 76 | attachInterrupt(digitalPinToInterrupt(SLEEP_PIN), goToSleep, RISING);
|
72 | 77 | lowPower.enableWakeupFromPin(WAKE_PIN, RISING);
|
| 78 | + |
73 | 79 | pinMode(LED_BUILTIN, OUTPUT);
|
74 | 80 |
|
75 | 81 | #ifdef TURN_PERIPHERALS_OFF
|
|
0 commit comments